All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virt: vbox: Do not report user namespace root as root to the host
@ 2026-11-13  9:07 Hungyu Lin
  2026-11-13  9:48 ` Hans de Goede
  0 siblings, 1 reply; 4+ messages in thread
From: Hungyu Lin @ 2026-11-13  9:07 UTC (permalink / raw)
  To: hansg; +Cc: arnd, gregkh, linux-kernel, dennylin0707

vbg_misc_device_requestor() decides whether the opener of the vboxguest
or vboxuser device is reported to the host as root:

	if (from_kuid(current_user_ns(), current_uid()) == 0)
		requestor |= VMMDEV_REQUESTOR_USR_ROOT;

from_kuid() translates the uid into the user namespace of the caller.
An unprivileged user who creates a user namespace and maps their uid to
0 in it is therefore reported as VMMDEV_REQUESTOR_USR_ROOT for every
request of that session, although the uid has no privileges outside of
that namespace. The host uses the user class to account the HGCM
requests of a session, so such a user is charged to the budget of root
instead of the one for ordinary users.

Compare the uid against GLOBAL_ROOT_UID so that only root in the initial
user namespace is reported as root.

Fixes: 0532a1b0d045 ("virt: vbox: Implement passing requestor info to the host for VirtualBox 6.0.x")
Cc: stable@vger.kernel.org
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
 drivers/virt/vboxguest/vboxguest_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c
index 7474bae2cd9a..ff66c00c27da 100644
--- a/drivers/virt/vboxguest/vboxguest_linux.c
+++ b/drivers/virt/vboxguest/vboxguest_linux.c
@@ -35,7 +35,7 @@ static u32 vbg_misc_device_requestor(struct inode *inode)
 			VMMDEV_REQUESTOR_CON_DONT_KNOW |
 			VMMDEV_REQUESTOR_TRUST_NOT_GIVEN;

-	if (from_kuid(current_user_ns(), current_uid()) == 0)
+	if (uid_eq(current_uid(), GLOBAL_ROOT_UID))
 		requestor |= VMMDEV_REQUESTOR_USR_ROOT;
 	else
 		requestor |= VMMDEV_REQUESTOR_USR_USER;
--
2.43.0

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

* Re: [PATCH] virt: vbox: Do not report user namespace root as root to the host
  2026-11-13  9:07 [PATCH] virt: vbox: Do not report user namespace root as root to the host Hungyu Lin
@ 2026-11-13  9:48 ` Hans de Goede
  2026-12-04  1:03   ` Hungyu Lin
  0 siblings, 1 reply; 4+ messages in thread
From: Hans de Goede @ 2026-11-13  9:48 UTC (permalink / raw)
  To: Hungyu Lin; +Cc: arnd, gregkh, linux-kernel

Hi,

On 13-Nov-26 10:07, Hungyu Lin wrote:
> vbg_misc_device_requestor() decides whether the opener of the vboxguest
> or vboxuser device is reported to the host as root:
> 
> 	if (from_kuid(current_user_ns(), current_uid()) == 0)
> 		requestor |= VMMDEV_REQUESTOR_USR_ROOT;
> 
> from_kuid() translates the uid into the user namespace of the caller.
> An unprivileged user who creates a user namespace and maps their uid to
> 0 in it is therefore reported as VMMDEV_REQUESTOR_USR_ROOT for every
> request of that session, although the uid has no privileges outside of
> that namespace. The host uses the user class to account the HGCM
> requests of a session, so such a user is charged to the budget of root
> instead of the one for ordinary users.
> 
> Compare the uid against GLOBAL_ROOT_UID so that only root in the initial
> user namespace is reported as root.
> 
> Fixes: 0532a1b0d045 ("virt: vbox: Implement passing requestor info to the host for VirtualBox 6.0.x")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>

Regards,

Hans



> ---
>  drivers/virt/vboxguest/vboxguest_linux.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c
> index 7474bae2cd9a..ff66c00c27da 100644
> --- a/drivers/virt/vboxguest/vboxguest_linux.c
> +++ b/drivers/virt/vboxguest/vboxguest_linux.c
> @@ -35,7 +35,7 @@ static u32 vbg_misc_device_requestor(struct inode *inode)
>  			VMMDEV_REQUESTOR_CON_DONT_KNOW |
>  			VMMDEV_REQUESTOR_TRUST_NOT_GIVEN;
> 
> -	if (from_kuid(current_user_ns(), current_uid()) == 0)
> +	if (uid_eq(current_uid(), GLOBAL_ROOT_UID))
>  		requestor |= VMMDEV_REQUESTOR_USR_ROOT;
>  	else
>  		requestor |= VMMDEV_REQUESTOR_USR_USER;
> --
> 2.43.0


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

* Re: [PATCH] virt: vbox: Do not report user namespace root as root to the host
  2026-11-13  9:48 ` Hans de Goede
@ 2026-12-04  1:03   ` Hungyu Lin
  2026-12-04  4:02     ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Hungyu Lin @ 2026-12-04  1:03 UTC (permalink / raw)
  To: Hans de Goede; +Cc: arnd, gregkh, linux-kernel

Hi Greg,

Gentle ping. This has a Reviewed-by from Hans. Could it be picked up?

Thanks,
Hungyu

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

* Re: [PATCH] virt: vbox: Do not report user namespace root as root to the host
  2026-12-04  1:03   ` Hungyu Lin
@ 2026-12-04  4:02     ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2026-12-04  4:02 UTC (permalink / raw)
  To: Hungyu Lin; +Cc: Hans de Goede, arnd, linux-kernel

On Thu, Dec 03, 2026 at 05:03:32PM -0800, Hungyu Lin wrote:
> Hi Greg,
> 
> Gentle ping. This has a Reviewed-by from Hans. Could it be picked up?

I see no context here, sorry.  Remember, some of us get 1000+ emails a
day.

Anyway, I'm digging through my queue now, already processed 3000+ usb
patches, will get to these in the next day or so "hopefully"...

To make things go faster, always help out by reviewing other people's
patches.  That way yours go up the queue.

thanks,

greg k-h

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

end of thread, other threads:[~2026-12-04  4:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13  9:07 [PATCH] virt: vbox: Do not report user namespace root as root to the host Hungyu Lin
2026-11-13  9:48 ` Hans de Goede
2026-12-04  1:03   ` Hungyu Lin
2026-12-04  4:02     ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.