VirtualBox

Changeset 91551 in vbox for trunk


Ignore:
Timestamp:
Oct 4, 2021 10:01:46 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
147254
Message:

SUPDrV: The SUPDRVSESSION::Uid & Gid members should be the kernel versions, not the within-current-namespace stuff we've been using thus far on linux.

Location:
trunk/src/VBox/HostDrivers/Support
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h

    r90943 r91551  
    729729    PSUPDRVUSAGE volatile           pUsage;
    730730
    731     /** The user id of the session. (Set by the OS part.) */
     731    /** The user id of the session - set by the OS part or NIL_RTUID.
     732     * This should be unique accross namespace/zones/whatever. */
    732733    RTUID                           Uid;
    733     /** The group id of the session. (Set by the OS part.) */
     734    /** The group id of the session - set by the OS part or NIL_RTGID.
     735     * This should be unique accross namespace/zones/whatever.  */
    734736    RTGID                           Gid;
    735737    /** Per session tracer specfic data. */
  • trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c

    r90944 r91551  
    297297
    298298
    299 DECLINLINE(RTUID) vboxdrvLinuxUid(void)
     299/** Get the kernel UID for the current process. */
     300DECLINLINE(RTUID) vboxdrvLinuxKernUid(void)
    300301{
    301302#if RTLNX_VER_MIN(2,6,29)
    302303# if RTLNX_VER_MIN(3,5,0)
    303     return from_kuid(current_user_ns(), current->cred->uid);
     304    return __kuid_val(current->cred->uid);
    304305# else
    305306    return current->cred->uid;
     
    310311}
    311312
    312 DECLINLINE(RTGID) vboxdrvLinuxGid(void)
     313
     314/** Get the kernel GID for the current process. */
     315DECLINLINE(RTGID) vboxdrvLinuxKernGid(void)
    313316{
    314317#if RTLNX_VER_MIN(2,6,29)
    315318# if RTLNX_VER_MIN(3,5,0)
    316     return from_kgid(current_user_ns(), current->cred->gid);
     319    return __kgid_val(current->cred->gid);
    317320# else
    318321    return current->cred->gid;
     
    323326}
    324327
    325 DECLINLINE(RTUID) vboxdrvLinuxEuid(void)
    326 {
    327 #if RTLNX_VER_MIN(2,6,29)
    328 # if RTLNX_VER_MIN(3,5,0)
     328
     329#ifdef VBOX_WITH_HARDENING
     330/** Get the effective UID within the current user namespace. */
     331DECLINLINE(RTUID) vboxdrvLinuxEuidInNs(void)
     332{
     333# if RTLNX_VER_MIN(2,6,29)
     334#  if RTLNX_VER_MIN(3,5,0)
    329335    return from_kuid(current_user_ns(), current->cred->euid);
     336#  else
     337    return current->cred->euid;
     338#  endif
    330339# else
    331     return current->cred->euid;
    332 # endif
    333 #else
    334340    return current->euid;
    335 #endif
    336 }
     341# endif
     342}
     343#endif
     344
    337345
    338346/**
     
    509517     */
    510518    if (   fUnrestricted
    511         && vboxdrvLinuxEuid() != 0 /* root */ )
     519        && vboxdrvLinuxEuidInNs() != 0 /* root */ )
    512520    {
    513521        Log(("VBoxDrvLinuxCreate: euid=%d, expected 0 (root)\n", vboxdrvLinuxEuid()));
     
    522530    if (!rc)
    523531    {
    524         pSession->Uid = vboxdrvLinuxUid();
    525         pSession->Gid = vboxdrvLinuxGid();
     532        pSession->Uid = vboxdrvLinuxKernUid();
     533        pSession->Gid = vboxdrvLinuxKernGid();
    526534    }
    527535
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette