pf: fix displaying expired states
pf_state_expires() returns <= time_uptime for expired states. For such
states we should return a PF_ST_EXPIRE value of 0 to userspace.
We used to return the timestamp at which the state expired, which
resulted in nonsensical expiry times being printed. That in turn caused
the pfsync:expire_underflow test case to intermittently fail.
Adjust the test case to account for expired states now showing 'expires
in 00:00:00'.
Sponsored by: Rubicon Communications, LLC ("Netgate")
pf: extend stricter checking for ICMPv6 packets
Now that we copy in the full MLD/ND packet we can sensibly inspect
their contents, and use them to generate more unique states for their
respective ICMPv6 packets.
Obtained From: OpenBSD, mcbride <mcbride at openbsd.org> 70bf7555ef4c
Sponsored by: Rubicon Communications, LLC ("Netgate")
if_ovpn: defer freeing of struct ovpn_kkey_dir
These keys are used in the data path, but can be freed through control
operations such as OVPN_NEW_KEY and OVPN_DEL_KEY. That might cause us to
use a freed key while processing packets.
Avoid this by using epoch callbacks to free the keys. That means that
the key is guaranteed not to be freed until after we're done with any
packet that could be using it.
Reported by: Kevin Day <kevin at your.org>
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
[Modules][ObjC] No methods are visible when messaging id in local submodule visibility (#247766)
When checking for known methods, use Sema::isVisible instead of
Decl::isUnconditionallyVisible.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
rdar://193808802
Don't trust dn_maxblkid for power-of-2 blocks in dmu_read_impl()
dmu_read_impl() zero-fills any range past the first block when
dn_maxblkid == 0. dbuf_dirty() publishes a new dirty record before
dnode_new_blkid() raises dn_maxblkid, and on Linux the
dn_struct_rwlock upgrade always drops and re-acquires the lock, so
another writer to the same block can find it already dirty, skip the
raise, and read its own data back while dn_maxblkid is still 0. For
WR_COPIED log records this logged sync writes with all-zero payloads,
which were replayed as zeros after a crash.
Only objects with an odd (non power-of-2) block size are guaranteed
to have a single block, so limit the shortcut to them. Power-of-2
objects take the normal path, which finds dirty dbufs or holes.
Normal read(2) uses dmu_read_uio_dnode() and is unaffected.
The free path makes a similar dn_maxblkid assumption; it is addressed
separately by raising dn_maxblkid before the dirty record is
published in dbuf_dirty().
[4 lines not shown]
RuntimeLibcalls: Add SME attributes to the AArch64 SME support routines (#245123)
SMEAttrs currently assumes these attributes based on the function
name. Add them to the function definition so this code can be cleaned
up in the future.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[flang] Keep complex powers with a negative constant exponent (#244671)
The algebraic simplification pass rewrites `z**(-n)` as `1 / (z * ... *
z)`. When that complex division is expanded inline, for example with
`-fcomplex-arithmetic=basic`, its intermediate results can overflow
although the power is representable. This patch keeps the power, so that
it is lowered to a runtime call.
**Option:** `keep-negative-complex-powi=false` restores the rewrite.
**Example:**
```fortran
subroutine s(a, b)
integer, parameter :: k = -2
complex(8) :: a, b
a = b**k
end subroutine
```
[17 lines not shown]
yp_unbind(3): Avoid null pointer deref after a yp operation.
Not a thread-safety issue -- this happens deterministically in a
single-threaded program if you do, e.g.:
yp_bind(domain);
yp_all(domain, ...);
yp_unbind(domain);
PR lib/61064: libc dumps core because yp nis not thread safe
libc/yp: Paranoia: avoid arithmetic overflow in allocation sizing.
Not sure if these paths are possible to hit, but let's make sure they
don't lead to disaster downstream.
Followup prompted by:
PR lib/61064: libc dumps core because yp nis not thread safe
[lld][MachO][NFC] Tag SymbolTable additions and duplicate diagnostics with EventKey
This is part of the ld64.lld performance improvements tracked by #222068 and #238938.
Tag symbol additions and duplicate-symbol diagnostics per shard with an EventKey encoding (batch, file, event) and merge batch additions in key order in endBatch(), keeping getSymbols() and duplicate diagnostics deterministic independently of insertion order.
This is part of a series of PRs that's setup work for turning on parallel sharded symbol-table insertion.
[lld][MachO][NFC] Shard SymbolTable lookup map by symbol name hash
This is part of the ld64.lld performance improvements tracked by #222068 and #238938.
Split SymbolTable's name map into 64 shards indexed by the high bits of CachedHashStringRef::hash(), storing Symbol* directly in each shard's DenseMap and allocating SymbolUnion instances with makeThreadLocal().
This is part of a series of PRs that's setup work for turning on parallel sharded symbol-table insertion.
[DWARFLinker] Differentiate unit-local functions sharing a linkage name (#247763)
The parallel linker uniques a function by its linkage name. That name is
unique across units only if the function is external. Two units can each
have a static init(), or instantiate a template over their own lambda,
and get the same mangled name for different functions. They were merged
into one DIE, and .debug_names kept an entry per unit:
```
error: Name Index @ 0x0: Entry @ 0x18a: mismatched Name of DIE @
0x226: index - call<(lambda at b.cpp:5:12)>; debug_info -
call<(lambda at a.cpp:2:46)>, call, _Z4callIZL4initvE3$_0EiRT_.
```
For a function that is not external, add the declaration file and line
and the template arguments to the name. Copies of one static inline
function from a header still merge.
An external function whose DW_AT_name differs between units still gets
[3 lines not shown]
reaper_abandon_children(): leave no orphans on a reaped reaper
A reaper which exited stays the reaper of its subtree until it is
reaped, and processes can be linked onto its orphan list after its
exit1() emptied it. PT_ATTACH puts there a child which stayed with its
zombie reaper parent. Since 38ab6d47b7cb, reaper_adopt() puts there a
traced process which the zombie gets when a subreaper is reaped. When
the zombie is reaped in turn, reaper_abandon_children() keeps an orphan
holding a zombie reference with it, as is right only for
PROC_REAP_RELEASE. The struct proc is freed with the orphan still
linked to it, and proc_realparent() returns the freed or reused struct
proc on PT_DETACH, on the exit of the debugger, and from wait(2).
When the reaper is reaped, pass every orphan on to the new reaper, as
its children are. Anything linked onto the orphan list of a zombie
reaper is on its reaplist, so this empties the list. Assert that in
proc_reap().
Reported by: llm-postcr
[4 lines not shown]
tests/sys/kern/ptrace_test: reap a reaper which has a traced orphan
Add ptrace__parent_reaper_exits_before_attach, where the parent of the
traced child, also its reaper, exits before the attach. The child stays
with the zombie, and the attach puts it on the orphan list of the
zombie.
Add ptrace__reaper_exits_before_subreaper, where the parent of the
traced child is a subreaper, and the reaper above it exits first.
Reaping the parent while the reaper is a zombie hands the child over to
the zombie, and links it onto the orphan list of the zombie.
In both tests, the test process then reaps the zombie, detaches from
the child, and waits for it. Before the fix, the child stayed on the
orphan list of the freed reaper, and PT_DETACH handed it to the freed
struct proc.
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
[DWARFLinker] List the empty directory in a DWARF 5 type unit (#247761)
A file with an absolute name has no directory. The type unit gave such a
file directory index 0 without adding a directory. That is right before
DWARF 5, where index 0 is the compilation directory and is not listed. A
DWARF 5 table lists every directory, so when all files were absolute the
table had none and could not be parsed:
```
warning: parsing line table prologue at 0x00000000 found an invalid
directory or file table description at 0x0000001f
error: DIE has DW_AT_decl_file with an invalid file index 0 (the file
table in the prologue is empty)
```
Add the empty directory to a DWARF 5 table like any other.
rdar://184768136
Assisted-by: Claude
[LV] Add tests for interleave group members only used by assumes. (NFC) (#247772)
Add tests for an interleave group where one member is only used by an
assume, while another member is still used, checking the register usage
and whether the plan is considered to generate vectors. Also add a
variant of the register usage test with the assume placed after the
store.
[CIR] Handle lowering for most of Relative-Vtables (#247288)
This builds on previous patches, which move us towards the
relative-vtable implementation. This patch handles all of the lowering
except for:
1- buildVTablePointer, which is left as NYI. This is a touch more work
for C++ uses of RTTI types, so this will be done in a followup.
2- Some markers in CIRGen that need to be removed, but cannot be tested
properly due to the above.
This matches LLVM output every where I could find, so I believe this to
be correct for the cases we cover.
A follow-up patch will fix both of those, plus port the
relative-vtable-tests from classic.
Note that Claude helped heavily in generating this patch and tests.
[CIR] Implement loop-hint lowering (#247320)
Previous patches resulted in the loop hints making it to CIR, and this
patch handles the lowering. These are lowered similarly to Classic
Codegen with an attempt to make the checks/dependencies between them
'work' correctly.
This does NOT however handle 'parallel', which are both challenging for
other reasons. For parallel, this needs to get propagated to all of the
llvm-ir intructions inside of the loop: We probably want to introduce a
scope to handle this during flattening, and emit it conditionally based
on that.
[AMDGPU] Add an intrinsic and builtin to access the dispatch index
This PR adds an intrinsic (and corresponding builtin and MLIR
operation) for accessing the dispatch index on gfx12+, since it can be
needed in some low-level contexts.
AI disclosure: None, I did this by hand
[AMDGPU] Refactor wave ID intrinsic handling and expose a Clang builtin
This PR refactors how the architecture-provided wave ID on gfx12 is
exposed, including by generalizing its lowering in preparation for
adding a dispatch.index intrinsic.
This PR also annotates the wave-id intrinsic with `TargetFeatures`,
meaning that it no longer is a selection failure to use it on a target
without the architected SGPRs feature, but a failure earlier in the
pipeline.
In addition, this PR exposes this id as __builtin_amdgcn_wave_id() in
Clang, matching MLIR, and adds documentation that clarifies the
properties of the ID.
AI disclosure: None, I did this by hand
Check for a pending free before copying the block pointer for nopwrite
dmu_sync() and dmu_write_direct() copy db_blkptr for the nopwrite
check, and only then ask dnode_block_freed() whether the block was
freed in a txg that has not synced yet. The sync of that txg zeroes
the block pointer in the L1 indirect block (free_blocks(), under the
L1's db_rwlock) and then removes the range from dn_free_ranges under
dn_mtx (dnode_sync_free_ranges()); neither step takes the L0 db_mtx
that the copy and the check run under. So a copy made just before
the zeroing and a check made just after the removal see the old block
pointer and no pending free: the write nopwrites against the freed
block, and dmu_sync_done() or zio_done() then fails its BP_EQUAL()
VERIFY.
Check first. If dnode_block_freed() finds the range, nopwrite is off.
If it does not, either there was no free or its removal is done, and
dn_mtx orders the zeroing that came before the removal ahead of the
copy, so the copy sees the hole.
[9 lines not shown]