[vbox-dev] Patch needed for VB modules with kernel 2.6.29
Larry Finger
Larry.Finger at lwfinger.net
Mon Dec 29 09:50:14 PST 2008
The merge period from kernel 2.6.28 to 2.6.29 has started. As usually happens,
some of the internal structures have changed. If you now try to compile the
modules that accompany the binary release (VB 2.1.0 in my case), the following
compile errors are found:
CC [M] /usr/share/virtualbox/src/vboxdrv/linux/SUPDrv-linux.o
/usr/share/virtualbox/src/vboxdrv/linux/SUPDrv-linux.c: In function ‘VBoxDrvLinuxCreate’:
/usr/share/virtualbox/src/vboxdrv/linux/SUPDrv-linux.c:706: error: ‘struct task_struct’ has no
member named ‘euid’
/usr/share/virtualbox/src/vboxdrv/linux/SUPDrv-linux.c:719: error: ‘struct task_struct’ has no
member named ‘uid’
/usr/share/virtualbox/src/vboxdrv/linux/SUPDrv-linux.c:720: error: ‘struct task_struct’ has no
member named ‘gid’
make[3]: *** [/usr/share/virtualbox/src/vboxdrv/linux/SUPDrv-linux.o] Error 1
These missing members are now located in struct cred referenced from
task_struct. The patch for these errors is:
Index: src/vboxdrv/linux/SUPDrv-linux.c
===================================================================
--- src.orig/vboxdrv/linux/SUPDrv-linux.c
+++ src/vboxdrv/linux/SUPDrv-linux.c
@@ -703,7 +703,7 @@ static int VBoxDrvLinuxCreate(struct ino
/*
* Only root is allowed to access the device, enforce it!
*/
- if (current->euid != 0 /* root */ )
+ if (current->real_cred->euid != 0 /* root */ )
{
Log(("VBoxDrvLinuxCreate: euid=%d, expected 0 (root)\n", current->euid));
return -EPERM;
@@ -716,8 +716,8 @@ static int VBoxDrvLinuxCreate(struct ino
rc = supdrvCreateSession(&g_DevExt, true /* fUser */, (PSUPDRVSESSION *)&pSession);
if (!rc)
{
- pSession->Uid = current->uid;
- pSession->Gid = current->gid;
+ pSession->Uid = current->real_cred->uid;
+ pSession->Gid = current->real_cred->gid;
}
pFilp->private_data = pSession;
The above patch will have to be removed to generate modules for 2.6.28 and
earlier. It should only be used until 2.6.29-rc1 is released. At that point, the
following patch should replace it:
Index: src/vboxdrv/linux/SUPDrv-linux.c
===================================================================
--- src.orig/vboxdrv/linux/SUPDrv-linux.c
+++ src/vboxdrv/linux/SUPDrv-linux.c
@@ -703,7 +703,11 @@ static int VBoxDrvLinuxCreate(struct ino
/*
* Only root is allowed to access the device, enforce it!
*/
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
+ if (current->real_cred->euid != 0 /* root */ )
+#else
if (current->euid != 0 /* root */ )
+#endif
{
Log(("VBoxDrvLinuxCreate: euid=%d, expected 0 (root)\n", current->euid));
return -EPERM;
@@ -716,8 +720,13 @@ static int VBoxDrvLinuxCreate(struct ino
rc = supdrvCreateSession(&g_DevExt, true /* fUser */, (PSUPDRVSESSION *)&pSession);
if (!rc)
{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
+ pSession->Uid = current->real_cred->uid;
+ pSession->Gid = current->real_cred->gid;
+#else
pSession->Uid = current->uid;
pSession->Gid = current->gid;
+#endif
}
pFilp->private_data = pSession;
----
More information about the vbox-dev
mailing list