reboot: Fix halt -p behavior
The RB_HALT bit is always set when invoked as `halt`, so to maintain a
distinction between `halt` and `halt -p`, we must check the RB_POWEROFF
bit first.
PR: 291814
Fixes: 4453ec5b8716 ("reboot: Default to a clean shutdown")
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D54320
files.amd64: remove some lines duplicated from files.x86
These were added to files.x86 because they were duplicated in both
files.i386 and files.amd64, but they did not end up removed in the
latter. Garbage collect them now.
Reviewed by: jhibbits
Fixes: b9c6fa339d9c7 ("files.x86: Pull in some more duplicate [...]")
Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D54295
LinuxKPI: bitcount fix builds with gcc and older llvm
LLVM before 19 and gcc before 14 do not support __builtin_popcountg().
Use __const_bitcount<n> from sys/bitcount.h as a replacement in these
cases. This should still allow drm-kmod to build where the size needs
to be known at compile-time.
Remove the conditional for gcc around the iwlwifi modules build,
which was collateral damage in all this.
Sponsored by: The FreeBSD Foundation
Fixes: 7cbc4d875971, 5e0a4859f28a
MFC after: 3 days
Reviewed by: brooks, emaste (without the sys/modules/Makefile change)
Differential Revision: https://reviews.freebsd.org/D54297
sys/bitcount.h: add __const_bitcount<n>
Add a version of __const_bitcount<n> which can be used to get the
numbers at compile-time when __builtin_popcountg() is not available
(see sys/compat/linuxkpi/common/include/linux/bitops.h for LLVM before
19 and gcc before 14).
Obtained from: https://reviews.freebsd.org/D50995#1174884 by obiwac
Sponsored by: The FreeBSD Foundation
Reviewed by: brooks, emaste
Differential Revision: https://reviews.freebsd.org/D54301
Revert "sys: Bump 32-bit kernel removal to 16.0"
32-bit powerpc and i386 kernels still exist in 14.x, so we don't want to
imply that those may persist until 16.0. The message only claims that
the kernels "may be" removed in 15.0 anyhow.
This reverts commit c19688407a2c797e74762aebd90c1f1cc70ab726.
Reported by: jhb
proc: Fix proc_init / proc_dtor ordering issues
* Move the initialization of p_ktr into proc_init() and make the check
in proc_dtor() unconditional. Prior to this, it was possible to fail
and invoke proc_dtor() after the first thread had been created (which
was the condition for checking p_ktr in proc_dtor()) but before p_ktr
had been initialized.
* Move the p_klist initialization in fork1() past the last possible
failure point so we don't have to free it on failure. We didn't,
which meant we were leaking a knlist every time we failed to fork
due to hitting the resource limit.
PR: 291470
MFC after: 1 week
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D54215
(cherry picked from commit 026d962ef14dafe19fa73361bea6dcc95f141dfa)
ipfilter: Prevent stack buffer overflow
When copying ipfs data from user space, don't just check that the payload
length is nonzero, but also that it does not exceed the size of the stack
buffer we're copying it into.
While we're at it, use a union to create a buffer of the exact size we
need instead of guessing that 2048 will be enough (and not too much).
Finally, check the size of the payload once it gets to where it's used.
MFC after: 3 days
Reported by: Ilja Van Sprundel <ivansprundel at ioactive.com>
Reviewed by: cy
Differential Revision: https://reviews.freebsd.org/D54194
(cherry picked from commit a34c50fbd2a52bb63acde82e5aec4cb57880e39b)
vfs: Let prison_enforce_statfs zero the fsid
Currently, we unconditionally zero the fsid before returning a struct
statfs to a jailed process. Move this into prison_enforce_statfs() so
it only happens if enforce_statfs is greater than 1, or enforce_statfs
is 1 but the mountpoint is outside the jail.
PR: 291301
MFC after: 1 week
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D54214
(cherry picked from commit d4f25d0c7957f0f1960028eec82625c2d6405537)
ipfilter: Prevent stack buffer overflow
When copying ipfs data from user space, don't just check that the payload
length is nonzero, but also that it does not exceed the size of the stack
buffer we're copying it into.
While we're at it, use a union to create a buffer of the exact size we
need instead of guessing that 2048 will be enough (and not too much).
Finally, check the size of the payload once it gets to where it's used.
MFC after: 3 days
Reported by: Ilja Van Sprundel <ivansprundel at ioactive.com>
Reviewed by: cy
Differential Revision: https://reviews.freebsd.org/D54194
(cherry picked from commit a34c50fbd2a52bb63acde82e5aec4cb57880e39b)
vfs: Let prison_enforce_statfs zero the fsid
Currently, we unconditionally zero the fsid before returning a struct
statfs to a jailed process. Move this into prison_enforce_statfs() so
it only happens if enforce_statfs is greater than 1, or enforce_statfs
is 1 but the mountpoint is outside the jail.
PR: 291301
MFC after: 1 week
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D54214
(cherry picked from commit d4f25d0c7957f0f1960028eec82625c2d6405537)