| #
6d22cd6b
|
| 29-Aug-2025 |
Olivier Certner <olce@FreeBSD.org> |
setgroups.2: Add SECURITY CONSIDERATIONS, fix the groups limit, rework
Add a new SECURITY CONSIDERATIONS section describing in details what the new behavior is after commit 9da2fe96ff2e ("kern: fix
setgroups.2: Add SECURITY CONSIDERATIONS, fix the groups limit, rework
Add a new SECURITY CONSIDERATIONS section describing in details what the new behavior is after commit 9da2fe96ff2e ("kern: fix setgroups(2) and getgroups(2) to match other platforms"), what setgroups(2) does not do anymore, and how programs using it are affected.
Fix the groups limit after commit 9da2fe96ff2e ("kern: fix setgroups(2) and getgroups(2) to match other platforms").
Prefer a terminology referring to POSIX terms, i.e., use "effective group list" instead of "group access list".
While here, fix some style.
Note for MFC to stable/14: The content will have to be revised as the new behavior is not in place. The latter should still be mentioned as upcoming in 15.
Fixes: 9da2fe96ff2e ("kern: fix setgroups(2) and getgroups(2) to match other platforms") MFC after: 5 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52284
show more ...
|
| #
9da2fe96
|
| 15-Aug-2025 |
Kyle Evans <kevans@FreeBSD.org> |
kern: fix setgroups(2) and getgroups(2) to match other platforms
On most other platforms observed, including OpenBSD, NetBSD, and Linux, these system calls have long since been converted to only tou
kern: fix setgroups(2) and getgroups(2) to match other platforms
On most other platforms observed, including OpenBSD, NetBSD, and Linux, these system calls have long since been converted to only touching the supplementary groups of the process. This poses both portability and security concerns in porting software to and from FreeBSD, as this subtle difference is a landmine waiting to happen. Bugs have been discovered even in FreeBSD-local sources, since this behavior is somewhat unintuitive (see, e.g., fix 48fd05999b0f for chroot(8)).
Now that the egid is tracked outside of cr_groups in our ucred, convert the syscalls to deal with only supplementary groups. Some remaining stragglers in base that had baked in assumptions about these syscalls are fixed in the process to avoid heartburn in conversion.
For relnotes: application developers should audit their use of both setgroups(2) and getgroups(2) for signs that they had assumed the previous FreeBSD behavior of using the first element for the egid. Any calls to setgroups() to clear groups that used a single array of the now or soon-to-be egid can be converted to setgroups(0, NULL) calls to clear the supplementary groups entirely on all FreeBSD versions.
Co-authored-by: olce (but bugs are likely mine) Relnotes: yes (see last paragraph) Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D51648
show more ...
|
| #
8269e767
|
| 14-Nov-2023 |
Brooks Davis <brooks@FreeBSD.org> |
libsys: relocate implementations and manpages
Remove core system call implementations and documentation to lib/libsys and lib/libsys/<arch> from lib/libc/sys and lib/libc/<arch>/<sys>. Update paths
libsys: relocate implementations and manpages
Remove core system call implementations and documentation to lib/libsys and lib/libsys/<arch> from lib/libc/sys and lib/libc/<arch>/<sys>. Update paths to allow libc to find them in their new home.
Reviewed by: kib, emaste, imp Pull Request: https://github.com/freebsd/freebsd-src/pull/908
show more ...
|
| #
dc36d6f9
|
| 23-Nov-2023 |
Warner Losh <imp@FreeBSD.org> |
lib: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl s
lib: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script.
Sponsored by: Netflix
show more ...
|
| #
b2c76c41
|
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
Remove $FreeBSD$: one-line nroff pattern
Remove /^\.\\"\s*\$FreeBSD\$$\n/
|
| #
4cfb30ed
|
| 24-Jan-2018 |
Kirk McKusick <mckusick@FreeBSD.org> |
Update .Dd missed in -r328304.
Reported by: Bjoern Zeeb (bz) MFC with: 328304
|
| #
8557409f
|
| 23-Jan-2018 |
Kirk McKusick <mckusick@FreeBSD.org> |
In the C library, the setting up of the group array by various utilities is done by calling gr_addgid() for each group to be added (usually found by traversing /etc/group) then calling the setgroups(
In the C library, the setting up of the group array by various utilities is done by calling gr_addgid() for each group to be added (usually found by traversing /etc/group) then calling the setgroups() system call after the group set has been created. The gr_addgid() function (helpfully?) deduplicates the addition of group members. So, if you call it to add a group member that already exists, it is just dropped. Because group[0] is the effective group-ID and is over-written when a setgid program is run, The value in group[0] is usually duplicated so that group value is not lost when a setgid program is run.
Historically this happened because the group value indicated in the password file also appears in /etc/group (e.g., if you are group staff in the password file, you will also appear in the staff line in /etc/group). But, with the addition of the deduplication, the attempt to add group staff was lost because it already appeared in group[0]. So, the fix is to deduplicate starting from group[1] which allows a duplicate of the entry in group[0], but not in later entries.
There is some confusion about the setgroups system call because in BSD it has (always) set the entire group including the egid group (in group[0]). However, in Linux, it skips over group[0] and starts setting from group[1]. See this comment from linux_setgroups:
/* * cr_groups[0] holds egid. Setting the whole set from * the supplied set will cause egid to be changed too. * Keep cr_groups[0] unchanged to prevent that. */
To make it clear what the BSD setgroups system call does, I added the following paragraph to the setgroups(2) manual page:
The first entry of the group array (gidset[0]) is used as the effective group-ID for the process. This entry is over-written when a setgid program is run. To avoid losing access to the privileges of the gidset[0] entry, it should be duplicated later in the group array. By convention, this happens because the group value indicated in the password file also appears in /etc/group. The group value in the password file is placed in gidset[0] and that value then gets added a second time when the /etc/group file is scanned to create the group set.
Reported by: Paul McMath paulm at tetrardus.net Reviewed by: kib MFC after: 2 weeks
show more ...
|
| #
fbbd9655
|
| 28-Feb-2017 |
Warner Losh <imp@FreeBSD.org> |
Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is
Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point.
Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96
show more ...
|
| #
54404cfb
|
| 19-Jun-2009 |
Brooks Davis <brooks@FreeBSD.org> |
In preparation for raising NGROUPS and NGROUPS_MAX, change base system callers of getgroups(), getgrouplist(), and setgroups() to allocate buffers dynamically. Specifically, allocate a buffer of siz
In preparation for raising NGROUPS and NGROUPS_MAX, change base system callers of getgroups(), getgrouplist(), and setgroups() to allocate buffers dynamically. Specifically, allocate a buffer of size sysconf(_SC_NGROUPS_MAX)+1 (+2 in a few cases to allow for overflow).
This (or similar gymnastics) is required for the code to actually follow the POSIX.1-2008 specification where {NGROUPS_MAX} may differ at runtime and where getgroups may return {NGROUPS_MAX}+1 results on systems like FreeBSD which include the primary group.
In id(1), don't pointlessly add the primary group to the list of all groups, it is always the first result from getgroups(). In principle the old code was more portable, but this was only done in one of the two places where getgroups() was called to the overall effect was pointless.
Document the actual POSIX requirements in the getgroups(2) and setgroups(2) manpages. We do not yet support a dynamic NGROUPS, but we may in the future.
MFC after: 2 weeks
show more ...
|
| #
0cf1d3bf
|
| 16-Jun-2008 |
Tony Finch <fanf@FreeBSD.org> |
Make it clearer that privilege is needed to reduce as well as increase group membership.
|
| #
c879ae35
|
| 09-Jan-2007 |
Warner Losh <imp@FreeBSD.org> |
Per Regents of the University of Calfornia letter, remove advertising clause.
# If I've done so improperly on a file, please let me know.
|
| #
988d4dc3
|
| 19-Nov-2003 |
Diomidis Spinellis <dds@FreeBSD.org> |
Documented missing EINVAL errno value kern_prot.c: if (ngrp > NGROUPS) return (EINVAL);
MFC after: 2 weeks
|
| #
743d5d51
|
| 10-Sep-2003 |
Ruslan Ermilov <ru@FreeBSD.org> |
mdoc(7): Properly mark C headers.
|
| #
2efeeba5
|
| 19-Dec-2002 |
Ruslan Ermilov <ru@FreeBSD.org> |
mdoc(7) police: "The .Fa argument.".
|
| #
2faeeff4
|
| 18-Dec-2002 |
Ruslan Ermilov <ru@FreeBSD.org> |
mdoc(7) police: Tidy up the syscall language.
Stop calling system calls "function calls".
Use "The .Fn system call" a-la "The .Nm utility".
When referring to a non-BSD implementation in the HISTOR
mdoc(7) police: Tidy up the syscall language.
Stop calling system calls "function calls".
Use "The .Fn system call" a-la "The .Nm utility".
When referring to a non-BSD implementation in the HISTORY section, call syscall a function, to be safe.
show more ...
|
| #
32eef9ae
|
| 01-Oct-2001 |
Ruslan Ermilov <ru@FreeBSD.org> |
mdoc(7) police: Use the new .In macro for #include statements.
|
| #
b1250632
|
| 09-Aug-2001 |
Yaroslav Tykhiy <ytykhiy@gmail.com> |
Use the ``.Rv -std'' mdoc(7) macro in appropriate cases.
Reviewed by: ru
|
| #
7ebcc426
|
| 15-Jul-2001 |
Dima Dorfman <dd@FreeBSD.org> |
Remove whitespace at EOL.
|
| #
a307d598
|
| 10-Jul-2001 |
Ruslan Ermilov <ru@FreeBSD.org> |
mdoc(7) police: removed HISTORY info from the .Os call.
|
| #
25bb73e0
|
| 21-Apr-2000 |
Alexey Zelkin <phantom@FreeBSD.org> |
Introduce ".Lb" macro to libc manpages.
More libraries manpages updates following.
|
| #
7f3dea24
|
| 28-Aug-1999 |
Peter Wemm <peter@FreeBSD.org> |
$Id$ -> $FreeBSD$
|
| #
fbc400a6
|
| 12-Jul-1999 |
Nik Clayton <nik@FreeBSD.org> |
Add $Id$, to make it simpler for members of the translation teams to track.
The $Id$ line is normally at the bottom of the main comment block in the man page, separated from the rest of the manpage
Add $Id$, to make it simpler for members of the translation teams to track.
The $Id$ line is normally at the bottom of the main comment block in the man page, separated from the rest of the manpage by an empty comment, like so;
.\" $Id$ .\"
If the immediately preceding comment is a @(#) format ID marker than the the $Id$ will line up underneath it with no intervening blank lines. Otherwise, an additional blank line is inserted.
Approved by: bde
show more ...
|
| #
7bdf80e5
|
| 22-Aug-1996 |
Mike Pritchard <mpp@FreeBSD.org> |
Correctly use .Fn instead of .Nm to reference function names in a bunch of man pages.
Use the correct .Bx (BSD UNIX) or .At (AT&T UNIX) macros instead of explicitly specifying the version in the te
Correctly use .Fn instead of .Nm to reference function names in a bunch of man pages.
Use the correct .Bx (BSD UNIX) or .At (AT&T UNIX) macros instead of explicitly specifying the version in the text in a bunch of man pages.
show more ...
|
| #
58f0484f
|
| 27-May-1994 |
Rodney W. Grimes <rgrimes@FreeBSD.org> |
BSD 4.4 Lite Lib Sources
|