Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Jul 2017 17:24:19 +1000 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        freebsd-bugs@freebsd.org
Cc:        freebsd-standards@freebsd.org
Subject:   Re: [Bug 220779] getgroups result is affected by setegid
Message-ID:  <20170717164107.G987@besplex.bde.org>
In-Reply-To: <bug-220779-15@https.bugs.freebsd.org/bugzilla/>
References:  <bug-220779-15@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 16 Jul 2017 a bug that doesn't want replies@freebsd.org wrote:

> ...
>           Summary: getgroups result is affected by setegid
> ...
>          Reporter: muh.muhten@gmail.com
>
> On FreeBSD, the groups applicable to a process are stored in an array wit=
h the
> egid in [0] and and zero or more (not necessarily distinct) additional gi=
ds in
> sorted order.
>
> The setgid, setegid, and setregid functions change the egid of a process,=
 but
> the process's supplementary group ids are to remain unchanged. Since getg=
roups,
> which claims to conform to IEEE Std 1003.1-2008 (=E2=80=9CPOSIX.1=E2=80=
=9D), is defined to fill
> its second argument with calling process's supplementary group ids, so it=
s

No, its second arg is filled with the egid and then the supplementary group
ids.

> output must not include the egid, which is changed by setgid &c.. The cur=
rent
> implementation fills the second argument with the entire groups array, wh=
ich
> does include the egid in [0].

Slot [0] is the non-supplementary part of the list.

> - "The setgid() function shall not affect the supplementary group list in=
 any
> way. Any supplementary group IDs of the calling process shall remain
> unchanged."
> - "The setegid() function shall not affect the supplementary group list i=
n any
> way."
> - (ditto for setregid)

Satisified since setting the gid only changes slot [0] in the list.

> - "The getgroups() function shall fill in the array grouplist with the cu=
rrent
> supplementary group IDs of the calling process. It is implementation-defi=
ned
> whether getgroups() also returns the effective group ID in the grouplist
> array."

This is what allows FreeBSD to return the gid in slot [0].

> - "A process has up to {NGROUPS_MAX} supplementary group IDs in addition =
to the
> effective group ID."

So in implementations that return the egid in the array, the array can have
length 1 + {NGROUPS_MAX} elements.  POSIX says this too.

FreeBSD used to have an off-by-1 bug in this area.  It used to have a limit
of {NGROUPS_MAX} elements in the array.  So it didn't actually support
{NGROUPS_MAX} supplementary gids, but 1 less than that.  When I looked at
that many years ago, I suspected that it had the bug in this PR, but I
can't see this bug now.

There are still bugs in this area:
- FreeBSD doesn't document its implementation-defined behaviour that
   getgroups() returns the egid in the array.  It's getgroups(2) man
   page doesn't use the POSIX term "supplementary group" at all, but uses
   the generic term "group list".
- POSIX doesn't require getgroups() to return the egid in any particular
   place in the array (or disallow returning it more than once if there is
   space to spare).  So it is not a bug for FreeBSD to not document the
   particular place that it uses, but applications have a difficult time
   determining which ids in the list are supplementary.
- POSIX is not completely clear about disallowing multiple filling of the
   list with supplementary ids when there is space to spare, or about wasti=
ng
   space so that there is not enough.  The 2001 version even seems to allow
   expanding the return value beyond 1 + {NGROUPS_MAX} in the case where
   the egid is not returned, to provide enough space after wasting some.

Bruce
From owner-freebsd-bugs@freebsd.org  Mon Jul 17 08:51:53 2017
Return-Path: <owner-freebsd-bugs@freebsd.org>
Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0A71DD14527
 for <freebsd-bugs@mailman.ysv.freebsd.org>;
 Mon, 17 Jul 2017 08:51:53 +0000 (UTC)
 (envelope-from bugzilla-noreply@freebsd.org)
Received: from kenobi.freebsd.org (kenobi.freebsd.org
 [IPv6:2001:1900:2254:206a::16:76])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id ECCEA7CC8D
 for <freebsd-bugs@FreeBSD.org>; Mon, 17 Jul 2017 08:51:52 +0000 (UTC)
 (envelope-from bugzilla-noreply@freebsd.org)
Received: from bugs.freebsd.org ([127.0.1.118])
 by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id v6H8pqms054843
 for <freebsd-bugs@FreeBSD.org>; Mon, 17 Jul 2017 08:51:52 GMT
 (envelope-from bugzilla-noreply@freebsd.org)
From: bugzilla-noreply@freebsd.org
To: freebsd-bugs@FreeBSD.org
Subject: [Bug 220790] [Hyper-V]Fail to install on Hyper-V GEN2 VM on
 win2012r2 or win2016
Date: Mon, 17 Jul 2017 08:51:52 +0000
X-Bugzilla-Reason: AssignedTo
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: Base System
X-Bugzilla-Component: kern
X-Bugzilla-Version: CURRENT
X-Bugzilla-Keywords: 
X-Bugzilla-Severity: Affects Only Me
X-Bugzilla-Who: honzhan@microsoft.com
X-Bugzilla-Status: New
X-Bugzilla-Resolution: 
X-Bugzilla-Priority: ---
X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org
X-Bugzilla-Flags: 
X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform
 op_sys bug_status bug_severity priority component assigned_to reporter
 attachments.created
Message-ID: <bug-220790-8@https.bugs.freebsd.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-BeenThere: freebsd-bugs@freebsd.org
X-Mailman-Version: 2.1.23
Precedence: list
List-Id: Bug reports <freebsd-bugs.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/freebsd-bugs>,
 <mailto:freebsd-bugs-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-bugs/>;
List-Post: <mailto:freebsd-bugs@freebsd.org>
List-Help: <mailto:freebsd-bugs-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/freebsd-bugs>,
 <mailto:freebsd-bugs-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 17 Jul 2017 08:51:53 -0000

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D220790

            Bug ID: 220790
           Summary: [Hyper-V]Fail to install on Hyper-V GEN2 VM on
                    win2012r2 or win2016
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: freebsd-bugs@FreeBSD.org
          Reporter: honzhan@microsoft.com

Created attachment 184422
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D184422&action=
=3Dedit
Boot log of installation failure for GEN2 VM

If you want to install FreeBSD 11.1 or 12-current on win2012r2 or win2016
Hyper-V GEN2 mode, you may encounter the failure to attach CD/DVD ROM. See =
the
attachment.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170717164107.G987>