opnsense-src/lib
Kyle Evans 9da2fe96ff 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 48fd05999b 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
2025-08-14 23:06:09 -05:00
..
atf atf, kyua: Implement require.kmods. 2025-05-31 14:27:30 +02:00
clang clang: install clang-scan-deps 2025-07-06 22:02:52 +01:00
csu csu/tests: Add tests to verify that errno == 0 upon program startup 2025-06-24 01:24:04 +00:00
geom graid.8: fix typo 2025-04-28 10:01:30 -06:00
googletest Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
lib9p Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
lib80211 net80211: regdomain: ETSI: add missing 11a and 11na entries 2025-07-07 06:49:02 +00:00
libalias Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libarchive libarchive: Stop using readdir_r() 2025-08-02 01:11:56 +02:00
libauditd package: move OpenBSM auditing into its own package 2024-04-28 22:33:06 -06:00
libbe bectl: Use SPDX only license 2025-06-13 15:09:22 -04:00
libbearssl Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libbegemot Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libblacklist Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libblocksruntime Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libbluetooth Remove $FreeBSD$: one-line nroff pattern 2023-08-16 11:55:15 -06:00
libbsddialog Update Makefile.depend files 2024-10-14 10:26:17 -07:00
libbsdstat Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libbsm package: move OpenBSM auditing into its own package 2024-04-28 22:33:06 -06:00
libbsnmp libbsnmp: make binding of client UNIX socket optional and configurable 2025-07-25 13:10:17 -07:00
libbz2 Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libc kern: fix setgroups(2) and getgroups(2) to match other platforms 2025-08-14 23:06:09 -05:00
libc++ Merge llvm-project release/19.x llvmorg-19.1.3-0-gab51eccf88f5 2024-11-08 17:45:31 +01:00
libc++experimental Retire MK_PROFILE infrastructure 2024-11-12 12:11:51 -05:00
libc_nonshared Retire MK_PROFILE infrastructure 2024-11-12 12:11:51 -05:00
libcalendar Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libcam libcam: Include nvme opcode and status code routines from nvme_util.c 2025-06-05 21:28:38 -04:00
libcapsicum manuals: Fix "skipping end of block" .Ed errors 2024-10-03 14:49:23 -03:00
libcasper cap_fileargs.3: Polish 2025-08-08 18:08:21 +02:00
libcbor Update Makefile.depend files 2024-10-14 10:26:17 -07:00
libclang_rt Partially revert 6527682ab7 for llvm-based projects 2025-04-24 16:36:40 +02:00
libcom_err kerberos5, libcom_err, others: append to LDFLAGS instead of replacing 2025-04-05 14:19:57 -07:00
libcompat Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libcompiler_rt libgcc_s: export integer and floating point __aeabi_ symbols 2025-05-04 13:48:32 +02:00
libcrypt lib/libcrypt: reinstate CFLAGS+=-I${SRCTOP}/sys/crypto/sha2 2024-10-26 20:11:02 +02:00
libcuse Remove $FreeBSD$: one-line nroff pattern 2023-08-16 11:55:15 -06:00
libcxxrt src: Use gnu++17 as the default C++ standard 2025-04-11 09:53:50 -04:00
libder lib: hook libder up to the build 2025-01-01 15:11:06 -06:00
libdevctl manuals: Fix some "missing section argument" 2024-10-15 17:20:55 -03:00
libdevdctl Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libdevinfo libdevinfo: Avoid false positives for the root0 sentinel value 2025-01-29 10:03:59 -05:00
libdevstat Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libdiff diff: Nits in tests. 2024-05-20 16:27:50 +02:00
libdl _dl_iterate_phdr_locked(): fix libc and libdl 2024-11-14 06:14:05 +02:00
libdpv Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libdwarf Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libedit libedit: Reset WARNS 2025-04-30 15:05:00 +02:00
libefivar efivar: Kill needless sys/cdefs.h 2025-05-25 07:49:32 -06:00
libelf Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libelftc Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libevent1 Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libexecinfo Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libexpat lib/libexpat: update build config for 2.7.1 2025-04-07 11:36:45 +08:00
libfdt libfdt: Make an internal FDT library available 2024-03-21 01:05:05 -04:00
libfetch lib: Fix calls that naively set F_SETFD. 2025-07-17 17:00:32 +00:00
libfido2 Update Makefile.depend files 2024-10-14 10:26:17 -07:00
libfigpar Refactor error handling in lseek operations 2024-09-21 05:25:15 -06:00
libgcc_eh src: Use gnu++17 as the default C++ standard 2025-04-11 09:53:50 -04:00
libgcc_s libgcc_s: export integer and floating point __aeabi_ symbols 2025-05-04 13:48:32 +02:00
libgeom libgeom: Avoid fixed remappings of the devstat device 2024-08-19 16:02:59 +00:00
libgpio Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libgssapi Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libiconv_modules Retire MK_PROFILE infrastructure 2024-11-12 12:11:51 -05:00
libifconfig bridge: Add a vlanfilter bridge option 2025-08-03 23:55:10 +01:00
libipsec libipsec: decode SADB_X_EXT_IF_HW_OFFL 2024-07-12 06:29:31 +03:00
libipt Update Makefile.depend files 2024-10-14 10:26:17 -07:00
libiscsiutil libiscsiutil: Fix header to work with C++ 2025-04-02 14:40:32 -04:00
libjail jail: Add meta and env parameters 2025-03-31 09:17:03 +00:00
libkiconv Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libkldelf libkldelf: add see_local parameter to elf_lookup_symbol 2024-10-25 16:20:16 +00:00
libkvm libkvm/kvm_open.3: document broken full dumps 2025-06-22 06:49:32 +03:00
libldns Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
liblua Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
liblutok lutok: Switch from std::auto_ptr<> to std::unique_ptr<> 2025-04-16 10:09:18 -04:00
liblzma MFV: xz 5.8.1. 2025-05-04 00:06:22 -07:00
libmagic libmagic: Unbreak for older FreeBSD releases. 2025-01-07 20:42:16 -08:00
libmd lib/libmd: reenable AVX2 SHA1 kernel 2025-06-04 12:28:03 +02:00
libmemstat Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libmilter Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libmixer mixer(3): Do not skip devices with no volume control 2025-02-25 13:44:49 +02:00
libmp Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libmt Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libnetbsd Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libnetgraph lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libnetmap Update Makefile.depend files 2024-10-14 10:26:17 -07:00
libnv libnv: add tests to verify potential overflow issues 2024-09-04 13:43:16 +02:00
libnvmf libnvmf: Fix header to work with C++ 2025-08-06 15:56:05 -04:00
libomp Partially revert 6527682ab7 for llvm-based projects 2025-04-24 16:36:40 +02:00
libopenbsd libopenbsd: Add recallocarray() 2025-07-06 23:09:00 +00:00
libopencsd lib: Move libopencsd to /usr/lib and make private 2025-07-30 11:11:38 +01:00
libpam pam_ksu: Fix crash when no ticket is present 2025-08-09 07:16:45 +01:00
libpathconv manuals: Fix "missing end of block" errors 2024-10-07 15:40:58 -03:00
libpcap libpcap: Add changes missed in update to 1.10.5 2024-09-14 14:35:58 -03:00
libpe Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libpfctl pf: convert DIOCRDELADDRS to netlink 2025-08-06 00:27:14 +02:00
libpjdlog lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libpmc libpmc: add more alderlake models 2025-02-25 11:35:26 -04:00
libpmcstat libpmcstat: fix pmcstat -G on older-ish -CURRENT w/ drm-kmod 2025-04-20 23:00:01 -05:00
libproc Fix proc_signame() to use sig2str() 2025-06-11 17:16:22 -06:00
libprocstat libprocstat: Add handling for inotify descriptors 2025-07-04 14:42:34 +00:00
libradius radlib: fix a memory leak in is_valid_request 2024-06-04 19:40:55 -07:00
libregex libregex: fix our mapping for \w 2025-08-08 13:27:26 -05:00
librpcsec_gss gssapi,krb5: Replace libgssapi with the MIT version 2025-08-07 10:17:00 -07:00
librpcsvc Remove Secure RPC DES authentication 2025-08-10 16:36:40 +01:00
librss manuals: Misc syntax fixes 2024-10-08 16:13:39 -03:00
librt Update Makefile.depend files 2024-10-14 10:26:17 -07:00
librtld_db Remove "All Rights Reserved" from FreeBSD Foundation copyrights 2024-07-30 12:16:36 -04:00
libsamplerate libsamplerate: Build as internal library 2025-08-01 16:02:13 +03:00
libsbuf lib/libsbuf/tests: reformat with clang-format 2024-12-01 20:39:52 -08:00
libsdp Remove $FreeBSD$: one-line nroff pattern 2023-08-16 11:55:15 -06:00
libsecureboot Add DEBUG_PRINTF to stand.h 2025-07-17 16:36:17 -07:00
libsm Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libsmb Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libsmdb Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libsmutil Update Makefile.depend files 2024-10-14 10:26:17 -07:00
libsqlite3 Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libssp Update Makefile.depend files 2024-10-14 10:26:17 -07:00
libssp_nonshared Retire MK_PROFILE infrastructure 2024-11-12 12:11:51 -05:00
libstats Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libstdbuf Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libstdthreads Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libsys kern: fix setgroups(2) and getgroups(2) to match other platforms 2025-08-14 23:06:09 -05:00
libsysdecode libsysdecode: Add O_CLOFORK flags to sysdecode 2025-07-06 23:09:18 +00:00
libtacplus lib: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
libtelnet telnet: Add Support for MIT KRB5 build 2025-06-15 19:49:36 -07:00
libthr libthr: GC unused _sigsuspend() 2025-08-06 12:31:24 +01:00
libthread_db Remove "All Rights Reserved" from FreeBSD Foundation copyrights 2024-07-30 12:16:36 -04:00
libucl Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libufs add packages for libufs, libzfs 2025-05-05 16:39:25 +01:00
libugidfw Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libulog Retire MK_PROFILE infrastructure 2024-11-12 12:11:51 -05:00
libunbound unbound: Update version strings 2025-04-26 20:40:17 -07:00
libusb libusb: implement libusb_get_platform_descriptor 2025-08-06 10:05:40 -04:00
libusbhid libusbhid: add missing include guards 2024-06-06 10:09:05 -04:00
libutil libutil: Fix manlint failures 2025-08-12 14:55:01 +02:00
libutil++ libutil++: Move to the utilities package 2025-08-14 16:15:43 +00:00
libveriexec manuals: Fix "unusual .Xr" warnings with a script 2024-10-15 17:18:14 -03:00
libvgl lib/libvgl/main.c: remove an extra semicolon 2024-02-02 18:35:01 -07:00
libvmmapi libvmmapi: Add support for setting up and configuring guest NUMA domains 2025-07-27 18:31:48 +02:00
libwrap Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
libxo Update Makefile.depend files 2024-10-14 10:26:17 -07:00
liby Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libyaml libyaml: import libyaml vendor version 0.2.5 2025-06-26 09:02:31 +02:00
libypclnt Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
libz Update Makefile.depend files 2024-10-14 10:26:17 -07:00
libzstd Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
msun [libm] Avoid left shift of signed integer entities 2025-08-14 20:38:41 +02:00
ncurses ncurses: Provide reproducible paths 2025-07-14 14:45:57 +00:00
nss_tacplus nss_tacplus: Provide dummy setpwent(), getpwent_r(), endpwent(). 2023-08-31 07:49:57 +00:00
ofed src: Use gnu++17 as the default C++ standard 2025-04-11 09:53:50 -04:00
tests Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
Makefile gssapi,krb5: Replace libgssapi with the MIT version 2025-08-07 10:17:00 -07:00
Makefile.inc Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00