netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC] uaccess: user_access_begin_after_access_ok()
@ 2020-06-02  8:45 Michael S. Tsirkin
  2020-06-02 10:15 ` Jason Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2020-06-02  8:45 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jason Wang, netdev

So vhost needs to poke at userspace *a lot* in a quick succession.  It
is thus benefitial to enable userspace access, do our thing, then
disable. Except access_ok has already been pre-validated with all the
relevant nospec checks, so we don't need that.  Add an API to allow
userspace access after access_ok and barrier_nospec are done.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---

Jason, so I've been thinking using something along these lines,
then switching vhost to use unsafe_copy_to_user and friends would
solve lots of problems you observed with SMAP.

What do you think? Do we need any other APIs to make it practical?

 arch/x86/include/asm/uaccess.h | 1 +
 include/linux/uaccess.h        | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index d8f283b9a569..fa5afb3a54fe 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -483,6 +483,7 @@ static __must_check __always_inline bool user_access_begin(const void __user *pt
 	return 1;
 }
 #define user_access_begin(a,b)	user_access_begin(a,b)
+#define user_access_begin_after_access_ok()	__uaccess_begin()
 #define user_access_end()	__uaccess_end()
 
 #define user_access_save()	smap_save()
diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
index 67f016010aad..4c0a959ad639 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -370,6 +370,7 @@ extern long strnlen_unsafe_user(const void __user *unsafe_addr, long count);
 
 #ifndef user_access_begin
 #define user_access_begin(ptr,len) access_ok(ptr, len)
+#define user_access_begin_after_access_ok() do { } while (0)
 #define user_access_end() do { } while (0)
 #define unsafe_op_wrap(op, err) do { if (unlikely(op)) goto err; } while (0)
 #define unsafe_get_user(x,p,e) unsafe_op_wrap(__get_user(x,p),e)
-- 
MST


^ permalink raw reply related	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2020-06-06 20:08 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02  8:45 [PATCH RFC] uaccess: user_access_begin_after_access_ok() Michael S. Tsirkin
2020-06-02 10:15 ` Jason Wang
2020-06-02 16:33   ` Al Viro
2020-06-02 17:18     ` Linus Torvalds
2020-06-02 17:44       ` Al Viro
2020-06-02 17:46         ` Al Viro
2020-06-02 20:32       ` Michael S. Tsirkin
2020-06-02 20:41         ` David Laight
2020-06-02 21:58           ` Al Viro
2020-06-03  8:08             ` David Laight
2020-06-02 20:43         ` Linus Torvalds
2020-06-03  6:01           ` Michael S. Tsirkin
     [not found]             ` <CAHk-=wi3=QuD30fRq8fYYTj9WmkgeZ0VR_Sh3DQHU+nmwj-jMg@mail.gmail.com>
2020-06-03 16:59               ` Linus Torvalds
2020-06-02 16:30 ` Al Viro
2020-06-02 20:42   ` Michael S. Tsirkin
2020-06-02 22:10     ` Al Viro
2020-06-03  5:17       ` Michael S. Tsirkin
2020-06-03  1:48 ` Al Viro
2020-06-03  3:57   ` Jason Wang
2020-06-03  4:18     ` Al Viro
2020-06-03  5:18       ` Jason Wang
2020-06-03  5:46         ` Michael S. Tsirkin
2020-06-03  6:23           ` Jason Wang
2020-06-03  6:30             ` Michael S. Tsirkin
2020-06-03  6:36               ` Jason Wang
2020-06-04 16:49                 ` Michael S. Tsirkin
2020-06-05 10:03                   ` Jason Wang
2020-06-06 20:08                     ` Michael S. Tsirkin
2020-06-03  6:25       ` Michael S. Tsirkin
2020-06-03  5:29   ` Michael S. Tsirkin
2020-06-03 16:52     ` Al Viro
2020-06-04  6:10       ` Jason Wang
2020-06-04 14:59         ` Al Viro
2020-06-04 16:46           ` Michael S. Tsirkin
2020-06-04 10:10       ` Michael S. Tsirkin
2020-06-04 15:03         ` Al Viro
2020-06-04 16:47           ` Michael S. Tsirkin

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).