The FD_RESOLVE_BENEATH flag was intended to try to resolve bugzilla PR
262179 without entirely disallowing fd passing between jails. However,
one can use renameat() to bypass the restriction: upon receiving a
directory fd with FD_RESOLVE_BENEATH set, a jailed process can still
move its CWD or one of its ancestors to the directory, and just cd
out of its jail root.
So disallow renameat() when either the source or destination directory
fds has FD_RESOLVE_BENEATH set, like we do with fchdir() and fchroot()
to prevent similar escapes.
Approved by: so
Security: FreeBSD-SA-26:66.jail
Security: CVE-2026-101305
PR: 262179
Reported by: firk@cantconnect.ru
Reviewed by: olce, kib
Differential Revision: https://reviews.freebsd.org/D59875
Allow SO_REUSEPORT_LB to be set on divert sockets. If set, then bind()
will add the socket to a "load-balancing group". When a divert-to rule
matches a port with an associated group, the corresponding state ID is
used to select a specific socket from the group. Packets without an
associated state are simply forwarded to the first socket in the group.
For now I only pass a state ID from pf, as I couldn't see a useful
identifier on the ipfw side.
This implementation is simple but has a caveat, that being that if
sockets are added to the group while flows are being processed, the size
of the group will change and this changes the mapping of state IDs to
sockets. So, to get a consistent mapping, the divert socket application
must bind all of its sockets before any traffic is diverted by the
firewall.
Reviewed by: glebius
MFC after: 1 month
Sponsored by: OPNsense
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D56563
"filedescriptors" is the odd one out when looking at other manual pages.
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 4c6d8aa069f2ac22f801fa69add61085631b3356)
Since pdrfork will be included in FreeBSD 15.1
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D56513
(cherry picked from commit 9d39213d222395eb40323102db018cbedf773ddf)
pmap_pkru_update_range() did not handle the case where a PDPE has PG_PS
set. More generally, the SET_PKRU and CLEAR_PKRU sysarch
implementations did not check whether the request covers a "boundary" vm
map entry. Fix this, add the missing PG_PS test, and add some tests.
Approved by: so
Security: FreeBSD-SA-26:11.amd64
Security: CVE-2026-6386
Reported by: Nicholas Carlini <npc@anthropic.com>
Reviewed by: kib, alc
Differential Revision: https://reviews.freebsd.org/D56184
+ s/ntp/ntpd/ for correctness + apropos results in document description
+ silence a linter warning by escaping a period with a zero-width space
MFC after: 3 days
(cherry picked from commit b49b3ccd40bda02f530c679f23f42ba9e0e4b2e2)
The 'simplification' commit referenced below actually broke one aspect
of MFD_HUGETLB: the caller isn't supposed to be required to specify a
size. MFD_HUGETLB by itself without a shift mask just requests a large
page, so we revert that part of memfd_create() back.
While we're here, fix up the related parts of the manpages a little bit,
since MFD_HUGETLB is actually supported. The manpage claims that we
would return ENOSYS if forced mappings weren't supported, but this was
actually not true. However, that seems like a very important
distinction to make between ENOSYS and EOPNOTSUPP, so fix the
implementation to match the docs.
Reviewed by: kib, markj
(cherry picked from commit 9a8d333368baef356f0a611b47ec592568dd14f9)
This was a minor oversight from their introduction.
Commit message by kevans@.
Reviewed by: kevans
(cherry picked from commit 51c5e2b60247b3deb204a1d78ea6edc91a8ac652)
Remove 81 lines of whitespace at default manual rendering width.
MFC after: 3 days
(cherry picked from commit db9bbe131c92f55e6cf03657dc030c9eea93a9fb)
atexit(3) is one of the cases when _exit(2) must be used instead of
exit(3).
MFC after: 3 days
Reviewed by: mhorne, ziaee
Differential Revision: https://reviews.freebsd.org/D54467
(cherry picked from commit c082e5656417945bfa567114c60969844f3d7bdf)
The information is basically taken from kldload(8).
Reviewed by: kib, ziaee
Differential Revision: https://reviews.freebsd.org/D55170
(cherry picked from commit 1e2c9bcc4ed5fd2a27abdbcf5dfb007193251648)
libsys required ARM EABI unwind symbols like __aeabi_unwind_cpp_pr0.
These symbols are normally provided by libc, but if a binary does
not link libc, the symbol ends up not being resolved.
Among other problems, this prevented gcc14 and newer from building
on arm.
Add the relevant symbols as hidden symbols into libsys to avoid this
problem.
(this patch was posted by jrtc27 who has asked me to move it along)
PR: 292539
Tested by: fuz, Mark Millard <marklmi26-fbsd@yahoo.com>
Reviewed by: mmel
Approved by: markj (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D55255
(cherry picked from commit 6265f30cd6b523d633efcc314f8952f24446861f)
kqueue1() was meant.
While here, make the wording in the AUTHORS section more clear.
PR: 291908
Fixes: 9b1585384d ("kqueue.2: Editorial pass")
Reviewed by: kib, dab
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D54858
(cherry picked from commit 4efe75af0869dd71a26685c432e5284d71bf4dc8)
This enables additional searching the manual by sysctl variable.
This syntax is standardized in style.mdoc(5).
Reported by: bapt
MFC after: 3 days
(cherry picked from commit 75866d71e8d93fe1a1ff469b8a9c6c6c9908a6c8)
ioctls can fail with EACCES, see sys/kern/tty.c
PR: 239504
MFC after: 3 days
Reviewed by: ziaee
Reported by: Brennan Vincent <brennan@umanwizard.com>
Differential Revision: https://reviews.freebsd.org/D49072
(cherry picked from commit e2afbc45258f2fa4bdcf126e959ac660e76fc802)
Commit d6864221d8 added support for the _PC_CASE_INSENSITIVE
name for pathconf, to indicate if case insensitive lookups
are configured.
This patch documents this new name and also updates
the description for _PC_HAS_HIDDENSYSTEM to also
include UF_ARCHIVE.
This is a content change.
(cherry picked from commit b473bb274cef37d45940cad4624b5d3b7fc96e01)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53240
(cherry picked from commit 514fff24b19f69c5f22db380389128eb6bc32ea7)
Add 14.2, as this was cherry-picked prior to release.
Reported by: Harald Eilertsen
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53320
(cherry picked from commit 2387a51af235e4304c63f95465a569c878f49dcd)
Create a chapter on every important socket type: stream, datagram,
seqpacket. Always list what protocol families do support what kinds of
sockets. Improve some statements possessing language from the
specification [1]. Reduce some statements that are mostly specific to
TCP. Provide more external links and references to various important
syscalls that can be used on sockets.
Add a paragrph on non-blocking mode.
The big factual change is documentation of SOCK_SEQPACKET. In FreeBSD 15
this socket now fully follows the specification and is a stream socket
with record boundaries.
[1] https://pubs.opengroup.org/onlinepubs/9799919799/functions/V2_chap02.html#tag_16_10_06
Differential Revision: https://reviews.freebsd.org/D52771
(cherry picked from commit 86d17239233ea4f5766bee68ba6355804525cefa)
(cherry picked from commit ad13fd5a8fa1607805d11ced3428e86dbd94778e)
In the STANDARDS section, stop mentioning behavior that is not
prescribed by POSIX and make sure to specify which alternative we
implement (as POSIX allows to return or not the effective group ID).
Say more clearly that programs treating specially the first slot of the
returned array must be modified.
Consistently use "group ID" instead of "GID".
These changes are going to be MFCed into stable/14 as part of MFCing
commit 4be38acc826f ("getgroups.2: Clarify, mention ascending order, add
SECURITY CONSIDERATIONS"), so the current commit will be MFCed to
stable/15 only.
MFC after: 1 hour
MFC to: stable/15
Sponsored by: The FreeBSD Foundation
(cherry picked from commit c363dcbe75b2c7171611815daec82d263607ee37)
Clarify and be more precise about the behavior of getgroups(2), in
particular with respect to 'gidsetlen'.
Prefer a terminology referring to POSIX terms, i.e., use "supplementary
groups" instead of "group access list".
Say that getgroups(2) reports the supplementary groups in strictly
ascending order and returns the cardinal of the set they form (and
mention this has been the case since FreeBSD 14.3).
Add a new SECURITY CONSIDERATIONS section contrasting the new behavior
after commit 9da2fe96ff ("kern: fix setgroups(2) and getgroups(2) to
match other platforms") with the historical one.
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 be mentioned as
upcoming in 15.
Reviewed by: gbe (older version)
MFC after: 5 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D52286
(cherry picked from commit 4be38acc826f260e4c7d3ebbb9de534db449782e)
Reviewed by: gbe
Fixes: 9da2fe96ff ("kern: fix setgroups(2) and getgroups(2) to match other platforms")
MFC after: 5 days
MFC to: stable/15
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D52285
(cherry picked from commit 66b54c48b2ae1c1759134cad5daa6fc27b679918)
Add a new SECURITY CONSIDERATIONS section describing in details what the
new behavior is after commit 9da2fe96ff ("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 9da2fe96ff ("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: 9da2fe96ff ("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
(cherry picked from commit 6d22cd6b5f8b5604f1fe9e70930b1506f990e31e)
The manual page does not directly mention this reason for getting EPERM,
instead referring the reader to chroot(2). We have had some questions
about it recently, in part due to a bug (fixed), and this case is not an
obvious permission/problem, so let's be more explicit.
PR: 280809
Reviewed by: jamie
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D52319
(cherry picked from commit ef2f36be8fce8cf7a62ce7d33ab1c4a181fac3e2)
Give jail descriptors the same kevent flags as jails. Also fix the
event reporting in jails, where it was including data for events the
user didn't ask for.
(cherry picked from commit 66d8ffe3046ded1eb3f78599c6af8eb965482ef5)
Instead of using the EVFILT_PROC model of attempting to automatically
register new events when a child jail is created, just give a single
event when a child jail is created. As was already done with jail
attach events, make a best-effort report of the added jail's id in
kn_data. If the are multiple NOTE_JAIL_CHILD and/or NOTE_JAIL_ATTACH
events, set the NOTE_JAIL_MULTI flag, and don't report anything in
data, indicating that the caller will need to query the system state
on their own.
(cherry picked from commit dbcaac13e49c88d1c077f34f56dd2b7ba77a145a)