From 59cff3903bdaeff0f5daefb5fc5e362b8fb45d97 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 26 Aug 2004 20:45:32 -0700 Subject: [PATCH] copy_to_user checking in select.c Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/select.c | 7 ++++--- 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 #include #include #include @@ -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 -- cgit v1.2.3