26430 Commits
Author SHA1 Message Date
Konstantin Belousov 4ab9e73994 libthr/thr_mutex.c: make mutex asserts more useful
Print the file and line number of the caller where the assert fired.
Use _thread_exitf() directly for this.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2026-10-28 02:56:06 +02:00
Martin Matuska 61c70dc16a libarchive: merge from vendor branch
libarchive 3.8.10

ChangeLog:
https://github.com/libarchive/libarchive/compare/v3.8.9...v3.8.10

Obtained from:	libarchive
Vendor commit:	0c48412be2d94afe1859a807ea7896a18d8900bd
MFC after:	3 days
2026-10-26 22:47:32 +01:00
Ed Maste 7ea9ac99e1 libc: Add a man page caveat about the w modifier
In-tree Clang is unaware of the N2680 fixed-width modifier `w` and emits
a warning when used.

PR:		299631
Reviewed by:	imp
Differential Revision: https://reviews.freebsd.org/D60939
2026-10-26 09:46:02 -04:00
Wolfram Schneider f5b6c8f5c2 manpages: Fix unusual Xr order 2026-10-26 10:35:42 +00:00
Wolfram Schneider 3208a17f96 manpages: Fix unusual Xr order 2026-10-26 10:32:42 +00:00
Wolfram Schneider afe20e82f9 manpages: Fix unusual Xr order 2026-10-26 10:29:10 +00:00
Wolfram Schneider 4560b19ff4 manpages: Fix unusual Xr order 2026-10-26 10:27:43 +00:00
Konstantin Belousov cf63e3f3cd pdfork.2: improve markup
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2026-10-23 21:17:45 +03:00
Dag-Erling Smørgrav c6d7a2478c unbound: Update to 1.26.2
Release notes at
    https://community.nlnetlabs.nl/t/unbound-1-26-2-released

Merge commit 'ce3304d97ba4861eabac759e538426a568aef0a5'

Security:	CVE-2026-35501
Security:	CVE-2026-50106
Security:	CVE-2026-96405
Security:	CVE-2026-97206
Security:	CVE-2026-109125
2026-10-21 13:24:44 +00:00
Osvaldo Janeri Filho 06abe08de4 pam_exec: fix the stderr close test and avoid a double close
The cleanup tested cherr[0] when closing cherr[1].  The parent also closed
chin[0]/chout[1]/cherr[1] after pdfork() without clearing them, so the out:
cleanup path closed them again.  Clear each fd after closing and test the right
one.

Reviewed by:	des, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D60924
2026-10-20 22:05:31 +00:00
R. Christian McDonald a317317519 pf: Keep every chunk of a table that a ruleset defines
libpfctl sends a table definition in chunks of 256 addresses, each as
its own PFNL_CMD_INA_DEFINE.  The kernel treated every chunk as a new
definition and replaced the shadow table, so only the last chunk
survived.

Mark the chunks after the first with PF_ID_APPEND and have the kernel
add them to the shadow table in progress.  A request without the
attribute still replaces the shadow; one with it and no definition in
progress fails with EINVAL.  Old kernels ignore the attribute, so both
halves are needed; the ioctl sends all addresses at once and is not
affected.  Mask the flags userland passes to PFR_FLAG_ALLMASK, as
PFR_FLAG_APPEND is kernel-internal.

Add a test that defines a table of 1,000 addresses, also in an anchor.

Reviewed by:		kp
Fixes:			219ce30638 ("pf: convert DIOCRINADEFINE to netlink")
Sponsored by:		Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D60876
2026-10-20 08:52:00 -04:00
Alexander Ziaee daca1e12bb pmc.perf.3: Mark only for amd64 architecture
Manual pages have an optional architecture specifier after the section
number in the document title macro. I highly recommend using it when
expedient, the extra information is available programmatically and it
uses no extra lines in the rendered page.

MFC after:		No, pmc.perf.3 is not MFCing
Reviewed by:		Anderson Nascimento <[email protected]>
Differential Revision:	https://reviews.freebsd.org/D60714
2026-10-19 16:02:04 -04:00
ShengYi Hung 894f70a2bd libthr: drop use of try_gc in the end of thr_join
thr_try_gc unlock and lock again to make sure the lock order. However,
there is no reason for such roundtrip if the caller holds the correct
oder. As a result, we create a new helper function to add the thread
to gc list without unlock + lock and wire the join_common to this new helper.

Reviewed by:    kib
MFC after:      2 weeks
Differential Revision: https://reviews.freebsd.org/D60717
2026-10-19 16:23:14 +11:00
Enji Cooper 3593be37a4 sbuf(3): clean up tests
- Update the copyright dates and add "Joao Bonifacio" to the top of
  `sbuf_core_test.c`.
- Use `SPDX-Identifier` instead of longform copyright tort.
- Remove `sbuf_test_common.h`: the header was originally added to help
  with the 10.x/11.x split, but is no longer needed given that those
  releases have been EOLed for multiple years now.

MFC after:	1 week
2026-10-18 11:24:20 -07:00
Joao Bonifacio 642b3d965e sbuf(3): increase test coverage
This change adds additional explicit test coverage for the following
sbuf(3) APIs:
- sbuf_clear_flags
- sbuf_get_flags
- sbuf_set_flags

While here, add a missing `sbuf_delete` to `sbuf_drain_ret0_test`: while
it isn't strictly required (the library's state is cleaned up shortly
after the test process ends), tools such as Coverity and LSAN flag
issues with leaked memory. Adding the sbuf_delete(3) call to the test
quells that issue.

MFC after:	1 week
Reviewed-by:	ngie
Pull-Request:	https://github.com/freebsd/freebsd-src/pull/2367
2026-10-18 11:10:33 -07:00
Enji Cooper 23ab9a9d09 Revert "sbuf(3): increase test coverage"
ghpr doesn't seem to do a `git status` prior to allowing someone to push
changes (bug pending). Revert the change so the properly tested one can
be pushed into the tree.

This reverts commit 760efcc775.
2026-10-18 11:09:37 -07:00
Joao Bonifacio 760efcc775 sbuf(3): increase test coverage
This change adds additional explicit test coverage for the following
sbuf(3) APIs:
- sbuf_clear_flags
- sbuf_get_flags
- sbuf_set_flags

While here, add a missing `sbuf_delete` to `sbuf_drain_ret0_test`: while
it isn't strictly required (the library's state is cleaned up shortly
after the test process ends), tools such as Coverity and LSAN flag
issues with leaked memory. Adding the sbuf_delete(3) call to the test
quells that issue.

MFC after:	1 week
Reviewed-by:	ngie
Pull-Request:	https://github.com/freebsd/freebsd-src/pull/2367
2026-10-18 10:53:25 -07:00
ShengYi Hung a0e1529736 libthr: Remove deadcode in join_common
The while loop previous can only be break when ret == ETIMEDOUT. They
never produce EBUSY. Remove the deadcode here.

Reviewed by:    kib
MFC after:      2 weeks
Differential Revision: https://reviews.freebsd.org/D60711
2026-10-18 13:06:59 +11:00
Konstantin Belousov bdcfeac3e1 sysarch.x86.2: manual page for the sysarch(2) functions on x86
Reviewed by:	ziaee
Discussed with:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D60047
2026-10-17 02:15:34 +03:00
ShengYi Hung 5fb07bbcd5 libthr: Fix LIBPTHREAD_QUEUE_FIFO range
LIBPTHREAD_QUEUE_FIFO is used in bitwise offset, we set the limit to
0~31 so that it won't cause undefined behavior. Also, create a new
helper function to do getenv++strtol directly and check the boundary of
the valid value.

Reviewed by:    kib
MFC after:      2 weeks
Differential Revision: https://reviews.freebsd.org/D60487
2026-10-14 06:27:46 +11:00
Ryan Moeller a3c57739ca lib/libifconfig: Fix pointer-sign warnings
Fix all pointer-sign warnings generated when compiling libifconfig.

A couple more snuck in while the previous batch of fixes was landing.

Fixes:		963f1a5455 ("ifconfig: add CMIS support for 400GbE optics")
Reviewed by:	kevans
Approved by:	kevans (mentor)
Differential Revision:	https://reviews.freebsd.org/D60573
2026-10-13 12:41:52 -04:00
R. Christian McDonald 9664345efb libpfctl: Return max_win and mss of state peers
The kernel sends PF_STP_MAX_WIN and PF_STP_MSS for both peers of a
state, but struct pfctl_state_peer has no fields for them and libpfctl
dropped them.  Add the fields and parse the attributes.

Reviewed by:		kp
Sponsored by:		Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D60544
2026-10-13 10:49:47 -04:00
Anderson Nascimento 2272fac218 hwpmc: Add support for AMD-only IRPERF in hwpmc PERF class
The IRPERF MSR counter (0xc00000e9) exposes an instructions-retired count
when read. Its support is advertised through CPUID leaf 0x80000008 EBX bit 1.
If this bit is set, the CPU supports the IRPERF MSR. For it to be used
by the system, bit 30 of the HWCR MSR (0xC0010015) needs to be enabled.

This patch checks for availability of the feature and enables the bit. If
the feature is available, the hwpmc PERF class detects its presence and
registers a third PERF MSR counter that allows hwpmc users to measure
instructions retired using IRPERF. This is AMD-only, as Intel does not
support IRPERF.

Due to erratum #1054 affecting AMD Zen 1 before model 30h, IRPERF is only
enabled for AMD Zen 1 model 30h onwards and later microarchitectures. This
commit also implements a validation step to make sure the IRPERF counter
is actually incrementing; otherwise, the feature is not enabled. This
guarantees it is working as expected before being made available to the
system and users.

To support this, the perf_pmcdesc[] structure changed from being
statically initialized with 2 entries (MPERF/APERF) to being populated
dynamically. If both MPERF/APERF and IRPERF are supported, the structure
will contain three entries: MPERF, APERF, and IRPERF. Each entry now also
carries its own MSR address and PMC event, so perf_read_pmc() reads the
MSR to use from the matching perf_pmcdesc[] entry at runtime instead of
switching over a fixed set of row indices.

Definitions for the features available on the HWCR MSR did not previously
exist. This commit adds macros for those features, including
HWCR_IRPERFEN. The MSR definition for MSR_IRPERF was also missing and has
now been added.

This commit also updates the manual page accordingly.

Signed-off-by:	Anderson Nascimento <[email protected]>
Reviewed by:	mhorne, adrian
Sponsored by:	AMD
Differential Revision:	https://reviews.freebsd.org/D59554
2026-10-13 10:21:45 -03:00
R. Christian McDonald 5fc8fe3df5 libpfctl: Fix the counts returned by pfctl_ina_define()
The counts of a table definition were stored only if the caller's
variables already held a non-zero value, and read uninitialised ones
otherwise.  pfctl_ina_define() passes the address of two uninitialised
locals and sums them up.

Reviewed by:		kp
Fixes:			219ce30638 ("pf: convert DIOCRINADEFINE to netlink")
Sponsored by:		Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D60614
2026-10-11 10:47:10 -04:00
Xiaoqiang Zhao 8a7df6c58d tests/libc: only build brk_test where libc provides sbrk
Replace the exclusion list with an allowlist of the architectures
whose libc exports brk/sbrk: amd64, i386, arm and powerpc.

On aarch64, riscv and loongarch libc does not export those symbols
and the test cannot run, so do not build it there. New architectures
now default to not building the test unless brk support is added.

MFC after:	1 week
Signed-off-by:	Xiaoqiang Zhao <[email protected]>
Reviewed by:	ngie
Differential Revision:	https://reviews.freebsd.org/D60357
2026-10-10 10:45:28 -07:00
Gleb Popov c3ac06161d nmount: Introduce the "check_fsid" option
See the manpage addition for rationale

Reviewed by:	ziaee, kib
Approved by:	ziaee, kib
Differential Revision:	https://reviews.freebsd.org/D59930
2026-10-10 17:42:08 +03:00
ShengYi Hung 305c3044e0 libthr: Support disable spinloop
Like yieldloops, we shoulde be able to set _thr_spinloops to zero.
Originally, it makes us to enformce default spin time even if we try to
disable it. Make MUTEX_ADAPTIVE_SPINS a one time initialization now.

Reviewed by:    kib
MFC after:      2 weeks
Differential Revision: https://reviews.freebsd.org/D60486
2026-10-10 09:13:31 +11:00
Aymeric Wibo d39b1d6932 ulimit(3): Improve UL_{GET,SET}FSIZE wording
Reword the UL_GETFSIZE and UL_SETFSIZE descriptions to say 512-byte
blocks and make the setter's argument clearer.

While here, improve mdoc markup and pull in other small improvements.

Reviewed by:	des
MFC after:	3 days
Obtained from:	https://github.com/apple-oss-distributions/libc
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D60467
2026-10-09 12:07:35 +01:00
John Baldwin 23be969c12 libsysdecode: Fix some cpp conditionals
While testing the bare values happens to work, the intent is to test
for their definition.

Reviewed by:	emaste
Fixes:		9a16bd169e ("libsysdecode: support errno and syscalls for arm64 Linux")
Fixes:		b69ae1a34c ("libsysdecode: Add preliminary support for decoding Linux syscalls")
Differential Revision:	https://reviews.freebsd.org/D60415
2026-10-08 11:21:06 -04:00
Osvaldo Janeri Filho ca9c571801 libpmc: fix the family check for the AMD DF event encoding
The check compares cpu_family with decimal 19 instead of 0x19, so
Families 17h and 19h get the Family 1Ah DF encoding.

Signed-off-by:	Osvaldo Janeri Filho <[email protected]>
Reviewed by:	mhorne
Fixes:		00c0a1f0bf ("hwpmc: Fix PMC flags for AMD Zen cores")
MFC after:	3 days
Sponsored by:	AMD
Pull Request:	https://github.com/freebsd/freebsd-src/pull/2461
2026-10-08 11:57:35 -03:00
ShengYi Hung de2c0f157a libthr: Fix some bugs in trylock
1. When contester > 2, a release causes kernel set CONTENTION bit but
   with no owner. In this case, the userspace should be able to try the
   lock instead of fall immediately. We copy this from trylock2.
2. A PI mutex should consult to kernel instead of decided by userspace
   itself.

Reviewed by:    kib
MFC after:      2 weeks
Differential Revision: https://reviews.freebsd.org/D60427
2026-10-08 04:14:04 +11:00
ShengYi Hung 99edcc3bd5 libthr: Reorder pthread mutex to prevent false sharing
On a 64 byte cache line CPU (amd64), m_owner is contended by all of
the shared processes. However, after finding one winner, mtx is
enqueued, which trigger a cache refresh from other processors. Reorder
mtx so that m_lock and m_qu will not be in the same cache line.

Notice that this doesn't affet arch that expose 128 bytes cache line
line aarch64 or powerpc.

Reviewed by:    kib, markj
MFC after:      2 weeks
Differential Revision: https://reviews.freebsd.org/D60434
2026-10-08 04:05:58 +11:00
ShengYi Hung 627e7d5b72 libthr: reject count < 0
This causes count == -1 spin for INT_MAX times in userspace.

Reviewed by:    kib
MFC after:      2 weeks
Differential Revision: https://reviews.freebsd.org/D60425
2026-10-08 03:59:19 +11:00
ShengYi Hung 1d21e67e72 libthr: Do not rely on UB in counter
counter + 1 > 0 is a undefined behavior and nobody guarantee that it
will be honestly perform by the compiler that counter + 1 will always be
INT_MIN. We switch to INT_MAX check instead to provide a deterministic
result.

Reviewed by:    kib
MFC after:      2 weeks
Differential Revision: https://reviews.freebsd.org/D60426
2026-10-08 03:59:10 +11:00
Mark Johnston fa6fe034a7 inotify.2: Add some entries to the BUGS section
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2026-10-07 14:55:57 +00:00
ShengYi Hung 192781bf5d libthr: Consume error in check_and_init_mutex
MFC after:      2 weeks
2026-10-07 12:26:11 +11:00
Philip Paeps 657c089950 lib80211: fix build with eXpat 2.9.0
eXpat 2.9.0 deprecates XML_GetCurrentLineNumber() in favour of
XML_GetCurrentLineNumber64().  The new function behaves the same
as the old one but is not prone to 32 bit integer wrap-around.
2026-10-07 09:15:49 +08:00
Philip Paeps 22c3edb312 contrib/expat: import expat 2.9.0
Changes: https://github.com/libexpat/libexpat/blob/R_2_9_0/expat/Changes

Security:	CVE-2026-102633
Security:	CVE-2026-77214
MFC after:	3 days
2026-10-07 09:15:49 +08:00
Xin LI b4e2c9abaf libcasper: tolerate kernels without PD_NOWAITPID
Commit 1a296762b3 made libcasper pass PD_NOWAITPID to pdfork(2).
Kernels predating the flag (15.1 and earlier, since the flag first
ships in 15.2) reject it with EINVAL, which makes cap_init() and every
service fork fail when a newer world runs on an older kernel, for
example in a poudriere jail.

Add casper_pdfork(), which retries without the flag on EINVAL, and use
it at both pdfork(2) call sites.  The retry is safe because the kernel
validates pdfork flags before creating a child.  On such kernels the
zombie must still be reaped with waitpid(2), as before the flag was
introduced.

The fallback is compiled out once __FreeBSD_version reaches 1700000,
so it disappears from main when stable/16 branches while remaining in
the stable/15 and stable/16 branches that need it.

Reviewed by:	kib
MFC after:	3 days

Differential Revision: https://reviews.freebsd.org/D60401
2026-10-06 01:10:57 -07:00
Philip Paeps 91970165e3 Vendor import of expat 2.9.0 2026-10-06 07:34:57 +08:00
R. Christian McDonald a5b1b2d2c5 libpfctl: remove the state getters that do not take a handle
Nothing in the tree calls any of the three.  Remove them rather than
fix them: pfctl_get_states_h() does the same with the handle that the
caller has.  pfctl_free_states(), struct pfctl_states and the list
entry in struct pfctl_state were there for pfctl_get_states() alone,
and go with it.

Reviewed by:		kp
Approved by:		kp (mentor)
Fixes:			2a478dfc7f ("libpfctl: retrieve family id only once")
Sponsored by:		Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D60248
2026-10-04 08:06:10 -04:00
Konstantin Belousov dec68aeff8 libc/stdlib/getenv.c: always allocate new environment
in particular, if the old environment is NULL.

Among making it less surprising for userspace to observe NULL environ,
the change also prevents NULL deref in __rebuild_environ() when
terminating the empty as NULL environment with the NULL pointer.

Reported by:	 Leo Bicknell <[email protected]>
PR:	298747
Reviewed by:	emaste, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D59996
2026-10-02 22:48:42 +03:00
R. Christian McDonald f05af59fba pf: return per-address feedback from netlink table test
The PFNL_CMD_TABLE_TEST_ADDRS reply carries only the match count, so
the per-address feedback from pfr_tst_addrs() is lost:
"pfctl -v -T test" lists nothing and "pfctl -vv -T test" reports
every address as "nomatch".

Return each address, as updated by pfr_tst_addrs(), in a nested
PF_TAS_ADDR attribute, and decode them into the caller's array in
libpfctl.  PF_TA_ADDR is not reused: it shares its value with
PF_TAS_ASTATS, which older libpfctl would decode into an
uninitialised target.  That target was also read when no reply was
parsed, so the match count could be garbage; initialise it.

Add a regression test.

Reviewed by:		kp
Approved by:		kp (mentor)
Fixes:			281282e935 ("pf: convert DIOCRTSTADDRS to netlink")
See also:		https://redmine.pfsense.org/issues/17135
Sponsored by:		Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D60146
2026-10-01 06:39:01 -04:00
R. Christian McDonald 55a69b9be8 libpfctl: zero the counters before summing per-chunk results
The chunked table address functions (set, add, del, clr_astats) add
each chunk's result to the caller's counter without initialising it.
pfctl reuses nadd for the number of tables created, so a replace that
also creates the table is off by one:

pfctl -t foo -T replace 192.0.2.1

reports "2 addresses added".

Zero the counters first, as pfctl_test_addrs() already does. Remove
the workaround for the add case from pfctl (da64f6e047), which is
no longer needed.

Add a regression test.

Reviewed by:		kp
Approved by:		kp (mentor)
Fixes:			08ed87a4a2 ("pf: convert DIOCRSETADDRS to netlink")
MFC after:		1 week
Sponsored by:		Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D60174
2026-09-30 19:23:21 -04:00
Konstantin Belousov 1e8708d9b5 stat.2: document SFBSD_MNTROOT
Reviewed by:	sobomax, markj, olce
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D59910
2026-10-01 00:36:04 +03:00
Dag-Erling Smørgrav 570869838f libfetch: Plug connection leaks in FTP code
When setting up an FTP transfer, we need to dereference the cached
connection before returning after a failure.

MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D60017
2026-09-30 18:55:23 +02:00
Dag-Erling Smørgrav b212f565fb libfetch: Plug leak in 304 Not Modified case
When we get a 304 Not Modified response, we need to go through the error
path to properly free any resources we've allocated instead of just
returning NULL directly.

MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D60016
2026-09-30 18:55:18 +02:00
Dag-Erling Smørgrav cd2fca49d3 libfetch: Correctly free redirect target
When processing a redirect, if we get multiple Location headers, we free
the previous one using free(new) instead of fetchFreeURL(new), which
leaks new->doc.

While here, rename new to loc since new is a reserved word in C++.

MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D60015
2026-09-30 18:55:13 +02:00
Dag-Erling Smørgrav b319c3d6ac libfetch: Reject control characters in credentials
If a URL contains credentials, check that neither the user name nor the
password contain control characters which might confuse the server,
especially in the FTP case.

MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D60008
2026-09-30 18:54:33 +02:00
Dag-Erling Smørgrav 64ce9daab9 libfetch: Limit response line length
When reading an FTP or HTTP response, error out if we read 64 kB before
hitting a newline.  Otherwise a runaway or malicious server could have
us spinning for quite a while allocating more and more memory before we
gave up or crashed.

MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D60007
2026-09-30 18:54:25 +02:00