Re: [BUG] vhost/vringh: __get_user without access_ok leaks kernel memory via vDPA passthrough
From: Michael S. Tsirkin
Date: Sun Oct 18 2026 - 17:43:35 EST
On Sun, Oct 18, 2026 at 10:34:12AM -1000, Linus Torvalds wrote:
> On Sun, 18 Oct 2026 at 09:26, Michael S. Tsirkin <mst@xxxxxxxxxx> 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.
Right, I was thinking of some other code. This one should just be
get_user.
> 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