From: David Laight <david.laight.linux@gmail.com>
To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: David Laight <david.laight.linux@gmail.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Arnd Bergmann <arnd@arndb.de>, Kees Cook <kees@kernel.org>
Subject: [PATCH 2/2] fs: Use masked_user_read_access_begin()
Date: Sun, 9 Feb 2025 10:56:00 +0000 [thread overview]
Message-ID: <20250209105600.3388-3-david.laight.linux@gmail.com> (raw)
In-Reply-To: <20250209105600.3388-1-david.laight.linux@gmail.com>
Commit 2865baf54077a changed get_sigset_argpack() to use
masked_user_access_begin() and avoid a slow synchronisation instruction.
Replace the rather unwieldy code pattern with
masked_user_read_access_begin().
Make the same change to get_compat_sigset_argpack().
Use masked_user_write_access_begin() in do_sys_poll() to avoid
the size calculation and conditional branch for access_ok().
Code generated for get_sigset_argpack() is identical.
Signed-off-by: David Laight <david.laight.linux@gmail.com>
---
fs/select.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/fs/select.c b/fs/select.c
index 7da531b1cf6b..abe2c1a57274 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -776,9 +776,7 @@ static inline int get_sigset_argpack(struct sigset_argpack *to,
{
// the path is hot enough for overhead of copy_from_user() to matter
if (from) {
- if (can_do_masked_user_access())
- from = masked_user_access_begin(from);
- else if (!user_read_access_begin(from, sizeof(*from)))
+ if (!masked_user_read_access_begin(&from, sizeof(*from)))
return -EFAULT;
unsafe_get_user(to->p, &from->p, Efault);
unsafe_get_user(to->size, &from->size, Efault);
@@ -1009,7 +1007,7 @@ static int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
fdcount = do_poll(head, &table, end_time);
poll_freewait(&table);
- if (!user_write_access_begin(ufds, nfds * sizeof(*ufds)))
+ if (!masked_user_write_access_begin(&ufds, nfds * sizeof(*ufds)))
goto out_fds;
for (walk = head; walk; walk = walk->next) {
@@ -1347,7 +1345,7 @@ static inline int get_compat_sigset_argpack(struct compat_sigset_argpack *to,
struct compat_sigset_argpack __user *from)
{
if (from) {
- if (!user_read_access_begin(from, sizeof(*from)))
+ if (!masked_user_read_access_begin(&from, sizeof(*from)))
return -EFAULT;
unsafe_get_user(to->p, &from->p, Efault);
unsafe_get_user(to->size, &from->size, Efault);
--
2.39.5
prev parent reply other threads:[~2025-02-09 10:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-09 10:55 [PATCH 0/2] uaccess: Add masked_user_read_access_begin David Laight
2025-02-09 10:55 ` [PATCH 1/2] uaccess: Simplify code pattern for masked user copies David Laight
2025-02-09 17:40 ` Linus Torvalds
2025-02-09 18:34 ` David Laight
2025-02-09 18:40 ` Linus Torvalds
2025-02-09 18:46 ` Linus Torvalds
2025-02-09 19:02 ` David Laight
2025-02-09 19:47 ` David Laight
2025-02-09 20:40 ` Linus Torvalds
2025-02-09 21:18 ` David Laight
2025-02-09 21:38 ` Linus Torvalds
2025-02-09 10:56 ` David Laight [this message]
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=20250209105600.3388-3-david.laight.linux@gmail.com \
--to=david.laight.linux@gmail.com \
--cc=arnd@arndb.de \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=kees@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.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