Thread View: linux.kernel.netdev
4 messages
4 total messages
Started by Linus Torvalds
Sun, 18 Oct 2026 20:34
Re: [BUG] vhost/vringh: __get_user without access_ok leaks kernel memory via vDPA passthrough
Author: Linus Torvalds
Date: Sun, 18 Oct 2026 20:34
Date: Sun, 18 Oct 2026 20:34
23 lines
9527 bytes
9527 bytes
On Sun, 18 Oct 2026 at 09:26, Michael S. Tsirkin <mst@redhat.com> wrote:
>
> + __virtio16 __user *uaddr = ivec.iov.iovec[0].iov_base;
> +
> + if (!access_ok(uaddr, sizeof(*p)))
> + return -EFAULT;
> + ret = __get_user(tmp, uaddr);
You should never use __get_user() in the first place. It is almost
always just a bug.
And __get_user() together with access_ok() is actively wrong and
stupid. It's slower, bigger, and more bug-prone than just using
"get_user()".
The *only* reason ever to use __get_user() is in very very iffy code
that might use a kernel pointer and doesn't want the access_ok() code.
Or old legacy code from the last century when __get_user() was faster
and was inlined.
Linus
Re: [BUG] vhost/vringh: __get_user without access_ok leaks kernel memory via vDPA passthrough
Author: Linus Torvalds
Date: Tue, 20 Oct 2026 06:51
Date: Tue, 20 Oct 2026 06:51
19 lines
12411 bytes
12411 bytes
On Mon, 19 Oct 2026 at 20:31, Michael S. Tsirkin <mst@redhat.com> wrote:
>
> The following seems to work for me. Testing would be appreciated.
I have a whole branch that removes __get_user() and __put_user() entirely.
Somebody should check that I did it right. But I didn't want to do the
pagefault_disable() around the vringh_notify() part, so it's not quite
the same as yours.
Let me just push it out. I was going to let it simmer, but your email
made me go "I should just let more people look at it".
Mind taking a look at the 'uaccess-cleanups' branch?
It builds for me. That's all the testing it has gotten so far. Blush.
Linus
Re: [BUG] vhost/vringh: __get_user without access_ok leaks kernel memory via vDPA passthrough
Author: David Laight
Date: Tue, 20 Oct 2026 09:21
Date: Tue, 20 Oct 2026 09:21
29 lines
12224 bytes
12224 bytes
On Mon, 19 Oct 2026 20:51:43 -1000 Linus Torvalds <torvalds@linuxfoundation.org> wrote: > On Mon, 19 Oct 2026 at 20:31, Michael S. Tsirkin <mst@redhat.com> wrote: > > > > The following seems to work for me. Testing would be appreciated. > > I have a whole branch that removes __get_user() and __put_user() entirely. There should also be very few (if any) access_ok() calls outside of the code that implements user copies. David > > Somebody should check that I did it right. But I didn't want to do the > pagefault_disable() around the vringh_notify() part, so it's not quite > the same as yours. > > Let me just push it out. I was going to let it simmer, but your email > made me go "I should just let more people look at it". > > Mind taking a look at the 'uaccess-cleanups' branch? > > It builds for me. That's all the testing it has gotten so far. Blush. > > Linus >
Re: [BUG] vhost/vringh: __get_user without access_ok leaks kernel memory via vDPA passthrough
Author: Linus Torvalds
Date: Tue, 20 Oct 2026 17:50
Date: Tue, 20 Oct 2026 17:50
19 lines
12687 bytes
12687 bytes
On Mon, 19 Oct 2026 at 23:21, David Laight <david.laight.linux@gmail.com> wrote:
>
> There should also be very few (if any) access_ok() calls outside of the code
> that implements user copies.
Note that that branch only removes __get_user/__put_user - and only on x86.
So there's still a lot of valid access_ok() calls left. Some are
around things like raw_copy_to/from_user() etc.
But some are around things that just want to verify that it's a valid
user address for other reasons. On example is in fork.c that just
checks that the stack that is supplied is ok.
But yes, the branch does remove a number of access_ok() calls. Fewer
than you'd maybe think, though.
Linus
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads