* [PATCH] fs: Return -EFAULT if copy_to_user() fails
@ 2021-03-01 11:26 Wang Qing
2021-03-01 12:52 ` Matthew Wilcox
0 siblings, 1 reply; 2+ messages in thread
From: Wang Qing @ 2021-03-01 11:26 UTC (permalink / raw)
To: Alexander Viro, linux-fsdevel, linux-kernel; +Cc: Wang Qing
The copy_to_user() function returns the number of bytes remaining to be
copied, but we want to return -EFAULT if the copy doesn't complete.
Signed-off-by: Wang Qing <wangqing@vivo.com>
---
fs/select.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/select.c b/fs/select.c
index 37aaa83..93cd35b
--- a/fs/select.c
+++ b/fs/select.c
@@ -400,7 +400,7 @@ static inline unsigned long __must_check
set_fd_set(unsigned long nr, void __user *ufdset, unsigned long *fdset)
{
if (ufdset)
- return __copy_to_user(ufdset, fdset, FDS_BYTES(nr));
+ return __copy_to_user(ufdset, fdset, FDS_BYTES(nr)) ? -EFAULT : 0;
return 0;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fs: Return -EFAULT if copy_to_user() fails
2021-03-01 11:26 [PATCH] fs: Return -EFAULT if copy_to_user() fails Wang Qing
@ 2021-03-01 12:52 ` Matthew Wilcox
0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2021-03-01 12:52 UTC (permalink / raw)
To: Wang Qing; +Cc: Alexander Viro, linux-fsdevel, linux-kernel
On Mon, Mar 01, 2021 at 07:26:00PM +0800, Wang Qing wrote:
> The copy_to_user() function returns the number of bytes remaining to be
> copied, but we want to return -EFAULT if the copy doesn't complete.
... which is done by the only caller.
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;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-01 12:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01 11:26 [PATCH] fs: Return -EFAULT if copy_to_user() fails Wang Qing
2021-03-01 12:52 ` Matthew Wilcox
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.