From owner-freebsd-current Fri Oct 12 3:27:10 2001 Delivered-To: freebsd-current@freebsd.org Received: from rj.sgi.com (rj.SGI.COM [204.94.215.100]) by hub.freebsd.org (Postfix) with ESMTP id 7EE5C37B407; Fri, 12 Oct 2001 03:27:04 -0700 (PDT) Received: from yog-sothoth.sgi.com (eugate.neu.sgi.com [144.253.131.5]) by rj.sgi.com (8.11.4/8.11.4/linux-outbound_gateway-1.0) with ESMTP id f9CAR3W27585; Fri, 12 Oct 2001 03:27:03 -0700 Received: from sgiger.munich.sgi.com (sgiger.munich.sgi.com [144.253.192.2]) by yog-sothoth.sgi.com (980305.SGI.8.8.8-aspam-6.2/980304.SGI-aspam-europe) via SMTP id MAA3128462; Fri, 12 Oct 2001 12:26:08 +0200 (CEST) mail_from (gwk@sgi.com) Received: from cuckoo.munich.sgi.com (cuckoo.munich.sgi.com [144.253.192.109]) by sgiger.munich.sgi.com (950413.SGI.8.6.12/950213.SGI.AUTOCF) via ESMTP id MAA07218; Fri, 12 Oct 2001 12:26:29 +0200 Received: from hunter.munich.sgi.com (hunter.munich.sgi.com [144.253.197.18]) by cuckoo.munich.sgi.com (SGI-8.9.3/8.9.3) with ESMTP id MAA83544; Fri, 12 Oct 2001 12:26:12 +0200 (CEST) Received: from hunter.munich.sgi.com (localhost.munich.sgi.com [127.0.0.1]) by hunter.munich.sgi.com (8.11.5/8.11.5) with ESMTP id f9CAPgY05850; Fri, 12 Oct 2001 12:25:43 +0200 (CEST) (envelope-from gwk@sgi.com) Date: Fri, 12 Oct 2001 12:25:42 +0200 Message-ID: From: "Georg-W. Koltermann" To: Robert Watson Cc: current@freebsd.org Subject: Re: VMWare2 permission problems on -current as of Sep 26 [FIXED] In-Reply-To: References: User-Agent: Wanderlust/2.4.1 (Stand By Me) SEMI/1.13.7 (Awazu) FLIM/1.13.2 (Kasanui) Emacs/20.7 (i386--freebsd) MULE/4.0 (HANANOEN) Organization: SGI X-Attribution: gwk MIME-Version: 1.0 (generated by SEMI 1.13.7 - "Awazu") Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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