linux: Pass a valid thread pointer to linux_msg()
linux_msg() will dereference that pointer if a debugging flag is set.
Reported by: Tianyi Chen <hi at tychen.cc>
Fixes: 3965de642c29 ("linux: Add inotify support")
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
shm: Fix a shm object refcount leak in shm_rename(SHM_RENAME_EXCHANGE)
With RENAME_EXCHANGE we acquire an extra ref on the destination object
so that shm_remove() doesn't free it. However, we failed to release
that ref if the rename fails.
Reported by: Laam Alif at Ibteda Digital Library
Fixes: 9afb12bab41f ("Add an shm_rename syscall")
Reviewed by: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61806
vm_object: Fix synchronization between reinit and global list walks
Checking for OBJT_DEAD in vm_object_list_handler() is racy since pagers
may set the object type to OBJT_DEAD after having dropped and reacquired
the object lock. dev_pager_dealloc() does this, for instance. Check
for the OBJ_DEAD flag as well, as that is set earlier. Fix one rare
case in the vnode pager where we freed an object without setting
OBJ_DEAD, and add an assertion to the zone destructor.
Try to minimize accesses of the object after dropping the object lock in
vm_object_list_handler().
Add a comment to warn others to think carefully before adding more
cases.
Fix shm_get_path() to reject dead objects. Fix tmpfs to finish
initialization of the object under its lock; we cannot claim that the
object is thread-private since it lives on a global list.
Try to close races with _vm_object_allocate(). Update object->flags,
[20 lines not shown]
freebsd32: Fix the ffclock estimate conversions
The CP() arguments were reversed in both directions, so
ffclock_getestimate() copied out uninitialized stack memory and
ffclock_setestimate() installed it as the system estimate.
Add helper functions to do the conversion, implemented so as to make
such mistakes harder to make.
Fixes: e3e811a3f824 ("freebsd32: add feed foward clock syscalls")
Reviewed by: brooks
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61774
arm64 pmap: Sync the icache in pmap_enter_largepage()
Unlike pmap_enter(), don't test PGA_ICACHE_SYNCED, because large pages
are unmanaged.
While here, assert that va is aligned to the page size, as amd64 does,
and that the pmap is stage 1, which the new code assumes.
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D61897
libc/fnmatch/rangematch: fix incorrect arguments to memset
strmbs variable is already a pointer, so calling memset on its address
was equivalent to setting the pointer, but the intent was to set the
pointed object.
This was found while debugging an unrelated issue in the same function.
Fixes: af79566b9315
MFC after: 1 week
libc/fnmatch/rangematch: fix uninitialized variable read in a condition
The condition was logically incorrect and could also result in access to
an uninitialized variable. The bug happened because of misplaced
parentheses in the complex condition. There is another very similar
condition in the code and it has the correct placement, so it does not
have the bug. I used it as an example for the fix. Both conditions
came from the same commit af79566b9315.
For me, the bug appeared as a random failure to match a simple pattern
with '[0-9]' in it. The value of the uninitialized variable depended on
the value left on the stack by other code, so the bug appeared only
under very specific conditions.
FWIW, gcc catches and reports the uninitialized variable problem.
clang does it only with -Wconditional-uninitialized but that flag leads
to too many false positives.
I also found a pattern that deterministically reveals the bug in a
[14 lines not shown]
hwpmc: claim stray PMI NMIs on Intel
core2_intr() claims an NMI only when IA_GLOBAL_STATUS shows an
overflow. It re-enables the LAPIC PMC vector before acking the
status bits, so a PMI raised while the handler runs can latch a
second NMI that finds the status already clear. That NMI goes
unclaimed and, with the default machdep.panic_on_nmi, panics the
machine. hwpmc_amd.c already absorbs such NMIs with a per-CPU
nmi_counter.
Give core2_intr() one credit per serviced PMI and spend it on the
next NMI on that CPU that finds no overflow.
Reproduced on a Xeon D-1518 (Broadwell-DE) running system-wide
CPU_CYCLES sampling: the unpatched kernel panicked with "NMI" after
about 47k PMIs. With this change it ran 12.5 hours (485k PMIs),
absorbed 6 empty NMIs, and did not panic.
Sponsored by: Netflix
[2 lines not shown]
x86: Do not take a CPUID leaf 1Fh module for the package
Each level of CPUID leaf 0Bh or 1Fh reports the shift that addresses
the next level up. Leaf 0Bh has only the SMT and core levels, so the
core level's shift identifies the package. Leaf 1Fh may enumerate
module, tile, die and die group levels above the core level, and then
the core level's shift identifies one of those instead.
topo_probe_intel_0xb() used the core level's shift for the package in
both cases. On a processor that enumerates a module level, every
module became a package, and the L3 cache was cut down to the module
with "WARNING: L3 data cache covers more APIC IDs than a package", so
the scheduler did not see that the modules share it. An Atom x7809C
(Amston Lake), which reports shifts of 1, 3 and 7 for its SMT, core and
module levels, came up as two packages of four cores. The N150 (Twin
Lake) in the PR is affected in the same way.
Use the shift of the last level enumerated for the package. The SDM
describes the package as the unenumerated domain above the last valid
[24 lines not shown]
nfs: Cache reply pages in an NFS-owned UMA zone
Allocate anonymous reply pages through a dedicated UMA cache and
return them in batches when the last M_EXTPG reference is released.
This reduced page-cache bucket shortages in the tested
concurrent-read workloads. The pool uses the existing UMA and
mbuf interfaces.
Once nfsd enables the pool, nfscommon refuses unload so delayed
callbacks remain valid. The usual nfsd/nfslockd dependency chain
already retains nfscommon; the explicit guard also enforces this
requirement directly. Loading nfscommon alone does not activate
that guard.
Mark Johnston suggested using a dedicated zone in the D61234 discussion.
That feedback led to this NFS implementation instead of changing UMA.
Gleb Smirnoff provided feedback on the original allocator proposal.
Reviewed by: rmacklem
[3 lines not shown]
powerpc: don't save the FPU state again in freebsd32_sigreturn()
set_mcontext32() restores the floating point registers from the context,
then freebsd32_sigreturn() called save_fpu(), which writes the hardware
registers, the ones the signal handler left behind, back into the PCB.
The process resumed with the handler's registers instead of its own.
sys_sigreturn() has no such call; drop it here too.
A 32-bit program that loads f14, takes a signal whose handler loads
another value and reads f14 back got the handler's value on a
COMPAT_FREEBSD32 kernel; it gets its own now, like the 64-bit build.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61792
Add a -b option to fsck(8) to specify an alternative superblock.
Pass the -b flag from the wrapper to the underlying filesystem checker.
This allows users to specify superblock directly without the need to
invoke the underlying checker manually.
Reported by: Aadya Chinubhai <aadyachinubhai at gmail.com>
PR: 27687 (from May 2001)
MFC after: 1 week