Thread View: linux.kernel.netdev
2 messages
2 total messages
Started by David Laight
Sun, 18 Oct 2026 19:48
Re: [BUG] vhost/vringh: __get_user without access_ok leaks kernel memory via vDPA passthrough
Author: David Laight
Date: Sun, 18 Oct 2026 19:48
Date: Sun, 18 Oct 2026 19:48
55 lines
9990 bytes
9990 bytes
On Sun, 18 Oct 2026 15:24:41 -0400
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> On Thu, Oct 15, 2026 at 03:23:45PM +0800, Haoran Wang wrote:
> > I'd like to report an issue in drivers/vhost/vringh.c:1216 (function
> > getu16_iotlb), found via static analysis of Linux 7.0.11 and verified
> > against the 7.2.10 source tree. I have reproduced the leak on an
> > unmodified 7.2.10 kernel.
>
>
> This should fix it I think? Can you confirm pls?
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> drivers/vhost/vringh.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
> index 9066f9f12ba1..4b097170bd36 100644
> --- a/drivers/vhost/vringh.c
> +++ b/drivers/vhost/vringh.c
> @@ -1213,7 +1213,11 @@ static inline int getu16_iotlb(const struct vringh *vrh,
> return ret;
>
> if (vrh->use_va) {
> - ret = __get_user(tmp, (__virtio16 __user *)ivec.iov.iovec[0].iov_base);
> + __virtio16 __user *uaddr = ivec.iov.iovec[0].iov_base;
> +
> + if (!access_ok(uaddr, sizeof(*p)))
> + return -EFAULT;
> + ret = __get_user(tmp, uaddr);
Can't that be a normal get_user() call?
David
> if (ret)
> return ret;
> } else {
> @@ -1251,7 +1255,11 @@ static inline int putu16_iotlb(const struct vringh *vrh,
> tmp = cpu_to_vringh16(vrh, val);
>
> if (vrh->use_va) {
> - ret = __put_user(tmp, (__virtio16 __user *)ivec.iov.iovec[0].iov_base);
> + __virtio16 __user *uaddr = ivec.iov.iovec[0].iov_base;
> +
> + if (!access_ok(uaddr, sizeof(*p)))
> + return -EFAULT;
> + ret = __put_user(tmp, uaddr);
> if (ret)
> return ret;
> } else {
>
>
Re: [BUG] vhost/vringh: __get_user without access_ok leaks kernel memory via vDPA passthrough
Author: Linus Torvalds
Date: Sun, 18 Oct 2026 23:12
Date: Sun, 18 Oct 2026 23:12
29 lines
10396 bytes
10396 bytes
On Sun, 18 Oct 2026 at 12:06, Linus Torvalds
<torvalds@linuxfoundation.org> wrote:
>
> That's a separate bug, and you really shouldn't use __get_user to work around it just because it doesn't check.
>
> You should use pagefault_disable() around the access. And if there is still a sleep_on() complaint, that should be fixed.
Ok, no longer driving around and checked: using pagefault_disable()
around the get_user() should indeed fix the warning, because
get_user() uses 'might_fault()', which doesn't complain if
pagefault_disabled() is set.
Admittedly the actual fault handler uses a different check: it uses
faulthandler_disabled(), which also checks for "in_atomic()", which is
why that __get_user() case just silently happened to work (badly).
But that check is historical - but actively wrong - the added
in_atomic() check in faulthandler_disabled() also checks for disabled
preemption, which is one of those "it's not reliable" things (because
the preemption count depends on whether preemption is enabled at
all!).
So no. There are exactly _zero_ valid reasons to use __get_user() and
friends. We really need to just get rid of that broken garbage. All it
does now is open up potential security holes and allow people to avoid
warnings for actively buggy code.
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