NetBSD Problem Report #9335
Received: (qmail 28939 invoked from network); 2 Feb 2000 20:39:25 -0000
Message-Id: <200002022026.VAA12957@grzyb.anal.net>
Date: Wed, 2 Feb 2000 21:26:27 +0100 (CET)
From: w.wnuk@zodiac.mimuw.edu.pl
Reply-To: w.wnuk@zodiac.mimuw.edu.pl
To: gnats-bugs@gnats.netbsd.org
Subject: Linux fsuid system calls
X-Send-Pr-Version: 3.95
>Number: 9335
>Category: kern
>Synopsis: Linux fsuid system calls
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: abs
>State: closed
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Wed Feb 02 12:42:00 +0000 2000
>Closed-Date: Mon Aug 07 16:12:29 +0000 2000
>Last-Modified: Mon Aug 07 16:12:29 +0000 2000
>Originator: Witold J. Wnuk
>Release: February 1
>Organization:
MIMUW
>Environment:
System: NetBSD grzyb.anal.net 1.4Q NetBSD 1.4Q (NGRZYB) #22: Tue Feb 1 15:12:01 CET 2000 witek@grzyb.anal.net:/empire/src/sys/arch/i386/compile/NGRZYB i386
>Description:
Linux binaries that use setfsuid and getfsuid dumps core
(Bad system call)
>How-To-Repeat:
Run Linux binary statically linked or linked with original Linux
libraries (eg. SuSe 6.3)
>Fix:
We don't support the fsuid concept, but:
o returning uid in linux_sys_getfsuid seems perfectly right.
o accepting fsuid == uid in linux_sys_setfsuid (and doing nothing)
seems perfectly right too.
And following is quite common use of these two. In fact, both Slang
and ncurses (or does Slang just use ncurses?) do something like
setfsuid(getuid()) (and setfsuid(geteuid()), but it shouldn't
be a problem).
In all other cases we should probably just return ENOSYS.
NetBSD version of Linux ncurses won't be needed this way (in suse
compat package) and statically linked binaries will be allowed to run.
patch follows (syscalls.master should be updated too):
Index: linux_misc.c
===================================================================
RCS file: /lfs/cvsroot/syssrc/sys/compat/linux/common/linux_misc.c,v
retrieving revision 1.62
diff -u -5 -r1.62 linux_misc.c
--- linux_misc.c 1999/12/16 15:09:49 1.62
+++ linux_misc.c 2000/01/30 20:44:12
@@ -904,10 +904,41 @@
(uid_t)-1 : SCARG(uap, egid);
return sys_setregid(p, &bsa, retval);
}
+/*
+ * We have nonexistant fsuid == uid.
+ * If call is no-op return 0, otherwise ENOSYS.
+ */
+int
+linux_sys_setfsuid(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_setfsuid_args /* {
+ syscallarg(uid_t) uid;
+ } */ *uap = v;
+ uid_t uid;
+
+ uid = SCARG(uap, uid);
+ if (p->p_cred->p_ruid != uid)
+ return (ENOSYS);
+ else
+ return (0);
+}
+
+int
+linux_sys_getfsuid(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ return sys_getuid(p, v, retval);
+}
+
int
linux_sys___sysctl(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: abs
State-Changed-When: Thu Feb 3 02:27:03 PST 2000
State-Changed-Why:
Committed to -current. I'll check with releng as to whether we can get this
pulled up for 1.4.2.
Thanks
.
Responsible-Changed-From-To: kern-bug-people->abs
Responsible-Changed-By: abs
Responsible-Changed-When: Thu Feb 3 02:27:03 PST 2000
Responsible-Changed-Why:
State-Changed-From-To: closed->feedback
State-Changed-By: abs
State-Changed-When: Tue Feb 15 06:17:45 PST 2000
State-Changed-Why:
After further discussion the return of ENOSYS could introduce a security
issue into linux binaries that depend on setfsuid().
Could you produce a modified version that would call sys_kill with SIGSYS in
the 'invalid' case? (I do not have time to test fully here)
Thanks
From: David Brownlee <abs@netbsd.org>
To: Witold Wnuk <ww181302@zodiac.mimuw.edu.pl>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/9335
Date: Tue, 15 Feb 2000 15:37:51 +0000 (GMT)
On Tue, 15 Feb 2000, Witold Wnuk wrote:
> On 15 Feb 2000 abs@netbsd.org wrote:
>
> > After further discussion the return of ENOSYS could introduce a security
> > issue into linux binaries that depend on setfsuid().
> I decided to return ENOSYS because: a) it was easier b) I haven't thought
> that running linux binaries as root may be secure (and I still wouldn't
> rely on it).
>
I agree running a linux binary as root is not a good thing, but
we should try to do the best we can with it :)
> > Could you produce a modified version that would call sys_kill with SIGSYS in
> > the 'invalid' case? (I do not have time to test fully here)
> I will send corrected version tomorrow (I don't have access to NetBSD
> machine right now).
Many thanks.
From: Witold Wnuk <ww181302@zodiac.mimuw.edu.pl>
To: David Brownlee <abs@netbsd.org>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/9335
Date: Wed, 16 Feb 2000 14:11:27 +0100 (CET)
> On Tue, 15 Feb 2000, Witold Wnuk wrote:
> > I will send corrected version tomorrow (I don't have access to NetBSD
> > machine right now).
here it is:
(against 1.63;
against 1.62 is at `http://zodiac.mimuw.edu.pl/~ww181302/po2')
calls sys_nosys instead of returning ENOSYS in invalid case (dumps core)
"nonexistant" -> "nonexistent"
Index: linux_misc.c
===================================================================
RCS file: /lfs/cvsroot/syssrc/sys/compat/linux/common/linux_misc.c,v
retrieving revision 1.63
diff -u -r1.63 linux_misc.c
--- linux_misc.c 2000/02/03 10:03:01 1.63
+++ linux_misc.c 2000/02/15 23:33:30
@@ -907,8 +907,8 @@
}
/*
- * We have nonexistant fsuid == uid.
- * If call is no-op return 0, otherwise ENOSYS.
+ * We have nonexistent fsuid equal to uid.
+ * If modification is requested, refuse.
*/
int
linux_sys_setfsuid(p, v, retval)
@@ -923,7 +923,7 @@
uid = SCARG(uap, uid);
if (p->p_cred->p_ruid != uid)
- return (ENOSYS);
+ return sys_nosys(p, v, retval);
else
return (0);
}
State-Changed-From-To: feedback->analyzed
State-Changed-By: abs
State-Changed-When: Thu Feb 17 04:34:30 PST 2000
State-Changed-Why:
Updated patch applied to current (thanks) Checking with tls before sending
pullup for 1.4
State-Changed-From-To: analyzed->closed
State-Changed-By: abs
State-Changed-When: Mon Aug 7 09:11:14 PDT 2000
State-Changed-Why:
Pullup request for 1.4 submitted (calls have been in -current and 1.5 without
any issues)
.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.