[libc] Declare tcsetattr's termios as const (#236514)
POSIX takes a const struct termios pointer in tcsetattr, and the
implementation already does. Only the declaration in termios.yaml
disagreed, so the generated header rejected a call passing a const
pointer
AI disclosure: this patch was written with Claude Code. I reviewed the
change and checked the declaration against the implementation. There is
no test since only the generated declaration changes
Assisted-by: Claude
[DebugInfo] Salvage replaced urem & srem instructions (#234224)
When `correlated-propagation` removes urem and srem instructions, it
doesn't correctly salvage the debug info. This leads to variables having
incorrect debug info. This patch makes sure we salvage the debug info
before removing the instructions
(See https://github.com/llvm/llvm-project/issues/218631 &
https://github.com/llvm/llvm-project/issues/218633)
[flang][Semantics][Lower] Lower explicit-shape arrays declared with rank-1 integer array bounds (F2023 R818) (#215403)
Part 3 of 3 implementing F2023 explicit-shape-bounds-spec, where a rank-1
INTEGER array of constant size supplies all the bounds of an explicit-shape
array, e.g. `real :: a(n)` or `a(lo:hi)` with rank-1 n/lo/hi declaring an
array of rank size(n). Parts 1 (#188447) and 2 (#203030) added the parsing
and the semantic representation; this part adds lowering, the module-file
round trip, and the folding needed for the feature to be usable end to end.
Executable coverage is in llvm/llvm-test-suite#411.
Representation. Semantics expands such a declaration into one ShapeSpec per
dimension. A bounds array that folds to a constant is folded into ordinary
per-dimension constant bounds at declaration, exactly as if dims(1),dims(2),...
had been written, so every consumer that reads a bound with ToInt64()
(EQUIVALENCE offsets, LBOUND/UBOUND folding, static-shape lowering) sees the
same ShapeSpec the ordinary syntax produces. A non-constant bounds array is
wrapped per dimension in a scalar evaluate::RankOneBoundElement that extracts
element [dim] from the shared rank-1 base; the wrapper is left unfolded so the
module-file writer can emit the original whole-array bound. ArraySpec records
[50 lines not shown]
Initial import of brotli 1.2.1, that fixes CVE 2026-111497.
also includes enhancements in dictionary handling, static init of
some data to reduce size, and minor other clean ups.
the new go and python code, as well as the ignored C encoder are
not included in this import as we don't use them, and they are
more than half the space.
[Reland][Offload][Omp] Compute getBlockLimit through liboffload (#236559)
Add two new device properties accessible through liboffload:
LAUNCH_MAX_NUM_WORK_GROUPS (max blocks) and LAUNCH_MAX_GRID_SIZE (max
total work-items). Using them compute the getBlockLimit in libomptarget
in a backend agnostic way.
Remove getBlockLimit from the Plugin Interface as it's no longer needed.
Assisted by Claude.
[bazel][lldb] Add the first lldb unit tests (#232715)
Start modeling lldb/unittests in the bazel overlay with the
TestingSupport helper libraries (lldbUtilityHelpers, lldbHostHelpers)
and the unit tests that only need lldb's base libraries: UtilityTests,
HostTests, HostCommonTests, SignalsTests and EditlineTests. The
remaining tests follow in later changes.
There are already tests for llvm folder's binaries with bazel:
https://github.com/llvm/llvm-project/blob/c7da05f9828542daaf634a6f4277212b5f6194d5/utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel
Test names and dependencies mirror the add_lldb_unittest() calls in the
CMake build, so the two are easy to keep in sync.
Several lldb unit tests read files through
lldb_private::GetInputFilePath(), which looks in an Inputs/ directory
next to the test binary. CMake's add_unittest_inputs() copies them
there; this does the same with copy_file, so the inputs land beside the
test binaries in the runfiles tree.
[12 lines not shown]
NAS-144914 / 28.0.0-BETA.1 / Use `force_sql_filters` by default when possible (#20065)
New `_datastore_sql_filters` field lists all fields that are safe to
filter with SQL. If filter is `=`, `in` or `nin`, SQL filters are used
by default. Removes a number of `force_sql_filters` for new-style
plugins. Legacy-style plugins will follow.
[lldb] Return llvm::Error from GenerateWatchpointCommandCallbackData (#235985)
Propagate the error from GenerateFunction instead of a bool, so a
malformed Python one-liner reports the real error instead of "failed to
generate watchpoint callback".
```
(lldb) watchpoint command add -s python 1 -o 'def ('
error: SyntaxError('invalid syntax', ...)
```
Assisted-by: Claude
feat(gisel): Mirror trunc/xor/select demanded bits
Extend scalar demanded-bits simplification to G_TRUNC, G_XOR, and
G_SELECT, following SelectionDAG traversal, known-bit propagation,
shared-use handling, and final folds. Honor GISel legality and target
profitability when rewriting or narrowing operations.
Share AArch64's logical-immediate search through a narrow XOR hook and
adapt XOR/shift profitability queries for both selectors. Preserve
SelectionDAG's constant-shrinking interface and node construction.
Validate TRUNC(LSHR) shift amounts with the existing
GISelValueTracking::getValidShiftAmountRange.
Preserve recursive constant bypasses and use-specific rewrites of shared
producers. Recognize constants at the analysis depth limit, matching
SelectionDAG, and retain KnownBits-based bypasses as a fallback.
Keep G_ASHR of G_SEXT_INREG arithmetic unless the top C + BW - W bits are
[5 lines not shown]
pf: Free a table entry that cannot be routed
pfr_insert_kentry() returned the error of pfr_route_kentry() and
leaked the entry it had created; pfr_insert_kentries() stopped at the
first entry it could not route and leaked it and the rest of the work
queue, which no caller frees. Destroy an entry that cannot be routed
and go on with the next.
Reviewed by: kp
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D60532
(cherry picked from commit 989d72fd3d35daa6a056afdd0c6b0aba4c5d8ccf)
pf: Do not hash pool address pointers into rule hashes
pf_hash_pool() hashes the first address of a pool as a whole struct
pf_addr_wrap, including the union that holds the kernel's pfi_dynaddr
or pfr_ktable pointer.
An interface pool such as "-> ($ext_if)" gets a new pfi_dynaddr on
every load, so with "set keepcounters" the rule never matches its
predecessor and loses its counters on every reload. The pointers also
differ between hosts: once a filter rule in the main ruleset has an
interface or table pool, pfsync peers disagree on the ruleset checksum
and bind every synced state to the default rule.
Hash the address with that union cleared. The rest of the address,
including the prefix length of an interface address, is hashed as
before, and the hash of a rule with a plain address pool does not
change.
Reviewed by: kp
[6 lines not shown]
pf: Set the reassembly flags under the rules lock
DIOCSETREASS stored V_pf_status.reass twice with no lock, first the
flags it was given and then, if reassembly was not among them, zero.
pf_normalize_ip() and pf_normalize_ip6() read the flags with the rules
lock held for reading, so a packet could see the intermediate value.
Compute the flags first and store them once, with the rules lock held
for writing, as DIOCSETDEBUG and DIOCSETHOSTID do.
Reviewed by: kp
Fixes: 39282ef356db ("pf: backport OpenBSD syntax of "scrub" option for "match" and "pass" rules")
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D60531
(cherry picked from commit b951994eddd4d274514df751da06680a32139037)
pf: Drain the overload task before a vnet's rules are freed
pf_src_connlimit() queues an entry for pf_overload_task() when a
source exceeds max-src-conn or max-src-conn-rate and the rule has an
overload table. The entry holds a pointer to the rule, and the task
runs from taskqueue_swi with the vnet of the queue. Nothing drained
the task when the vnet went away: an entry queued just before could
be applied to a rule pf_unload_vnet_purge() had freed, or to a vnet
that was gone.
Drain the task at the start of pf_unload_vnet_purge(), before the
unlinked rules are freed. No packet can queue another by then, as the
hooks are already removed.
Reviewed by: kp
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D60529
(cherry picked from commit 92d66a6b474fa6fe42fbe08002803d79a5af6594)
rms: Order a writer's stores before its readers see it leave
Readers check rms->writers without a fence, and rms_wunlock() drops
it with a plain store. rms_wlock() interrupts every CPU before the
first writer blocks readers, but nothing orders them when the last
writer leaves: on a weakly ordered CPU a reader can see the count
reach zero and still read what the writer replaced, such as callbacks
of a module unloaded under the lock.
Fence every CPU before the last writer drops the count: rename
rms_wlock_switch() to rms_block_readers() and add
rms_unblock_readers(), a wrapper for cpus_fence_seq_cst(). Readers
stay fence-free; the cost lands on the rare unlock.
Reviewed by: mjg
Discussed with: kib
Fixes: 1f162fef76a0 ("Add read-mostly sleepable locks")
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
[3 lines not shown]
if_gre: Use OID_AUTO for the net.link.gre sysctl node
if_gre(4) registers net.link.gre with the static OID number IFT_TUNNEL.
That number is an interface type that several tunnel drivers share, not
one that belongs to gre(4). if_me(4) used it too, which made loading
both modules panic until 21f2245de219. Nothing addresses the node by
number, so use OID_AUTO as if_me(4) now does.
Suggested by: markj
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")
(cherry picked from commit 80bc1d0e3ef732c6b58d13d0f223453a2410d8c1)
iflib: Do not ring the transmit doorbell when nothing is pending
For a lightly used ring iflib_txd_db_check() may defer zero descriptors,
so its "pending >= limit" test is true even when nothing has been queued
since the last doorbell. iflib_txq_drain() calls it before, inside and
after its loop, so a sender that drains its own packet wrote the tail
register three times per packet, twice with the value the hardware
already had.
The log of 81be655266fa ("iflib: ensure that tx interrupts enabled and
cleanups") calls skipping the doorbell when db_pending is zero "an
obvious missing optimization"; the comparison against a limit of zero
defeated it. vmx(4) and mgb(4) have dropped such repeated requests in
the driver since 2019. Return early when nothing is pending.
Reviewed by: gallatin
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D60290
[2 lines not shown]
if_me: Do not reuse gre(4)'s static sysctl OID number
if_me(4) registers its net.link.me node with the static OID number
IFT_TUNNEL, the same number if_gre(4) has used for net.link.gre since
2003, so the two tunnel drivers collide under net.link. Until
d35c4cfad580 that only printed a warning and left two nodes with the
same number; since then sysctl_register_oid() panics, so loading if_me
after if_gre (or the other way round) takes the box down:
kldload if_gre
kldload if_me
panic: sysctl: OID number(131) is already in use for 'me'
Use OID_AUTO like the other tunnel drivers. Nothing addresses the node
by number.
Reviewed by: ae
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")
[3 lines not shown]
igc: Fix the flow control sysctl
dev.igc.N.fc read and wrote a function-static variable shared by every
igc device, so a read returned the last value written to any of them (3
until the first write), not the state of the device. The softc value
started as 0, which is also the value of "no flow control", while the
hardware was set up for full flow control. As a result:
- Writing 0 was taken for no change and did nothing, unless another
value had been written to that device before.
- igc_reset() took a softc value of 0 for "not set", so a device set to
0 went back to full flow control on the next init.
- With more than one receive queue the driver enabled per-queue drop
(SRRCTL.DROP_EN), which is meant for a MAC that does not send pause
frames, although the MAC was told to send them.
- Values out of range were accepted and ignored.
A write only forced the MAC's flow control bits. The pause bits
advertised to the link partner, the pause thresholds and DROP_EN stayed
[26 lines not shown]
epoch: Fix use-after-free in epoch_trace_report()
epoch_trace_report() assigned the return value of RB_INSERT() back to
the new element. When two threads report the same stack concurrently,
the loser's RB_INSERT() returns the element already in the tree, and
that element was freed while still linked, leaking the new allocation.
The next lookup touches freed memory; KASAN catches it as a
use-after-free.
Keep the return value separate and free the new element instead. The
thread that won the race prints the report, so return without printing
it a second time.
Reviewed by: markj
Fixes: 173c062a569b ("Improve EPOCH_TRACE")
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D60162
(cherry picked from commit dd5dc8f6e51c5132f2dc885f5c1b0492cdf3052c)
pf: modify pfik_flags atomically
The purge thread sets PFI_IFLAG_REFS on the interfaces that states
refer to without the rules lock, under which the other flags are
changed. The updates can interleave, so that a "set skip on" is lost,
or outlives its removal, until the next ruleset load.
Use atomic operations to modify the flags. In the purge thread, only
write if the flag is not already set.
Reviewed by: kp
Approved by: kp (mentor)
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D60107
(cherry picked from commit c1241c6e30c792fb514f4689d2ed92ee21d3cf39)
pf: do not loop on an address that is cleared twice in pfr_clr_astats()
pfr_clr_astats() looks up each address it is given and inserts the entry
it finds at the head of a work queue. If the same address is given more
than once, the entry is inserted twice and the second insertion makes it
its own successor. pfr_clstats_kentries() then walks the queue forever,
with the rules lock held for writing, so packet processing and every
other pf operation in that vnet stop as well. To reproduce:
pfctl -e
pfctl -t foo -T add 192.0.2.1
pfctl -t foo -T zero 192.0.2.1 192.0.2.1
Do as pfr_del_addrs() does: clear pfrke_mark on the entries named, then
queue an entry only the first time it is seen. An address given more
than once is cleared, and counted, once. Validate all addresses before
any entry is touched.
Add a regression test.
[8 lines not shown]