From: Coywolf Qi Hunt <[email-masked]>

GCC warns me this problem.  This patch adds copy_to_user result check in
sys_select() and sys_pselect7().

Signed-off-by: Coywolf Qi Hunt <[email-masked]>
Cc: David Woodhouse <[email-masked]>
Signed-off-by: Andrew Morton <[email-masked]>
---

 fs/select.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff -puN fs/select.c~pselect-ppoll-system-calls-copy_to_user-check fs/select.c
--- devel/fs/select.c~pselect-ppoll-system-calls-copy_to_user-check	2005-07-26 00:59:59.000000000 -0700
+++ devel-akpm/fs/select.c	2005-07-26 01:10:55.000000000 -0700
@@ -394,7 +394,14 @@ asmlinkage long sys_select(int n, fd_set
 			tv.tv_sec++;
 			tv.tv_usec -= 1000000;
 		}
-		copy_to_user(tvp, &tv, sizeof(tv));
+		if (copy_to_user(tvp, &tv, sizeof(tv))) {
+			/*
+			 * If an application puts its timeval in read-only
+			 * memory, we don't want the Linux-specific update to
+			 * the timeval to cause a fault after the select has
+			 * completed successfully
+			 */
+		}
 	}
 
 	return ret;
@@ -452,7 +459,14 @@ asmlinkage long sys_pselect7(int n, fd_s
 			ts.tv_sec++;
 			ts.tv_nsec -= 1000000000;
 		}
-		copy_to_user(tsp, &ts, sizeof(ts));
+		if (copy_to_user(tsp, &ts, sizeof(ts))) {
+			/*
+			 * If an application puts its timeval in read-only
+			 * memory, we don't want the Linux-specific update to
+			 * the timeval to cause a fault after the select has
+			 * completed successfully
+			 */
+		}
 	}
 
 	if (sigmask)
_