Commit graph

261 commits

Author SHA1 Message Date
Mark Johnston
93d226e6e4 vfs: Disallow renameat() with FD_RESOLVE_BENEATH descriptors
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
2026-09-30 11:46:48 +02:00
Mark Johnston
6bd9bc16d0 divert: Define semantics for SO_REUSEPORT_LB on divert sockets
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
2026-06-25 11:18:46 +02:00
Olivier Certner
8ab08ea5fe
chroot.2: "filedescriptors" => "file descriptors"
"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)
2026-04-30 19:58:46 +02:00
Alan Somers
fac95c74d2 pdfork.2: correct pdrfork's HISTORY section
Since pdrfork will be included in FreeBSD 15.1

Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D56513

(cherry picked from commit 9d39213d222395eb40323102db018cbedf773ddf)
2026-04-27 13:37:22 -06:00
Konstantin Belousov
b024a8d082 membarrier.2: document MEMBARRIER_CMD_GET_REGISTRATIONS
(cherry picked from commit 324b3c2892a53e5fd9b1d8795a31a59ee835c5de)
2026-04-27 04:28:59 +03:00
Mark Johnston
9331e62e8b pkru: Fix handling of 1GB largepage mappings
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
2026-04-21 15:42:41 +00:00
Alexander Ziaee
c348c928a2
ntp_adjtime.2: Increase visibility
+ 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)
2026-04-20 12:18:41 -04:00
Konstantin Belousov
ee3ef70c40 fork.2: note that all methods to pre-resolve symbols have consequences
(cherry picked from commit 660498986a8e56025d9d2f9c6a0813c09a27ba8e)
2026-04-17 03:42:38 +03:00
Kit Dallege
0a5c45744e mq_open(2): document sysctl limit EINVAL and ENFILE conditions
Document two missing error conditions for mq_open(2):

- EINVAL: returned when mq_maxmsg exceeds kern.mqueue.maxmsg or
  mq_msgsize exceeds kern.mqueue.maxmsgsize.
- ENFILE: add kern.mqueue.maxmq sysctl name to the existing entry.

PR:		243209
Reviewed by:	mhorne
MFC after:	1 week
Signed-off-by:	Kit Dallege <xaum.io@gmail.com>
Pull Request:	https://github.com/freebsd/freebsd-src/pull/2098

(cherry picked from commit 3e9f4fd6fc50300d052d5619d82a14d3488483d5)
2026-04-16 12:25:07 -03:00
Kyle Evans
ac6173b54f libc: fix memfd_create's HUGETLB handling
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)
2026-04-12 22:12:44 -05:00
Christian S.J. Peron
1cf7c6cd51 libsys: install manpage links for jail_attach_jd/jail_remove_jd
This was a minor oversight from their introduction.

Commit message by kevans@.

Reviewed by:	kevans

(cherry picked from commit 51c5e2b60247b3deb204a1d78ea6edc91a8ac652)
2026-04-11 22:15:08 -05:00
Alexander Ziaee
820887188e
procctl.2: Align list indentation
Remove 81 lines of whitespace at default manual rendering width.

MFC after: 3 days

(cherry picked from commit db9bbe131c92f55e6cf03657dc030c9eea93a9fb)
2026-04-10 14:30:26 -04:00
Artem Bunichev
20bbad13f2
_exit.2: Cross-reference atexit(3)
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)
2026-04-10 14:30:21 -04:00
Artem Bunichev
2ba48ee1ec
kldload.2: Provide more info about file argument
The information is basically taken from kldload(8).

Reviewed by:		kib, ziaee
Differential Revision:	https://reviews.freebsd.org/D55170

(cherry picked from commit 1e2c9bcc4ed5fd2a27abdbcf5dfb007193251648)
2026-04-10 14:29:36 -04:00
Konstantin Belousov
360ff2ca47 dup(2): document the handling of filedescriptor flags
(cherry picked from commit 6cc99baea607255859ee958608e4db6e2ff24793)
2026-03-31 07:07:17 +03:00
Konstantin Belousov
756689232e sigreturn.2: refresh the man page
(cherry picked from commit 9da4a804f0916b24519b8baa7ed460a7ba23d8c8)
2026-03-14 14:02:34 +02:00
Konstantin Belousov
b5e307d41e Regen 2026-03-10 13:41:32 +02:00
Konstantin Belousov
3ccc39d38e renameat2(2): document
(cherry picked from commit 619e49b2ba58e1ffd2ab111fef6d1e87d77e7391)
2026-03-10 13:41:32 +02:00
Konstantin Belousov
1bb58ba12b libsys/rename.2: remove commented-out CAVEAT section
(cherry picked from commit 5f911eaba017645487a1eaee3609b26a77f0f174)
2026-03-10 13:41:32 +02:00
Konstantin Belousov
522dbeb9f2 sys: add renameat2(2) syscall
(cherry picked from commit 28599a1e5f1b90676a818e0a4818cddd0839ad25)
2026-03-10 13:41:31 +02:00
Konstantin Belousov
afe686823a pdfork.2: add EFAULT as possible error, explain some consequences of it
(cherry picked from commit db80ea9b88628168d2bb7f17a60b73568a8ea102)
2026-02-21 11:48:58 +02:00
Konstantin Belousov
fea8849bac pdrfork(2): do require RFPROCDESC | RFPROC
(cherry picked from commit b05be03ceea0a95f7783ddc890885f34bb4023d4)
2026-02-21 11:48:58 +02:00
Jessica Clarke
f16349f12d libsys/arm: include ARM EABI unwind bits into libsys
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)
2026-02-20 17:44:55 +01:00
Konstantin Belousov
48aeff4df8 open.2: grammar improvements
(cherry picked from commit f1f142c01db43c7dc8d0d172fc1726da2ee01972)
2026-02-18 10:00:50 +02:00
Konstantin Belousov
4338c43791 open.2: stop making impression that fd must be directory
(cherry picked from commit 5bcccc702b29a0e173a5916b001771dd7b280c7c)
2026-02-18 10:00:04 +02:00
Artem Bunichev
389762add0 kqueue.2: Fix reference to unexisting kevent1()
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)
2026-02-09 18:03:41 +00:00
Alexander Ziaee
9229de71e4
manuals: Correct some sysctl markup
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)
2026-02-05 16:49:53 -05:00
Konstantin Belousov
124f70e36e libsys, libc: provide rfork_thread() and pdrfork_thread() on all arches
(cherry picked from commit c1be185e3fb9afd6743683a8f5a43b9c364ab529)
2026-02-01 23:38:50 +02:00
Konstantin Belousov
c5fc8e4fdb libsys: add pdrfork_thread() on x86
(cherry picked from commit 74a2bf1b7a7ff0c872499cb94df24713f61c872c)
2026-02-01 23:38:50 +02:00
Konstantin Belousov
892a09e123 Regen sysents for addition of pdrfork and pdwait 2026-02-01 23:38:49 +02:00
Konstantin Belousov
780b7f9e0e Document pdrfork(2) and pdwait(2)
(cherry picked from commit f7b56887cc0725fbe15730dbe062a092d0955058)
2026-02-01 23:38:49 +02:00
Konstantin Belousov
6820fe965f lib/libsys, lib/libc: export pdwait
(cherry picked from commit 2d555ec85a716e016be587b2a1606ca69267f870)
2026-02-01 23:38:49 +02:00
Konstantin Belousov
f48772e6da lib/libsys, lib/libc: export pdrfork(2)
(cherry picked from commit f10b4b6131d444c023a90c386cec4b0b8f525a1f)
2026-02-01 23:38:48 +02:00
Felix Johnson
bd6289c064
ioctl.2: Mention EACCES
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)
2026-01-01 13:05:06 -05:00
Seth Hoffert
da13642913
man typos: Fix pf.conf.5 and jail.2 typos
MFC after:	3 days
Signed-off-by:	Seth Hoffert <seth.hoffert@gmail.com>
Closes:		https://github.com/freebsd/freebsd-src/pull/1919

(cherry picked from commit 0140dc4a68ac25c70300ed2a418e7ca441638bdb)
2026-01-01 13:05:03 -05:00
Rick Macklem
52159dd73f pathconf.2: Document the new _PC_CASE_INSENSITIVE name
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)
2025-11-23 12:24:10 -08:00
Mateusz Piotrowski
d01eb8e98f revoke.2: Remove mention of block special device files
Block devices are a thing of a past in FreeBSD.

Reviewed by:	ziaee
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D53332
2025-11-03 13:46:28 +01:00
Konstantin Belousov
3aae49be3d kqueue.2: document KQUEUE_CPONFORK
(cherry picked from commit a4981ededef3c2d867ddd991905e4b65bc917a62)
2025-11-01 02:43:14 +02:00
Konstantin Belousov
514c8f173c write.2: explain the atomicity guarantees of the writes
(cherry picked from commit 1c8d7bb4cf7a6b19262333b2a9b1dacf3094b938)
2025-10-31 16:41:03 +02:00
Ed Maste
243a886019 closefrom.2: Add introduction of close_range to HISTORY
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53240

(cherry picked from commit 514fff24b19f69c5f22db380389128eb6bc32ea7)
2025-10-29 09:42:39 -04:00
Ed Maste
87795ea454 getrlimitusage.2: Update HISTORY section
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)
2025-10-27 10:34:42 -04:00
Gleb Smirnoff
a091d6919c socket(2): refactor the manual page
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)
2025-10-15 11:58:54 -07:00
Olivier Certner
59f602e2f2
getgroups.2: Simplifications; Be clearer on programs to be modified
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)
2025-10-10 19:03:16 +02:00
Konstantin Belousov
799fae57ca libsys: drop private exports no longer needed
(cherry picked from commit 495813bfd7a28759b23204d66826ff9b3ee7ab61)
2025-10-01 06:00:08 +03:00
Olivier Certner
2932e6f59b
getgroups.2: Clarify, mention ascending order, add SECURITY CONSIDERATIONS
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)
2025-09-23 14:02:48 +02:00
Olivier Certner
af6ac32284
setcred.2: Remove now obsolete mention of setgroups(2)'s different behavior
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)
2025-09-23 14:02:47 +02:00
Olivier Certner
7132fb5edb
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 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)
2025-09-23 14:02:47 +02:00
Olivier Certner
7140f620a5
jail.2: Mention EPERM is returned on open directories
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)
2025-09-18 10:50:31 +02:00
Jamie Gritton
9d7f89ef26 jaildesc: add kevent support
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)
2025-09-14 20:33:48 -07:00
Jamie Gritton
1a849ff1e9 jail: simplify EVFILT_JAIL events
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)
2025-09-14 20:33:18 -07:00