MFC: fsck_msdosfs: fix head bitmap over-allocation on 32-bit platforms
bitmap_ctor() computed the allocation size as
roundup2(bits, LONG_BIT) / (LONG_BIT / 8)
The dividend is a count of bits, so converting it to bytes requires
dividing by 8 (bits per byte), not by LONG_BIT / 8 (bytes per long).
The two divisors happen to coincide on LP64, but on ILP32 platforms
the head bitmap was allocated at twice the required size; for a
FAT32 file system with close to 2^28 clusters, that is 64 MiB instead
of 32 MiB.
The extra half of the allocation was never accessed, so there is no
functional change other than the reduced memory footprint.
Pull Request: https://github.com/freebsd/freebsd-src/pull/2440
(cherry picked from commit 269002da453895fc935101afefeb02d2c7d10360)
MFC: fsck_msdosfs: fix head bitmap over-allocation on 32-bit platforms
bitmap_ctor() computed the allocation size as
roundup2(bits, LONG_BIT) / (LONG_BIT / 8)
The dividend is a count of bits, so converting it to bytes requires
dividing by 8 (bits per byte), not by LONG_BIT / 8 (bytes per long).
The two divisors happen to coincide on LP64, but on ILP32 platforms
the head bitmap was allocated at twice the required size; for a
FAT32 file system with close to 2^28 clusters, that is 64 MiB instead
of 32 MiB.
The extra half of the allocation was never accessed, so there is no
functional change other than the reduced memory footprint.
Pull Request: https://github.com/freebsd/freebsd-src/pull/2440
(cherry picked from commit 269002da453895fc935101afefeb02d2c7d10360)
sendfile: keep the lowat hack more conservative
First, record the original lowat value and later in the wait/EAGAIN loop
look at the original value, rather than on the value that we just faked.
This eliminates some blank syscalls, where socket was reported as writable
and immediate write instantly fails. In my testing the ratio of such
syscalls was really small, under 2%, however in a different scenario this
negative effect can be more profound.
Second, cap the lowat growth to 1/2 of original socket buffer size, rather
than to current size. The problem was there before, but it became more
profound after 587c6c121504.
Note: we are considering to evaluate if the lowat hack is needed at all.
Reviewed by: tuexen
Differential Revision: https://reviews.freebsd.org/D60106
tcp: use SB_AUTOSIZE flag to tell if socket buffer was set
The check against V_tcp_sendspace is not a correct one, as a buffer may
grow larger than the initial value. The conjunction was always false up
until 587c6c121504, and only after it the bug surfaced.
If we already grow our buffer past the value stored in the hostcache,
prefer our value.
Reviewed by: tuexen
Differential Revision: https://reviews.freebsd.org/D60105
vt: Fix timer race between vtterm_splash() and vt_flush()
Current code leads to console text being drawn over the splash image.
vt_flush() draws while holding the vtbuf lock. Have it check VDF_SPLASH
under it too, and make vtterm_splash() take the vtbuf lock when setting
it, before drawing the splash.
Sponsored by: Defenso
Signed-off-by: Quentin Thébault <quentin.thebault at defenso.fr>
Reviewed by: vexeduxr
Differential Revision: https://reviews.freebsd.org/D59928
stand/images: remove translucent pixels around orb
Remove semi-transparent pixels around the orb. These become more
pronounced when the orb is used as the spash screen image.
While here also strip metadata.
MFC after: 3 days
Reviewed by: tsoome
Differential Revision: https://reviews.freebsd.org/D60163
crypto/openssl: upgrade to 3.0.22
All of the security content from 3.0.22 has been merged to this branch
already; this follows through with the remainder of the changes to
finish off the version update -- in part to make future updates easier.
This is a direct commit to :stable/14.
See commit 3180d4d82f5 a description of the content update done between
the two versions, as well as the update methodology used when importing
OpenSSL 3.0.22.
mountpoint(1): new utility, implemented as a stat(1) hardlink
Add mountpoint(1), a simple utility to tell whether the file pointed
to by the argument is a mount point. It prints whether it is, unless
-q is given, and exits 0 if it is, 1 if it is not, and 2 on error.
The answer comes from the kernel with a single stat(2): the root vnode
of a mounted file system is reported with SFBSD_MNTPOINT in
st_bsdflags. Unlike comparing realpath(3) of the argument with that
of statfs(2)'s f_mntonname, this works for arbitrarily deep
hierarchies, and after chroot(2) or inside a jail. A chroot or jail
root is reported as a mount point only if it is one.
The argument does not have to be a directory: file systems such as
nullfs(5) can be mounted over regular files and sockets, and stat(2)
reports those mount points as well.
Since all that is needed is one stat(2) call, make mountpoint a
hardlink to stat(1), the same way readlink(1) is, and document it in
[11 lines not shown]
ifuncs: Include <machine/ifunc.h> instead of <x86/ifunc.h>
All architectures have been providing an 'ifunc.h' header with
DEFINE_IFUNC() et alter working both in kernel and userland since commit
cf41d1113377 ("riscv: implement kernel ifunc resolution"), and separate
<i386/ifunc.h> and <amd64/ifunc.h> headers were introduced in commit
2b1db07bec92 ("x86: add machine/ifunc.h"), so stop including
<x86/ifunc.h> directly and use the common <machine/ifunc.h> idiom.
While here, re-order includes in the blocks featuring <x86/ifunc.h>,
which requires fixing <x86/apicvar.h> so that it can be included before
<machine/intr_machdep.h>.
Reviewed by: kib
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D60194
random: Remove unused include of ifuncs
No functional change (intended).
Reviewed by: markj, emaste
Fixes: 3a12982962ce ("random: add RDSEED as a provably unique entropy source")
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D60193
llvm: remove Mips target support
The Mips architecture has been removed from all supported branches now.
MFC after: 1 week
(cherry picked from commit b5d1e0c5a4929e2be3bc58aad8e5b707860ec0fd)
llvm: remove Mips target support
The Mips architecture has been removed from all supported branches now.
MFC after: 1 week
(cherry picked from commit b5d1e0c5a4929e2be3bc58aad8e5b707860ec0fd)
stress2: Fix script bugs in gnop6.sh, gnop7.sh and fdatasync*.sh
gnop6.sh recorded the checkfs result with "checkfs ... || s=1 && s=0",
which the shell parses as "(checkfs || s=1) && s=0", so the test passed
even when the file system check failed.
gnop7.sh only sets s when unmount or fsck_ffs fails and ends with
"exit $s". On a clean run s is unset, and the script exits with the
status of the preceding "[ $notloaded ] && gnop unload", which is 1
whenever geom_nop was already loaded, for instance by an earlier test.
fdatasync.sh and fdatasync2.sh ran "df -i $RUNDIR" before creating the
directory. With a RUNDIR that does not exist yet, df failed, the test
printed "[: -lt: unexpected operator" and the free inode check was
skipped.
Reviewed by: pho
Differential Revision: https://reviews.freebsd.org/D60136
Sponsored by: Sippy Software, Inc.
MFC after: 2 weeks
tests/sys/vfs: Fix the Linux kld check
linux and linux64 are file names, not module names. The corresponding
module names are linuxelf and linux64elf, respectively, so these tests
were always being skipped.
Fixes: b98d169d1f91 ("tests/sys/vfs: add ABI-root absolute symlink tests")
Sponsored by: The FreeBSD Foundation
lockf: Do not block in vfs_busy()
A race is possible otherwise: vfs_busy() may return after an unmounted
filesystem has been removed from the global mount list. That is,
vfs_busy() will block until vfs_mount_destroy() sets MNTK_REFEXPIRE, and
at that point the mountpoint has been removed from the mountlist, so
TAILQ_FOREACH can return an invalid value.
Simply do not block if the mountpoint is being unmounted.
Reviewed by: kib
Fixes: eca39864f702 ("Add sysctl KERN_LOCKF")
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D59982
(cherry picked from commit dd16a5f53b0b2e967d20d2900f18fc320997679b)
lockf: Do not block in vfs_busy()
A race is possible otherwise: vfs_busy() may return after an unmounted
filesystem has been removed from the global mount list. That is,
vfs_busy() will block until vfs_mount_destroy() sets MNTK_REFEXPIRE, and
at that point the mountpoint has been removed from the mountlist, so
TAILQ_FOREACH can return an invalid value.
Simply do not block if the mountpoint is being unmounted.
Reviewed by: kib
Fixes: eca39864f702 ("Add sysctl KERN_LOCKF")
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D59982
(cherry picked from commit dd16a5f53b0b2e967d20d2900f18fc320997679b)
vm_page: Fix the error path in vm_page_alloc_contig_domain()
If we are inserting a run of pages into a VM object and fail at some
point due to a memory allocation failure, we have to free all of the
pages in the run. We do that by resetting some fields and calling
vm_page_free_toq() on each page; this removes the page from the object
and frees it back to the buddy allocator.
If the page is supposed to be wired, we reset the reference count, but
this was done incorrectly: the VPRC_OBJREF flag must be retained as the
page still belongs to an object. Resetting it to zero will cause a
panic in vm_page_free_prep(): vm_page_free_object_prep() will subtract
VPRC_OBJREF from the refcount, causing underflow, and
vm_page_free_prep() subsequently calls panic() if the refcount is
non-zero.
Reviewed by: alc, kib
Fixes: fee2a2fa3983 ("Change synchonization rules for vm_page reference counting.")
MFC after: 1 week
[4 lines not shown]
mac_bsdextended: reject negative rule indices in sysctl_rule()
The security.mac.bsdextended.rules.<N> node handler takes N as
`index = name[0]` (a signed int) and only checks
`index >= MAC_BSDEXTENDED_MAXRULES`. A negative index is caught on
the read branch, but the write-only add and delete
branches proceed to `rules[index]` unconditionally.
Reject `index < 0` alongside the existing upper-bound check.
Submitted by calif.io for the OpenAI Patch The Planet program
Signed-off-by: Andrew Griffiths <andrew at calif.io>
Reviewed by: markj
MFC after: 2 weeks
(cherry picked from commit 5d0b87669a91244e330a35fc973e6c60f92f6d1f)
ppp: Fix address leaks
Avoid printing timer addresses, so as to not divulge information about
the address space layout.
In ip.c, print the actual SPI instead of a pointer to the SPI in the
header buffer.
When debug logging is enabled, don't leak pointers when logging function
arguments or return values.
Reported by: Reo Shiseki
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
(cherry picked from commit c91777f23a3b13649cdf303515ee45a04c788af3)
vm_page: Fix the error path in vm_page_alloc_contig_domain()
If we are inserting a run of pages into a VM object and fail at some
point due to a memory allocation failure, we have to free all of the
pages in the run. We do that by resetting some fields and calling
vm_page_free_toq() on each page; this removes the page from the object
and frees it back to the buddy allocator.
If the page is supposed to be wired, we reset the reference count, but
this was done incorrectly: the VPRC_OBJREF flag must be retained as the
page still belongs to an object. Resetting it to zero will cause a
panic in vm_page_free_prep(): vm_page_free_object_prep() will subtract
VPRC_OBJREF from the refcount, causing underflow, and
vm_page_free_prep() subsequently calls panic() if the refcount is
non-zero.
Reviewed by: alc, kib
Fixes: fee2a2fa3983 ("Change synchonization rules for vm_page reference counting.")
MFC after: 1 week
[4 lines not shown]
ppp: Fix address leaks
Avoid printing timer addresses, so as to not divulge information about
the address space layout.
In ip.c, print the actual SPI instead of a pointer to the SPI in the
header buffer.
When debug logging is enabled, don't leak pointers when logging function
arguments or return values.
Reported by: Reo Shiseki
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
(cherry picked from commit c91777f23a3b13649cdf303515ee45a04c788af3)
posixshm: Fix a double unlock in shm_partial_page_invalidate()
For some reason, shm_partial_page_invalidate() unlocks the object upon
an error, but its callers don't expect this. Don't do any special error
handling. Keep the subroutine anyway since the name is a bit clearer
than vm_page_grab_zero_partial().
While here, normalize the object pointer used for locking in
shm_deallocate().
Reviewed by: kib
Fixes: 454bc887f250 ("uipc_shm: Implements fspacectl(2) support")
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D59877
(cherry picked from commit ba974faaf30b74472acc4f0dc5853a22d43951f2)