NetBSD Problem Report #24381

Received: (qmail 7392 invoked by uid 605); 10 Feb 2004 17:04:03 -0000
Message-Id: <20040210170403.7391.qmail@mail.netbsd.org>
Date: 10 Feb 2004 17:04:03 -0000
From: Christian Biere <christianbiere@gmx.de>
Sender: gnats-bugs-owner@NetBSD.org
To: gnats-bugs@gnats.netbsd.org
Subject: Strange definitions of UID_MAX/GID_MAX and comments
X-Send-Pr-Version: 3.95

>Number:         24381
>Category:       misc
>Synopsis:       Strange definitions of UID_MAX/GID_MAX and comments
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 10 17:05:00 +0000 2004
>Closed-Date:    
>Last-Modified:  Thu Feb 12 14:08:00 +0000 2004
>Originator:     Christian Biere
>Release:        NetBSD 1.6ZH
>Organization:
>Environment:
System: NetBSD cyclonus 1.6ZH NetBSD 1.6ZH (STARSCREAM) #0: Fri Feb 6 00:16:58 CET 2004 root@cyclonus:/usr/src/sys/arch/i386/compile/STARSCREAM i386
>Description:

sys/sys/syslimits.h:
#define GID_MAX            2147483647U  /* max value for a gid_t (2^31-2) */
#define UID_MAX            2147483647U  /* max value for a uid_t (2^31-2) */

2147483647U is actually 2^31-1, not 2^31-2. This was already noticed by
Geoff Wing back in 1999:
http://mail-index.netbsd.org/current-users/1999/01/07/0002.html

Note the original commit message by Luke Mewburn:
-------
Revision 1.14, Thu May 22 03:02:50 1997 UTC (6 years, 8 months ago) by lukem
Branch: MAIN
Changes since 1.13: +3 -1 lines

define GID_MAX (max value permitted in gid_t) and UID_MAX (ditto for uid_t)
to 2^32-2
-------

Both were defined to 4294967294 as claimed in this message.

Here's his following commit message:
-------
Change {UID,GID}_MAX from 2^32-2 to 2^31-2 (which was the original
intention). This is because setreuid takes signed ints, which may
be -1 to indicate ``don't change [ug]id''.
-------

There are two mistakes. (-1) is 2^32-1 as long as we're at talking about
uint32_t (which is what uid_t and gid_t effectively are) but never 2^31-2.
I cannot see where setreuid uses signed ints, either. It never did, CMIIW.
The only reserved value (internally) is (-1) which is (2^32)-1
(sys/kern/kern_prot.c). So the intial commit was correct and the next was
caused by a misconception.

>How-To-Repeat:
>Fix:

Correct at least the comments to reflect reality and correct the values as
well if there aren't any obstacles.
>Release-Note:
>Audit-Trail:

From: "Greg A. Woods" <woods@weird.com>
To: Christian Biere <christianbiere@gmx.de>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: misc/24381: Strange definitions of UID_MAX/GID_MAX and comments
Date: Thu, 12 Feb 2004 04:18:18 -0500 (EST)

 [ On , February 10, 2004 at 17:04:03 (-0000), Christian Biere wrote: ]
 > Subject: misc/24381: Strange definitions of UID_MAX/GID_MAX and comments
 >
 > Correct at least the comments to reflect reality and correct the values as
 > well if there aren't any obstacles.

 I have been successfully using "(~((uid_t)0))" for both for some time.

 -- 
 						Greg A. Woods

 +1 416 218-0098                  VE3TCP            RoboHack <woods@robohack.ca>
 Planix, Inc. <woods@planix.com>          Secrets of the Weird <woods@weird.com>

From: Christian Biere <christianbiere@gmx.de>
To: "Greg A. Woods" <woods@weird.com>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: misc/24381: Strange definitions of UID_MAX/GID_MAX and comments
Date: Thu, 12 Feb 2004 15:07:32 +0100

 Greg A. Woods wrote:
 > I have been successfully using "(~((uid_t)0))" for both for some time.

 Do you actually have a user with that UID? I don't think that works. If
 you look into sys/kern/kern_prot.c, you can see that this value is
 reserved. So you'd have to use ((uid_t)-2).

 -- 
 Christian
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.