Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Oct 2001 12:25:42 +0200
From:      "Georg-W. Koltermann" <gwk@sgi.com>
To:        Robert Watson <rwatson@freebsd.org>
Cc:        current@freebsd.org
Subject:   Re: VMWare2 permission problems on -current as of Sep 26 [FIXED]
Message-ID:  <lthofndcfyx.wl@hunter.munich.sgi.com>
In-Reply-To: <Pine.NEB.3.96L.1011008235047.784F-100000@fledge.watson.org>
References:  <lthu1xa6q6u.wl@hunter.munich.sgi.com> <Pine.NEB.3.96L.1011008235047.784F-100000@fledge.watson.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Robert,

the problem wan't with access(2) but with preceding setresuid(2)
calls.  There was a false widening conversion taking place in
linux_uid16.c.

Various setXXid() calls allow the caller to set several ids at once,
or leave them unchanged by specifying the magic parameter -1.
Unfortunately uid_t and gid_t are unsigned, so this is asking for
trouble in itself.  The problem came to light when someone decided
that linux really passed only 16 bits of information for the ids, and
thus the passed-in ids had to be widened (unsignedly) to 32 bits for
BSD kernel land.  The C compiler happily widened an unsigned 16 bit
value of -1 to an unsiged 32 bit value of +65535 which wan't magic any
more.

I've inserted proper casts, see the attached diff, and now VMware
works again.  I'd appreciate if you could commit the patch, or
anything equivalent.

Now that VMware works I still have trouble with ORACLE.  I'll probably
csvup to today's -current before I start working (as I get time, no
promises) on that one.

--
Regards,
Georg.


At Tue, 9 Oct 2001 00:16:17 -0400 (EDT),
Robert Watson wrote:
> 
> [...]
> An interesting experiment might be to write a short program invoking
> access(2) with the same arguments, compiled under both ABIs, and then
> experimented with and without setuid-root.  A glance at the linux_access()
> implementation looks right to me, but maybe there's something going on
> relating to preserving real/saved uids/gids and the process credential.
> Or alternatively, maybe your .Xauthority file isn't readable  :-)
> [...]

--- sys/compat/linux/linux_uid16.c.gwk	Wed Sep 12 10:36:57 2001
+++ sys/compat/linux/linux_uid16.c	Thu Oct 11 23:35:53 2001
@@ -42,6 +42,13 @@
 DUMMY(getresuid16);
 DUMMY(getresgid16);
 
+/* Linux uid_t and gid_t have different sizes than BSD variants.
+ * Use XXX_TOBSD(x) macros to convert so that the "magic" values
+ * of -1 are preserved correctly.
+ */
+#define GID_TOBSD(x) ((x) == (l_gid16_t) -1 ? -1 : (x))
+#define UID_TOBSD(x) ((x) == (l_uid16_t) -1 ? -1 : (x))
+
 int
 linux_chown16(struct thread *td, struct linux_chown16_args *args)
 {
@@ -249,8 +256,8 @@
 {
 	struct setregid_args bsd;
 
-	bsd.rgid = args->rgid;
-	bsd.egid = args->egid;
+	bsd.rgid = GID_TOBSD(args->rgid);
+	bsd.egid = GID_TOBSD(args->egid);
 	return (setregid(td, &bsd));
 }
 
@@ -259,8 +266,8 @@
 {
 	struct setreuid_args bsd;
 
-	bsd.ruid = args->ruid;
-	bsd.euid = args->euid;
+	bsd.ruid = UID_TOBSD(args->ruid);
+	bsd.euid = UID_TOBSD(args->euid);
 	return (setreuid(td, &bsd));
 }
 
@@ -269,9 +276,9 @@
 {
 	struct setresgid_args bsd;
 
-	bsd.rgid = args->rgid;
-	bsd.egid = args->egid;
-	bsd.sgid = args->sgid;
+	bsd.rgid = GID_TOBSD(args->rgid);
+	bsd.egid = GID_TOBSD(args->egid);
+	bsd.sgid = GID_TOBSD(args->sgid);
 	return (setresgid(td, &bsd));
 }
 
@@ -280,8 +287,8 @@
 {
 	struct setresuid_args bsd;
 
-	bsd.ruid = args->ruid;
-	bsd.euid = args->euid;
-	bsd.suid = args->suid;
+	bsd.ruid = UID_TOBSD(args->ruid);
+	bsd.euid = UID_TOBSD(args->euid);
+	bsd.suid = UID_TOBSD(args->suid);
 	return (setresuid(td, &bsd));
 }

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?lthofndcfyx.wl>