NetBSD Problem Report #133
From gnats Fri Feb 18 23:31:26 1994
Received: from yarrina.connect.com.au (yarrina.connect.com.au [192.189.54.17]) by sun-lamp.cs.berkeley.edu (8.6.5/8.6.5) with SMTP id XAA23693 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Fri, 18 Feb 1994 23:31:23 -0800
Message-Id: <199402190722.SAA00310@pandion.eyrie.img.com.au>
Date: Sat, 19 Feb 1994 18:22:50 +1100
From: David Burren <davidb@eyrie.img.com.au>
Reply-To: davidb@eyrie.img.com.au
To: gnats-bugs@sun-lamp.cs.berkeley.edu
Subject: setuid/setgid don't check effective id
X-Send-Pr-Version: 3.2
>Number: 133
>Category: kern
>Synopsis: setuid/setgid don't check effective id
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: gnats-admin
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Feb 18 23:35:01 +0000 1994
>Closed-Date: Fri Feb 25 04:02:06 +0000 1994
>Last-Modified: Sun Mar 03 17:45:56 +0000 2013
>Originator: David Burren
>Release:
>Organization:
img Consultants
>Environment:
24/1/93 current
System: NetBSD pandion.eyrie.img.com.au 0.9a PANDION#3 i386
>Description:
According to setuid(3) (the same man page as setgid(3)):
If the user is not the super user, or the uid specified is not the real
or effective ID, these functions return -1.
The seteuid and setegid calls have this behaviour, but the setuid
and setgid calls do not. They do not check the current effective id.
This breaks programs such as INN.
Do we change the system calls or the man page? I believe the man
page is correct.
>How-To-Repeat:
setgid(getegid()) will fail in a setgid executeable where the file's
group is different from the (non-root) user.
>Fix:
*** src/sys/kern/kern_prot.c.orig Sat Feb 19 13:28:14 1994
--- src/sys/kern/kern_prot.c Sat Feb 19 13:36:01 1994
***************
*** 265,271 ****
int error;
uid = (uid_t) uap->uid;
! if (uid != pc->p_ruid &&
(error = suser(pc->pc_ucred, &p->p_acflag)))
return (error);
/*
--- 265,271 ----
int error;
uid = (uid_t) uap->uid;
! if (uid != pc->p_ruid && uid != pc->p_svuid &&
(error = suser(pc->pc_ucred, &p->p_acflag)))
return (error);
/*
***************
*** 323,329 ****
int error;
gid = (gid_t) uap->gid;
! if (gid != pc->p_rgid && (error = suser(pc->pc_ucred, &p->p_acflag)))
return (error);
pc->pc_ucred = crcopy(pc->pc_ucred);
pc->pc_ucred->cr_groups[0] = gid;
--- 323,330 ----
int error;
gid = (gid_t) uap->gid;
! if (gid != pc->p_rgid && gid != pc->p_svgid &&
! (error = suser(pc->pc_ucred, &p->p_acflag)))
return (error);
pc->pc_ucred = crcopy(pc->pc_ucred);
pc->pc_ucred->cr_groups[0] = gid;
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: cgd
State-Changed-When: Thu Feb 24 20:02:06 PST 1994
State-Changed-Why:
man page fixed; the behaviour of the syscalls was correct, but the man page
was a bit hazy. the man page is still a bit hazy, but better. 4.4-Lite
will fix this.
>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.