From: Wang Qing <wangqing@vivo.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Wang Qing <wangqing@vivo.com>
Subject: [PATCH] fs: Return -EFAULT if copy_to_user() fails
Date: Mon, 1 Mar 2021 19:26:00 +0800 [thread overview]
Message-ID: <1614597960-32681-1-git-send-email-wangqing@vivo.com> (raw)
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
next reply other threads:[~2021-03-01 11:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-01 11:26 Wang Qing [this message]
2021-03-01 12:52 ` [PATCH] fs: Return -EFAULT if copy_to_user() fails Matthew Wilcox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1614597960-32681-1-git-send-email-wangqing@vivo.com \
--to=wangqing@vivo.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).