NetBSD Problem Report #329

From gnats  Wed Jul  6 23:56:39 1994
Received: from werple.apana.org.au (werple.apana.org.au [192.188.107.10]) by sun-lamp.cs.berkeley.edu (8.6.9/8.6.9) with ESMTP id XAA11698 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Wed, 6 Jul 1994 23:56:37 -0700
Message-Id: <199407070656.QAA29439@werple.apana.org.au>
Date: Thu, 7 Jul 1994 16:56:29 +1000
From: Andrew Herbert <andrew@werple.apana.org.au>
Reply-To: andrew@werple.apana.org.au
To: gnats-bugs@sun-lamp.cs.berkeley.edu
Cc: andrew@werple.apana.org.au
Subject: initgroups(3)/setgroups(2) bug
X-Send-Pr-Version: 3.2

>Number:         329
>Category:       misc
>Synopsis:       initgroups(3)/setgroups(2) bug
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    misc-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 07 00:05:02 +0000 1994
>Closed-Date:    Mon Sep 19 07:50:57 +0000 1994
>Last-Modified:  Wed Jul 02 02:58:04 +0000 1997
>Originator:     Andrew Herbert
>Release:        
>Organization:
werple
>Environment:

System: NetBSD werple.apana.org.au 0.9C NetBSD 0.9C (WERPLE) #1: Tue Jul  5 22:47:18 EST 1994 andrew@werple.apana.org.au:/src/netbsd/sys/arch/i386/compile/WERPLE i386

>Description:
The system panics in nfs_request() with a "nfsreq nogrps".  Three factors
combine to cause this:

1. initgroups(3) does not include agroup in the groups list if agroup (a
signed int) is negative.  This can result in an empty groups list.

2. setgroups(2) accepts an empty groups list (i.e. ngroups==0).

3. the authentication code in nfs_request() requires a non-empty groups
list, panicking otherwise.

>How-To-Repeat:

main()
{
...
initgroups("nobody", -1); /* nobody doesn't appear as a user in /etc/groups */
...
/*
 * induce nfs activity (definitely happens when a vm_fault() asks for data
 * from an nfs vnode)
 */
}

>Fix:
1. Change initgroups(3) to have the following prototype:
	initgroups(const char *uname, gid_t agroup)
   and unconditionally execute:
                groups[ngroups++] = agroup;
                groups[ngroups++] = agroup;

   (or change the manpage to document the current behaviour)

   plus,

2. Include the following test in setgroups(2):

	if (ngrp == 0)
		return (EINVAL);


	There are two bugs here: 1) initgroups(3) should always be including
	the agroup argument, and 2) setgroups(2) should not allow an empty
	group list.  The former was fixed by importing the 4.4-Lite code;
	the latter I fixed myself.  - mycroft

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: mycroft 
State-Changed-When: Mon Sep 19 00:50:57 PDT 1994 
State-Changed-Why:  
Fixed.

Responsible-Changed-From-To: gnats-admin->misc-bug-people
Responsible-Changed-By: mikel
Responsible-Changed-When: Tue Jul  1 19:57:39 1997
Responsible-Changed-Why:
category changed from 'pending'.

>Unformatted:


 no
 setgroups(0, &blah) results in a ucred with ngroups==0, causing nfs panics
 serious
 high
 NetBSD 0.9C
 sw-bug

NetBSD Home
NetBSD PR Database Search

(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.