opnsense-src/sys/compat/linux
Kyle Evans be1f7435ef kern: start tracking cr_gid outside of cr_groups[]
This is the (mostly) kernel side of de-conflating cr_gid and the
supplemental groups.  The pre-existing behavior for getgroups() and
setgroups() is retained to keep the user <-> kernel boundary
functionally the same while we audit use of these syscalls, but we can
remove a lot of the internal special-casing just by reorganizing ucred
like this.

struct xucred has been altered because the cr_gid macro becomes
problematic if ucred has a real cr_gid member but xucred does not.  Most
notably, they both also have cr_groups[] members, so the definition
means that we could easily have situations where we end up using the
first supplemental group as the egid in some places.  We really can't
change the ABI of xucred, so instead we alias the first member to the
`cr_gid` name and maintain the status quo.

This also fixes the Linux setgroups(2)/getgroups(2) implementation to
more cleanly preserve the group set, now that we don't need to special
case cr_groups[0].

__FreeBSD_version bumped for the `struct ucred` ABI break.

For relnotes: downstreams and out-of-tree modules absolutely must fix
any references to cr_groups[0] in their code.  These are almost
exclusively incorrect in the new world, and cr_gid should be used
instead.  There is a cr_gid macro available in earlier FreeBSD versions
that can be used to avoid having version-dependant conditionals to refer
to the effective group id.  Surrounding code may need adjusted if it
peels off the first element of cr_groups and uses the others as the
supplemental groups, since the supplemental groups start at cr_groups[0]
now if &cr_groups[0] != &cr_gid.

Relnotes:	yes (see last paragraph)
Co-authored-by:	olce
Differential Revision:	https://reviews.freebsd.org/D51489
2025-07-30 23:44:11 -05:00
..
check_error.d sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
check_internal_locks.d sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux.c linux: use sa_family_t for address family conversions 2024-03-29 13:35:37 -07:00
linux.h linux.h: don't redefine lower_32_bits if already defined 2024-10-15 04:50:44 -06:00
linux_common.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_common.h linux: use sa_family_t for address family conversions 2024-03-29 13:35:37 -07:00
linux_dtrace.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux_dummy.c linux: Add inotify support 2025-07-04 14:42:34 +00:00
linux_elf.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_elf.h spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
linux_elf32.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_elf64.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_emul.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_emul.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux_errno.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_errno.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux_errno.inc sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux_event.c linux(4): Convert flags in timerfd_create 2023-09-05 11:53:02 +03:00
linux_event.h linux(4): Convert flags in timerfd_create 2023-09-05 11:53:02 +03:00
linux_file.c kern: allow kern_shm_open2 of an anonymous preconstructed shmfd 2025-07-26 16:31:40 -05:00
linux_file.h linux: Add inotify support 2025-07-04 14:42:34 +00:00
linux_fork.c cpu_set_upcall / linux_clone_thread: Remove calls to cpu_thread_clean 2025-01-03 11:03:08 -05:00
linux_fork.h linux(4): Update my copyrights, add SPDX tag 2023-08-17 23:54:36 +03:00
linux_futex.c umtx: Add a helper for unlocked umtxq_busy() calls 2025-02-24 21:34:51 +00:00
linux_futex.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux_getcwd.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_ioctl.c linux: support IUTF8 2024-10-21 08:22:50 +00:00
linux_ioctl.h linux: support IUTF8 2024-10-21 08:22:50 +00:00
linux_ipc.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_ipc.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux_ipc64.h linux(4): Fix semid64_ds structure layout 2023-10-04 21:21:12 +03:00
linux_mib.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_mib.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux_misc.c kern: start tracking cr_gid outside of cr_groups[] 2025-07-30 23:44:11 -05:00
linux_misc.h sys: Add AT_HWCAP3 and AT_HWCAP4 2025-06-24 17:26:40 +01:00
linux_mmap.c Reduce reliance on sys/sysproto.h pollution 2024-04-15 21:35:40 +01:00
linux_mmap.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux_netlink.c linux: allow RTM_GETADDR without full ifaddrmsg argument 2024-05-28 13:13:08 -07:00
linux_persona.h linux(4): Fix leftovers after 2ff63af9 2023-08-17 23:54:00 +03:00
linux_ptrace.c linux: Fix usage of ptrace(PT_GET_SC_ARGS) 2025-06-13 19:19:59 +00:00
linux_rseq.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_siginfo.h sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
linux_signal.c linux(4): On Linux SIGKILL can not be reset to default 2023-09-18 17:53:01 +03:00
linux_signal.h linux(4): Staticize lsiginfo_to_siginfo 2023-09-18 17:52:43 +03:00
linux_socket.c linux: Handle IP_RECVTOS cmsg type 2025-03-10 11:12:36 -07:00
linux_socket.h linux(4): Drop bogus __arm__ condition due to lack of 32-bit arm support 2023-08-17 22:57:17 +03:00
linux_stats.c linuxulator: ignore AT_NO_AUTOMOUNT for all stat variants 2024-09-24 13:58:42 -04:00
linux_sysctl.c linux(4): Add const qualifier to the value parameter of function handle_string() 2024-05-20 12:02:33 +08:00
linux_time.c Redefine CLOCK_BOOTTIME to alias CLOCK_MONOTONIC, not CLOCK_UPTIME 2024-05-31 08:45:02 -06:00
linux_time.h linux: Export linux_convert_l_sigevent 2024-05-23 13:40:46 -06:00
linux_timer.c linux: Export linux_convert_l_sigevent 2024-05-23 13:40:46 -06:00
linux_uid16.c kern: start tracking cr_gid outside of cr_groups[] 2025-07-30 23:44:11 -05:00
linux_util.c machine/stdarg.h -> sys/stdarg.h 2025-06-11 17:39:02 +01:00
linux_util.h Reduce reliance on sys/sysproto.h pollution 2024-04-15 21:35:40 +01:00
linux_vdso.c linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743 2023-08-18 13:12:02 +03:00
linux_vdso.h linux(4): Remove include of sys/types.h from linux_vdso.h 2023-08-18 15:58:32 +03:00
linux_vdso_gtod.inc linux(4): Fix linker warning about undefined vdso symbols 2023-08-20 00:48:36 +03:00
linux_vdso_inc.S linux: Allows writing to the vdso from the kernel 2024-06-06 09:07:49 +00:00
linux_videodev2_compat.h linux(4): Fix leftovers after 2ff63af9 2023-08-17 23:54:00 +03:00
linux_videodev_compat.h linux(4): Fix leftovers after 2ff63af9 2023-08-17 23:54:00 +03:00
linux_xattr.c linux(4): Fix typo xatrr in function name 2024-11-29 14:38:35 -07:00
stats_timing.d sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
trace_futexes.d sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00