rtsock: drop a notification whose sockaddr does not fit
rtsock_msg_mbuf() bounces every sockaddr through a struct
sockaddr_storage on the stack, and only a KASSERT checks that it
fits. Without INVARIANTS, a larger sockaddr overflows the stack.
The callers pass only sockaddrs that the kernel built or checked, so
one that does not fit is a bug in the caller.
Also check at run time, as f3be7df50f0 did for rtsock_msg_buffer():
free the mbuf and return NULL, which every caller already handles
like a failed allocation.
Log the drop at LOG_DEBUG, as rt_xaddrs() does for an oversized
sockaddr from userland. The message is compiled in but off by
default. Setting net.route.debug.rtsock_debug_level to 7 shows which
message and sockaddr were dropped.
Reviewed by: lytboris
[4 lines not shown]
Check objset MACs directly
When an objset block is smaller than the pool's objset_phys_t size,
dmu_objset_open_impl() copies it into a larger anonymous ARC buffer.
The copy isn't marked unauthenticated, so dmu_objset_own() and
non-raw sends accept it without checking its MACs, and the next write
computes new MACs over it. Encrypted objsets written by older illumos
ZFS are 2 KiB, so they take this path on pools with project quotas
enabled.
Have dmu_objset_authenticate() check the MACs of os_phys itself
rather than rely on the ARC's mark. The zero padding of a copy doesn't
change the MACs. A new objset has no MACs to check, so it starts out
authenticated.
Reviewed by: George Wilson <gwilson at zfsmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Matthew Ahrens <matt at mahrens.org>
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
Closes #19884
[lld/mac,lld/win] Call llvm::sys::fs::current_path() less (#247661)
Summary: This makes linking Chromium Framework ~30 ms faster on
unix systems in the common case, and ~0.2s faster on macOS in
a very uncommon case. If chrome.dll is linked without /pdbsourcepath
(in practice, it's always linked with that flag), it makes linking
chrome.dll faster by ~1.4s on unix systems in the common case,
and ~11 s (!) (19.45s -> 8.63s) on macOS in a very uncommon case.
Details:
Unix/Path.inc implements current_path() by checking if
stat($PWD) and stat(".") refer to the same inode. If they do, it
returns $PWD. Else, it returns getcwd().
lld-link and ld64.lld by default make all debug info paths absolute
relative to the cwd. They did this by calling sys::fs::make_absolute()
with just the relative path for each object file. make_absolute()
internally calls current_path().
[26 lines not shown]
Check objset MACs in one place
dmu_objset_own() and non-raw sends each check the MACs of an
encrypted objset by looking at the ARC header of os_phys_buf, without
a lock, while the sync thread may be writing the objset and replacing
that header.
Move the check into dmu_objset_authenticate(). Mark the objset as
being written from before os_phys_buf is released until the write is
done, and have the check wait for a write in progress. Record in the
objset that its MACs have been checked, so that later callers skip
the check and don't wait. A raw receive changes the MACs, so it marks
them unchecked again.
Reviewed by: George Wilson <gwilson at zfsmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Matthew Ahrens <matt at mahrens.org>
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
Closes #19884
ZTS: make zfs-tests.sh -t NAME select the test of that name
zfs-tests.sh -t NAME, given a name rather than a path, runs the first
path under the test suite whose name starts with NAME, in directory
order. Many tests share that prefix with something that is not the
test: a helper program (bin/mmap_ftruncate once installed, or
cmd/mmap_ftruncate.c in a source tree; likewise mmap_read_truncate,
mmap_eof_extend, mount_null_source, send_doall, file_append), a
directory named after the test (zfs_rewrite, zfs_load-key), a data
file (a channel program's .zcp or .out), an object file, or another
test (tst.clone_neg for tst.clone). Which path comes first depends on
the file system. A directory or a data file makes test-runner reject
the runfile, so nothing runs; an installed helper is an executable
file, so test-runner runs it instead of the test.
Search only tests/, and for a file named NAME.ksh or NAME first, so
that the tests that are programs (hkdf_test, many_fds, page_alignment,
tmpfile_*) are still found, and skip .libs, where libtool keeps a
second copy of such a program in a build tree. Only when no file has
[10 lines not shown]
[RISCV][CFI] Preserve CFI instructions around CM_POP and RET (#246963)
Emit CFI restore directives and update the CFA offset after CM_POP,
except when followed by RET. Update the POPRET fusion pass to match
CM_POP and RET across debug instructions. Remove CFI directives between
foldable CM_POP and RET. Update affected tests accordingly.
Follow up #245548
ZTS: run cleanup when a test fails
These tests skip some of their cleanup when they fail, so a failure
leaves state behind for the tests after it:
- zpool_iostat_interval_all, zpool_iostat_interval_some, slog_014_pos:
register the cleanup function, which they never did.
- inherit_001_pos: register default_cleanup_noexit, which was only
called at the start of each configuration.
- delegate verify_fs_receive, verify_fs_receive_append: remove the
stream files when the test fails, too.
- tmpfile_002_pos: remove the link when zpool freeze or export fails,
so that tmpfile_003_pos does not find it.
- removal tests: stop the random writer when the test fails, before
the pool is destroyed.
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Alan Somers <asomers at gmail.com>
Signed-off-by: Matthew Ahrens <matt at mahrens.org>
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
Closes #20081
docs: Add some best practices documentation for codegen tests (#244482)
Document common review feedback.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[dsymutil] Don't write past a DIE for a relocation that does not fit (#247778)
applyValidRelocs() asserts that a relocation fits in the DIE it
patches, then writes it regardless. A relocation map which does not
describe the DWARF of its dSYM holds relocations running past their
DIE, and one larger than 8 bytes also overflows the buffer its value
is built in.
Reject a relocation running past the range it is looked up in, with a
warning. getRelocations() does so for every lookup: such a relocation
is not applied, does not keep its DIE, and is not saved to the output
relocation map. The asserts in applyValidRelocs() now hold.
The check needs exact ranges. In both linkers,
getVariableRelocAdjustment() passed a range starting at the length of
the block, which precedes the expression. Two tests had their
relocations on that length, where only such a range found them. Move
them to the operand.
[4 lines not shown]
RuntimeLibcalls: Add attributes to ObjC runtime calls
Mark the ObjC runtime functions nounwind, and mark the argument of
the functions whose intrinsics mark their argument returned.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Add attributes to operator new and delete
Annotate operator new and delete implementation variants. The nothrow
variants are nounwind. No library registers these yet so they don't
appear in the DeclareRuntimeLibcalls tests.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
linux: reuse stored names for normalized lookups
Resolve normalization-equivalent names to the stored dentry so that
removing or renaming one spelling cannot leave another cached spelling
accessible. Keep case sensitivity unchanged and discard negative
dentries that could hide a newly created equivalent name.
Warm both spellings in the native mixed-case deletion test.
Remove the Linux expected-failure entries for the four normalization
tests which now pass.
Assisted-by: OpenAI Codex
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: ooonea <35407790+ooonea at users.noreply.github.com>
Closes #13980
Closes #19726
Revert "[Clang][Sema] Accept weak reference after declaration" (#247827)
Reverts llvm/llvm-project#228809 . There was reported breakage building
OpenZFS.
I'd prefer to take our time to get this right.
[X86] canonicalizeShuffleWithOp - generalize VZEXT_MOVL folding to any op with known zero in the upper bits (#247832)
Generalised from the VTRUNC handling that was added to #245048 - we can
use value tracking to confirm that the upper bits are already zero,
which means the VZEXT_MOVL will be free if moved through the logic op.
libzfs: FreeBSD: retry an unmount a mount update holds busy
FreeBSD's dounmount() returns EBUSY while the mount has MNT_UPDATE
set, that is while any nmount(MNT_UPDATE) on it is in progress.
mountd(8) applies export changes that way, and libzfs signals mountd
in zfs_unmount() (zfs_commit_shares() after zfs_unshare()) right
before calling unmount(2). So 'zfs unmount', 'zfs set canmount=off',
'zfs destroy' or 'zpool export' of a dataset with sharenfs=on could
fail with "pool or dataset is busy" when mountd's update of that file
system (from this or an earlier share change) overlapped the unmount.
This is the inheritance/inherit_001_pos failure on the FreeBSD CI
runners. FreeBSD 14 calls VFS_MOUNT() (a ZFS remount) for each export
update as well, which makes the window wider there.
Retry unmount(2) on EBUSY with a short backoff (10 ms doubling, about
1.3 s in all). A file system that is really busy still fails with
EBUSY, only later.
This makes zfs_unmount_remount_busy pass.
[5 lines not shown]
ZTS: zfs unmount of a file system busy for a moment
On FreeBSD, unmount(2) returns EBUSY while another thread is inside
nmount(MNT_UPDATE) on the same mount. mountd(8) does exactly that
whenever libzfs commits an NFS share change: it pushes the new export
list into the kernel with nmount(MNT_UPDATE). 'zfs unmount' of a
dataset with sharenfs=on signals mountd right before its own
unmount(2), so it races mountd's update of that very file system.
This is the "cannot unmount ...: pool or dataset is busy" failure of
'zfs set canmount=off' in inheritance/inherit_001_pos on the FreeBSD
CI runners.
zfs_unmount_remount_busy (FreeBSD only, about 3 s):
- a file system held busy by a process, released only once
'zfs unmount' has had EBUSY and waits to try again, must unmount;
without a retry this fails every time, independent of timing;
- 50 unmount/mount cycles while a background loop updates the mount
(mount -u), as mountd does, must all succeed;
- a file system that stays in use must still refuse with "busy",
[6 lines not shown]