diff options
| author | Andrew Morton <akpm@osdl.org> | 2004-08-26 20:45:32 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-08-26 20:45:32 -0700 |
| commit | 59cff3903bdaeff0f5daefb5fc5e362b8fb45d97 (patch) | |
| tree | bfbd8e2ddc0d420529e989f0c2d7297c34a44ca5 | |
| parent | f6ed4dc92d444de4bef2d5462c18cafdefcd1d88 (diff) | |
[PATCH] copy_to_user checking in select.c
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
| -rw-r--r-- | fs/select.c | 7 | ||||
| -rw-r--r-- | include/linux/poll.h | 8 |
2 files changed, 9 insertions, 6 deletions
diff --git a/fs/select.c b/fs/select.c index 4dbc1d99a05e..dfff0ad1baf5 100644 --- a/fs/select.c +++ b/fs/select.c @@ -373,9 +373,10 @@ sys_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, s ret = 0; } - set_fd_set(n, inp, fds.res_in); - set_fd_set(n, outp, fds.res_out); - set_fd_set(n, exp, fds.res_ex); + if (set_fd_set(n, inp, fds.res_in) || + set_fd_set(n, outp, fds.res_out) || + set_fd_set(n, exp, fds.res_ex)) + ret = -EFAULT; out: select_bits_free(bits, size); diff --git a/include/linux/poll.h b/include/linux/poll.h index b4bb681fd1ca..1bb33342cbbd 100644 --- a/include/linux/poll.h +++ b/include/linux/poll.h @@ -5,6 +5,7 @@ #ifdef __KERNEL__ +#include <linux/compiler.h> #include <linux/wait.h> #include <linux/string.h> #include <linux/mm.h> @@ -81,11 +82,12 @@ int get_fd_set(unsigned long nr, void __user *ufdset, unsigned long *fdset) return 0; } -static inline -void set_fd_set(unsigned long nr, void __user *ufdset, unsigned long *fdset) +static inline unsigned long __must_check +set_fd_set(unsigned long nr, void __user *ufdset, unsigned long *fdset) { if (ufdset) - __copy_to_user(ufdset, fdset, FDS_BYTES(nr)); + return __copy_to_user(ufdset, fdset, FDS_BYTES(nr)); + return 0; } static inline |
