]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
7 months agofflush: correct buffer handling in __sflush
Dag-Erling Smørgrav [Thu, 3 Aug 2023 15:13:45 +0000 (15:13 +0000)]
fflush: correct buffer handling in __sflush

This fixes CVE-2014-8611 correctly.

The commit that purported to fix CVE-2014-8611 (805288c2f062) only hid
it behind another bug.  Two later commits, 86a16ada1ea6 and
44cf1e5eb470, attempted to address this new bug but mostly just confused
the issue.  This commit rolls back the three previous changes and fixes
CVE-2014-8611 correctly.

The key to understanding the bug (and the fix) is that `_w` has
different meanings for different stream modes.  If the stream is
unbuffered, it is always zero.  If the stream is fully buffered, it is
the amount of space remaining in the buffer (equal to the buffer size
when the buffer is empty and zero when the buffer is full).  If the
stream is line-buffered, it is a negative number reflecting the amount
of data in the buffer (zero when the buffer is empty and negative buffer
size when the buffer is full).

At the heart of `fflush()`, we call the stream's write function in a
loop, where `t` represents the return value from the last call and `n`
the amount of data that remains to be written.  When the write function
fails, we need to move the unwritten data to the top of the buffer
(unless nothing was written) and adjust `_p` (which points to the next
free location in the buffer) and `_w` accordingly.  These variables have
already been set to the values they should have after a successful
flush, so instead of adjusting them down to reflect what was written,
we're adjusting them up to reflect what remains.

The bug was that while `_p` was always adjusted, we only adjusted `_w`
if the stream was fully buffered.  The fix is to also adjust `_w` for
line-buffered streams.  Everything else is just noise.

Fixes: 805288c2f062
Fixes: 86a16ada1ea6
Fixes: 44cf1e5eb470
Sponsored by: Klara, Inc.

7 months agolinuxkpi linux_work: use 'true' instead of 'non-zero'
Konstantin Belousov [Tue, 7 Nov 2023 10:56:39 +0000 (12:56 +0200)]
linuxkpi linux_work: use 'true' instead of 'non-zero'

Submitted by: markj
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D42468

7 months agolinuxkpi: races between linux_queue_delayed_work_on() and linux_cancel_delayed_work_s...
Konstantin Belousov [Sat, 4 Nov 2023 07:45:48 +0000 (09:45 +0200)]
linuxkpi: races between linux_queue_delayed_work_on() and linux_cancel_delayed_work_sync()

1. Suppose that linux_queue_delayed_work_on() is called with
   non-zero delay and found the work.state WORK_ST_IDLE. It
   resets the state to WORK_ST_TIMER and locks timer.mtx. Now, if
   linux_cancel_delayed_work_sync() was also called meantime, read
   state as WORK_ST_TIMER and already taken the mutex, it is executing
   callout_stop() on non-armed callout. Then linux_queue_delayed_work_on()
   continues and schedules callout.  But the return value from cancel() is
   false, making it possible to the requeue from callback to slip in.

2. If linux_cancel_delayed_work_sync() returned true, we need to cancel
   again.  The requeue from callback could have revived the work.

The end result is that we schedule callout that might be freed, since
cancel_delayed_work_sync() claims that everything was stopped.  This
contradicts the way the KPI is used in Linux, where consumers expect
that cancel_delayed_work_sync() is reliable on its own.

Reviewed by: markj
Discussed with: bz
Sponsored by: NVidia networking
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D42468

7 months agokern linker: Do not retry loading modules on EEXIST
Zhenlei Huang [Tue, 7 Nov 2023 04:45:25 +0000 (12:45 +0800)]
kern linker: Do not retry loading modules on EEXIST

LINKER_LOAD_FILE() calls linker_load_dependencies() which will return
EEXIST in case the module to be loaded has already been compiled into
the kernel. Since the format of the module is now recognized then there
is no need to retry loading with a different linker, otherwise the
userland will get misleading error number ENOEXEC.

PR: 274936
Reviewed by: dfr
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D42474

7 months agonfscl: newnfs_copycred() cannot be called when a mutex is held
Rick Macklem [Mon, 6 Nov 2023 22:25:30 +0000 (14:25 -0800)]
nfscl: newnfs_copycred() cannot be called when a mutex is held

Since newnfs_copycred() calls crsetgroups() which in turn calls
crextend() which might do a malloc(M_WAITOK), newnfs_copycred()
cannot be called with a mutex held.  Fortunately, the malloc()
call is rarely done, since XU_GROUPS is 16 and the NFS client
uses a maximum of 17 (only 17 groups will cause the malloc() to
be called).  Further, it is only a problem if the malloc() tries
to sleep().  As such, this bug does not seem to have caused
problems in practice.

This patch fixes the one place in the NFS client where
newnfs_copycred() is called while a mutex is held by moving the
call to after where the mutex is released.

Found by inspection while working on an experimental patch.

MFC after: 2 weeks

7 months agopf: expose more syncookie state information to userspace
Kristof Provost [Mon, 6 Nov 2023 21:20:32 +0000 (22:20 +0100)]
pf: expose more syncookie state information to userspace

Allow userspace to retrieve low and high water marks, as well as the
current number of half open states.

MFC after: 1 week
Sponsored by: Modirum MDPay

7 months agonanobsd: fix typo in utility function call name
Guido Falsi [Mon, 6 Nov 2023 21:18:35 +0000 (22:18 +0100)]
nanobsd: fix typo in utility function call name

Approved by: imp
Differential Revision: https://reviews.freebsd.org/D42475

7 months agoSkip sys.netinet6.frag6.frag6_19.frag6_19 in CI
Li-Wen Hsu [Mon, 6 Nov 2023 20:59:24 +0000 (04:59 +0800)]
Skip sys.netinet6.frag6.frag6_19.frag6_19 in CI

This test case is unreliable in CI environment.

PR: 274941
Sponsored by: The FreeBSD Foundation

7 months agocrashinfo: Get local variable values in the gdb backtrace
Mark Johnston [Mon, 6 Nov 2023 19:59:10 +0000 (14:59 -0500)]
crashinfo: Get local variable values in the gdb backtrace

This should make crash reports a bit more useful without having to ask
for additional information.

Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42465

7 months agoe6000sw: Fix locking in miibus_{read,write}reg implementations
Mark Johnston [Mon, 6 Nov 2023 19:57:56 +0000 (14:57 -0500)]
e6000sw: Fix locking in miibus_{read,write}reg implementations

Commit 469290648005e13b819a19353032ca53dda4378f made e6000sw's
implementation of miibus_(read|write)reg assume that the softc lock is
held.  I presume that is to avoid lock recursion in e6000sw_attach() ->
e6000sw_attach_miibus() -> mii_attach() -> MIIBUS_READREG().

However, the lock assertion in e6000sw_readphy_locked() can fail if a
different driver uses the interface to probe registers.  Work around the
problem by providing implementations which lock the softc if it is not
already locked.

PR: 274795
Fixes: 469290648005 ("e6000sw: add readphy and writephy wrappers")
Reviewed by: kp, imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42466

7 months agocam: Remove left-over sys/cdefs.h in sys/cam
Warner Losh [Mon, 6 Nov 2023 19:20:23 +0000 (12:20 -0700)]
cam: Remove left-over sys/cdefs.h in sys/cam

These weren't removed when $FreeBSD$ was removed. They aren't needed and
now are a style(9) nonconformity.

Sponsored by: Netflix

7 months agocam: Add nvme error devctl publishing
Warner Losh [Mon, 6 Nov 2023 19:09:31 +0000 (12:09 -0700)]
cam: Add nvme error devctl publishing

Start reporting nvme errors from devices, like we report ata and scsi
errors.

Sponsored by: Netflix
Reviewed by: mav, jhb
Differential Revision: https://reviews.freebsd.org/D41086

7 months agoyppush: Remove return statement at the end of void functions
Elyes Haouas [Fri, 3 Nov 2023 17:47:17 +0000 (18:47 +0100)]
yppush: Remove return statement at the end of void functions

Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
7 months agorpcbind: Remove return statement at the end of void functions
Elyes Haouas [Fri, 3 Nov 2023 17:47:01 +0000 (18:47 +0100)]
rpcbind: Remove return statement at the end of void functions

Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
7 months agorpc.ypxfrd: Remove return statement at the end of void functions
Elyes Haouas [Fri, 3 Nov 2023 17:46:38 +0000 (18:46 +0100)]
rpc.ypxfrd: Remove return statement at the end of void functions

Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
7 months agoypserv: Remove return statement at the end of void functions
Elyes Haouas [Fri, 3 Nov 2023 17:46:16 +0000 (18:46 +0100)]
ypserv: Remove return statement at the end of void functions

Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
7 months agokeyserv: Remove return statement at the end of void functions
Elyes Haouas [Fri, 3 Nov 2023 17:45:55 +0000 (18:45 +0100)]
keyserv: Remove return statement at the end of void functions

Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
7 months agortadvd: Remove return statement at the end of void functions
Elyes Haouas [Fri, 3 Nov 2023 17:44:50 +0000 (18:44 +0100)]
rtadvd: Remove return statement at the end of void functions

Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
7 months agocam: Minor opt_cam.h cleanup
Warner Losh [Mon, 6 Nov 2023 17:47:15 +0000 (10:47 -0700)]
cam: Minor opt_cam.h cleanup

sys/cam/cam.h includes opt_cam.h, so none of the clients need to do
this. cam.h does all the right dancing to conditionally include
opt_cam.h only when it makes sense. It generally only matters when
cam_debug.h is included (it must be included before that). Many of the
stray opt_cam.h includes were after cam_debug.h which would be a problem
were it not included in cam/cam.h. The other users of CAM options that
aren't debug all already include cam/cam.h.

Also trim unneeded sys/cdefs.h files from the files touched.

Sponsored by: Netflix

7 months agopmap_kextract(9): some additions
Mitchell Horne [Mon, 6 Nov 2023 16:54:18 +0000 (12:54 -0400)]
pmap_kextract(9): some additions

Mainly, provide a little more detail on the caller's responsibilities.

Suggested by: kib, jhb
Reviewed by: kib, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42458

7 months agonvme: Introduce longer timeouts for admin queue
Alexander Motin [Mon, 6 Nov 2023 16:05:48 +0000 (11:05 -0500)]
nvme: Introduce longer timeouts for admin queue

KIOXIA CD8 SSDs routinely take ~25 seconds to delete non-empty
namespace.  In some cases like hot-plug it takes longer, triggering
timeout and controller resets after just 30 seconds. Linux for many
years has separate 60 seconds timeout for admin queue.  This patch
does the same.  And it is good to be consistent.

Sponsored by: iXsystems, Inc.
Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42454

7 months agoFix up the vm_guest_sysctl_names size assert.
Mateusz Guzik [Mon, 6 Nov 2023 15:38:06 +0000 (15:38 +0000)]
Fix up the vm_guest_sysctl_names size assert.

As VM_LAST was included in the array, the size check had to always pass.

While here modernize the assert itself.

Sponsored by: Rubicon Communications, LLC ("Netgate")

7 months agoRELNOTES: mention bb830e346bd5
Christos Margiolis [Mon, 6 Nov 2023 15:36:39 +0000 (17:36 +0200)]
RELNOTES: mention bb830e346bd5

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D42479

7 months agoRELNOTES: bump version to 15.0
Christos Margiolis [Mon, 6 Nov 2023 15:36:33 +0000 (17:36 +0200)]
RELNOTES: bump version to 15.0

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D42478

7 months agoloader.efi.8: Fix style warnings
Benedict Reuschling [Mon, 6 Nov 2023 14:45:20 +0000 (14:45 +0000)]
loader.efi.8: Fix style warnings

This is a follow-up commit to bce728719e7f57272d99b6d039f10b4c636fa024
to address mandoc(1) warnings.

7 months agolibpfctl: handle the 'pfctl' netlink family not being supported
Kristof Provost [Mon, 6 Nov 2023 10:57:35 +0000 (11:57 +0100)]
libpfctl: handle the 'pfctl' netlink family not being supported

If we fail to find the pfctl family we should not attempt to make the
call. That means that either pf is not loaded, or it's a very old (i.e.
pre-netlink) version.

Reported by: manu
Sponsored by: Rubicon Communications, LLC ("Netgate")

7 months agoAdd paragraph documenting loader.env functionlity
Guido Falsi [Mon, 6 Nov 2023 12:11:26 +0000 (13:11 +0100)]
Add paragraph documenting loader.env functionlity

Approved by: docs (carlavilla)
Differential Revision: https://reviews.freebsd.org/D42476

7 months agoxen-netfront: attempt to make cleanup idempotent
Roger Pau Monné [Fri, 3 Nov 2023 09:28:16 +0000 (10:28 +0100)]
xen-netfront: attempt to make cleanup idempotent

Current cleanup code assumes that all the fields are allocated and/or setup by
the time cleanup is called, but this is not always true: a failure in mid-setup
of the device will cause the functions to be called with possibly uninitialized
fields.

Fix the functions to cope with such sate, while also attempting to make the
cleanup idempotent.

Finally fix an error path during setup that would not mark the device as
closed, and hence prevents the kernel from finishing booting.

Fixes: 96375eac945c ("xen-netfront: add multiqueue support")
Sponsored by: Citrix Systems R&D

7 months agoxen: fix initialization of grant table frame array
Roger Pau Monné [Thu, 2 Nov 2023 17:23:25 +0000 (18:23 +0100)]
xen: fix initialization of grant table frame array

The current sizing of the array used to store grant table frames is broken, as
the calculation:

       max_nr_glist_frames = (boot_max_nr_grant_frames *
                              GREFS_PER_GRANT_FRAME /
                              (PAGE_SIZE / sizeof(grant_ref_t)));

Is plain bogus, for once grant_ref_t is the type of the grant reference, but
not the entry used to store such references in the grant frames.  But even if
the above calculation is switched to use grant_entry_v1_t, it would end up as:

       max_nr_glist_frames = (boot_max_nr_grant_frames *
                              (PAGE_SIZE / sizeof(grant_entry_v1_t)) /
                              (PAGE_SIZE / sizeof(grant_entry_v1_t)));

Which is pointless (note GREFS_PER_GRANT_FRAME has been expanded to (PAGE_SIZE
/ sizeof(grant_entry_v1_t))).

Just use boot_max_nr_grant_frames directly to size the grant table frames
array.

Fixes: 30d1eefe3937 ("Import OS interfaces to Xen services.")
Sponsored by: Citrix Systems R&D

7 months agosctp: minor clean
Michael Tuexen [Mon, 6 Nov 2023 10:04:15 +0000 (11:04 +0100)]
sctp: minor clean

No functional change intended.
MFC after: 1 week

7 months agoshare/mk: Fix .TARGET override documentation
Ka Ho Ng [Sun, 5 Nov 2023 21:27:59 +0000 (16:27 -0500)]
share/mk: Fix .TARGET override documentation

Fixes: 48da57b47ff14
Sponsored by: Juniper Networks, Inc.
MFC after: 3 days
Reviewed by: imp, delphij, emaste
Differential Revision: https://reviews.freebsd.org/D42469

7 months agoif_tuntap: trigger the bpf hook on transmitting for the tap interface
Michael Tuexen [Sun, 5 Nov 2023 19:32:46 +0000 (20:32 +0100)]
if_tuntap: trigger the bpf hook on transmitting for the tap interface

The tun interface triggers the bpf hook when a packet is transmitted,
the tap interface triggers it when the packet is read from the
character device. This is inconsistent.
So fix the tap device such that it behaves like the tun device.
This is needed for adding support for the tap device to packetdrill.

Reviewed by: kevans, rscheff
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D42467

7 months agoudplite: make socketoption available on IPv6 sockets
Michael Tuexen [Sun, 5 Nov 2023 14:28:54 +0000 (15:28 +0100)]
udplite: make socketoption available on IPv6 sockets

This patch allows the IPPROTO_UDPLITE-level socket options
UDPLITE_SEND_CSCOV and UDPLITE_RECV_CSCOV to be used on
AF_INET6 sockets in addition to AF_INET sockets.

Reviewed by: ae, rscheff
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42430

7 months agotcp rack: remove references to rb trees
Michael Tuexen [Sun, 5 Nov 2023 14:21:06 +0000 (15:21 +0100)]
tcp rack: remove references to rb trees

The references should have been removed in
https://cgit.freebsd.org/src/commit/?id=030434acaf4631c4e205f8bccedcc7f845cbfcbf

Reviewed by: rscheff, zlei
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D42386

7 months agogrep: don't rely on implementation-defined malloc(0) behavior
Kyle Evans [Sun, 5 Nov 2023 02:08:36 +0000 (21:08 -0500)]
grep: don't rely on implementation-defined malloc(0) behavior

The very few places that rely on malloc/calloc of a zero-size region
won't attempt to dereference it, so just return NULL rather than rolling
the dice with the underlying malloc implementation.

Reported by: brooks, Shawn Webb

7 months agocrashinfo: remove unused /usr/bin/gdb support
Ed Maste [Tue, 8 Mar 2022 14:32:24 +0000 (09:32 -0500)]
crashinfo: remove unused /usr/bin/gdb support

We have not had gdb 6.1 in the base system for some time; there is no
need to check for it.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34478

7 months agomountd: Add support for spaces in exported directories
Dan Mcgregor [Sat, 4 Nov 2023 22:07:56 +0000 (15:07 -0700)]
mountd: Add support for spaces in exported directories

The previous code would correctly parse strings including quotation
marks (") or backslash (/), but the tests when creating the export
includes them in the final string. This prevents exporting paths
with embedded spaces, for example "/exports/with space". Trying
results in log lines resembling:

mountd[1337]: bad exports list line '/exports/with\ space':
    /exports/with\ space: lstat() failed: No such file or directory.

Turns out that when creating its exports list, zfs escapes strings
in a format compatible with vis(3). Since I expect that zfs sharenfs
is the dominating use case for generating an exports list, use
strunvis(3) to parse the export path. The result is lines like the
following allowing spaces:

/exports/with\040space -network 192.168.0 -mask 255.255.255.0

A man page update will be done as a separate commit.

MFC after: 1 month
Reviewed by: rmacklem
Differential Revision: https://reviews.freebsd.org/D42432

7 months agotty: set IUTF8 by default
Christos Margiolis [Sat, 4 Nov 2023 20:31:47 +0000 (22:31 +0200)]
tty: set IUTF8 by default

128f63cedc14 and 9e589b093857 added proper UTF-8 backspacing handling in
the tty(4) driver, which is enabled by setting the new IUTF8 flag
through stty(1). Since the default locale is UTF-8, and the feature
itself is important enough, enable IUTF8 by default.

Related discussion:
https://lists.freebsd.org/archives/freebsd-arch/2023-November/000534.html

Reviewed by: imp, bojan.novkovic_fer.hr
Differential Revision: https://reviews.freebsd.org/D42464

7 months agobsd.progs.mk must pass META_XTRAS to gendirdeps.mk
Simon J. Gerraty [Sat, 4 Nov 2023 17:16:33 +0000 (10:16 -0700)]
bsd.progs.mk must pass META_XTRAS to gendirdeps.mk

The indirection used by bsd.progs.mk is setting META_XTRAS
means the value needs to be passed in the environment to
gendirdeps.mk, as any expansion before then will be empty.

Remove a now misleading comment from bsd.progs.mk
before it includes bsd.prog.mk

Update gendirdeps.mk to accommodate this.

Reviewed by: stevek

7 months agovfs_lookup_cross_mount(): restore previous do...while loop
Jason A. Harmening [Sat, 4 Nov 2023 16:56:45 +0000 (11:56 -0500)]
vfs_lookup_cross_mount(): restore previous do...while loop

When the cross-mount walking logic in vfs_lookup() was factored into
a separate function, the main cross-mount traversal loop was changed
from a do...while loop conditional on the current vnode having
VIRF_MOUNTPOINT set to an unconditional for(;;) loop.  For the
unionfs 'crosslock' case in which the vnode may be re-locked, this
meant that continuing the loop upon finding inconsistent
v_mountedhere state would no longer branch to a check that the vnode
is in fact still a mountpoint.  This would in turn lead to over-
iteration and, for INVARIANTS builds, a failed assert on the next
iteration.

Fix this by restoring the previous loop behavior.

Reported by: pho
Tested by: pho
Fixes: 80bd5ef0702562c546fa1717e8fe221058974eac
MFC after: 1 week

7 months agostand/zfs: Remove one more read-compatible feature
Alexander Motin [Sat, 4 Nov 2023 17:04:33 +0000 (13:04 -0400)]
stand/zfs: Remove one more read-compatible feature

This feature is marked as ZFEATURE_FLAG_READONLY_COMPAT and so
irrelevant for read-only pool imports by the loader:

"com.delphix:spacemap_v2"

This should cause no functional changes, just a code cleanup.

I'm sorry, missed it in previous commit.

MFC after: 2 months

7 months agoFix typo
Konstantin Belousov [Sat, 4 Nov 2023 16:48:25 +0000 (18:48 +0200)]
Fix typo

Fixes: 967022aa5aa60a18764a668ae0fb78e39e16fa8e
MFC after: 1 week

7 months agoarm64: improve UVA layout for 32bit processes
Konstantin Belousov [Wed, 25 Oct 2023 01:03:09 +0000 (04:03 +0300)]
arm64: improve UVA layout for 32bit processes

Add compat.aarch32 tunables for maxssiz, maxdsiz, and maxvmem.
Set the default values same as for amd64.
Fix freebsd32 sysentvec on arm64 to provide sv_maxssiz, and sv_fixlimit.

PR: 274705
Reviewed by: markj
Tested by: fuz
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D42451

7 months agostand/zfs: Remove read-compatible features
Alexander Motin [Sat, 4 Nov 2023 16:26:25 +0000 (12:26 -0400)]
stand/zfs: Remove read-compatible features

These features are marked as ZFEATURE_FLAG_READONLY_COMPAT and so
irrelevant for read-only pool imports by the loader:

"com.datto:resilver_defer",
"com.delphix:obsolete_counts",
"com.delphix:spacemap_histogram",
"com.delphix:zpool_checkpoint",
"com.intel:allocation_classes",
"org.zfsonlinux:allocation_classes"

This should cause no functional changes, just a code cleanup.

MFC after: 2 months

7 months agoshare/examples/etc/make.conf: Add AMD Zen 4 to list
Daniel Engberg [Sat, 4 Nov 2023 15:28:46 +0000 (16:28 +0100)]
share/examples/etc/make.conf: Add AMD Zen 4 to list

Add AMD Zen 4 (znver4) to the list of valid "Intel x86 CPU types"

Reviewed by: emaste
Approved by: emaste
Differential Revision: https://reviews.freebsd.org/D41518

7 months agoreboot: Avoid unlocking Giant if the scheduler is stopped
Mark Johnston [Sat, 4 Nov 2023 14:48:58 +0000 (10:48 -0400)]
reboot: Avoid unlocking Giant if the scheduler is stopped

When the scheduler is stopped, mtx_unlock() turns into a no-op, so the
loop

    while (mtx_owned(&Giant))
    mtx_unlock(&Giant);

runs forever if the calling thread has Giant locked.

Reviewed by: mhorne
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D42460

7 months agopfsync: Avoid transmitting uninitialized bytes in pfsync_sendout()
Mark Johnston [Sat, 4 Nov 2023 14:28:24 +0000 (10:28 -0400)]
pfsync: Avoid transmitting uninitialized bytes in pfsync_sendout()

When IPv6 support was added to pfsync, PFSYNC_MINPKT increased such that
we always allocate enough space for either IPv4 or IPv6 headers.  IPv6
headers are 20 bytes larger than IPv4 headers.  When pfsync_sendout()
does its thing, it ends up allocating enough space for either; thus when
transmitting an IPv4 packet, the last 20 bytes of the buffer are left
uninitialized.

Fix the problem by stashing the length in a local variable and adjusting
it depending on the address family in use.

While here, just zero the entire buffer in one go rather than being
careful to initialize each subheader.  This seems simpler and less error
prone.

Reported by: KMSAN
Reviewed by: kp
Fixes: 6fc7fc2dbb2b ("pfsync: transport over IPv6")
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D42461

7 months agokmsan: Correct the origin address in kmsan_shadow_check()
Mark Johnston [Fri, 3 Nov 2023 19:37:09 +0000 (15:37 -0400)]
kmsan: Correct the origin address in kmsan_shadow_check()

Otherwise a KMSAN report (which panics the system by default) could
trigger a recursive panic.

MFC after: 1 week
Fixes: ca6cd604c8fc ("kmsan: Use the correct origin bytes in kmsan_check_arg()")

7 months agoif_tuntap: improve code consistency
Michael Tuexen [Sat, 4 Nov 2023 09:22:42 +0000 (10:22 +0100)]
if_tuntap: improve code consistency

No functional change intended.

Reviewed by: rscheff
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D42462

7 months agocommitters-src: Add Jake Freeland
Jake Freeland [Fri, 3 Nov 2023 16:14:21 +0000 (11:14 -0500)]
committers-src: Add Jake Freeland

Add myself to the active src committers list and document my
mentor/mentee relationships.

7 months agortld/arm: fix initial-exec (IE) thread-local storage relocation
R. Christian McDonald [Fri, 3 Nov 2023 12:56:58 +0000 (13:56 +0100)]
rtld/arm: fix initial-exec (IE) thread-local storage relocation

net/frr[89] revealed an interesting edge-case on arm when dynamically
linking a shared library that declares more than one static TLS variable
with at least one  using the "initial-exec" TLS model. In the case
of frr[89], this library was libfrr.so which essentially does the
following:

#include <stdio.h>

#include "lib.h"

static __thread int *a
__attribute__((tls_model("initial-exec")));

void lib_test()
{
static __thread int b = -1;

printf("&a = %p\n", &a);
printf(" a = %p\n", a);

printf("\n");

printf("&b = %p\n", &b);
printf(" b = %d\n", b);
}

Allocates a file scoped `static __thread` pointer with
tls_model("initial-exec") and later a block scoped TLS int. Notice in
the above minimal reproducer, `b == -1`. The relocation process does
the wrong thing and ends up pointing both `a` and `b` at the same place
in memory.

The output of the above in the broken state is:

&a = 0x4009c018
 a = 0xffffffff

&b = 0x4009c018
 b = -1

With the patch applied, the output becomes:

&a = 0x4009c01c
 a = 0x0

&b = 0x4009c018
 b = -1

Reviewed by: kib
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D42415/

7 months agonet80211: add ieee80211_add_vhtcap_ch()
Bjoern A. Zeeb [Thu, 26 Oct 2023 20:55:59 +0000 (20:55 +0000)]
net80211: add ieee80211_add_vhtcap_ch()

Add an implementation of ieee80211_add_vhtcap() which works based on
information derived from the vap (and possibly channel/band but we do
not support that yet in net80211).  This is needed for scans request
information in LinuxKPI at times before we have a BSS.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: adrian, cc
Differential Revision: https://reviews.freebsd.org/D42422

7 months agonet80211: migrate ic_vhtcaps, ic_vht_mcsinfo, ic_flags_vht
Bjoern A. Zeeb [Fri, 27 Oct 2023 18:44:02 +0000 (18:44 +0000)]
net80211: migrate ic_vhtcaps, ic_vht_mcsinfo, ic_flags_vht

Like for the VAP rename ic_flags_vht to ic_vht_flags for consistency to
keep "VHT" fields together and merge ic_vhtcaps and ic_vht_mcsinfo
into struct ieee80211_vht_cap ic_vht_cap.

While the structure layout changes no other functional changes intended.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: adrian, cc
Differential Revision: https://reviews.freebsd.org/D42421

7 months agonet80211: combine iv_vhtcaps and iv_vht_mcsinfo
Bjoern A. Zeeb [Fri, 27 Oct 2023 18:33:22 +0000 (18:33 +0000)]
net80211: combine iv_vhtcaps and iv_vht_mcsinfo

The iv_vhtcaps and iv_vht_mcsinfo fields together form
struct ieee80211_vht_cap so combine them into one field in the VAP
and keep the information together.

While the structure layout changes no other functional changes intended.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: adrian, cc
Differential Revision: https://reviews.freebsd.org/D42420

7 months agonet80211: rename iv_flags_vht to iv_vht_flags
Bjoern A. Zeeb [Fri, 27 Oct 2023 18:18:24 +0000 (18:18 +0000)]
net80211: rename iv_flags_vht to iv_vht_flags

While the flag field is internal start naming it as well as "iv_vht*"
so we keep all "VHT" fields together.  This breaks with what was done
done for HT but with HE, EHT, .. coming one day seems the more logic
choice.

No functional changes intended.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: adrian, cc
Differential Revision: https://reviews.freebsd.org/D42419

7 months agoLinuxKPI: 802.11: zero-pad debug flags
Bjoern A. Zeeb [Sat, 28 Oct 2023 18:43:43 +0000 (18:43 +0000)]
LinuxKPI: 802.11: zero-pad debug flags

Write the debug flags as full 32bit hex numbers to have a better
view on them.

No functional changes.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: cc, emaste
Differential Revision: https://reviews.freebsd.org/D42426

7 months agoLinuxKPI: 802.11: deal with scan_ie_len
Bjoern A. Zeeb [Fri, 27 Oct 2023 20:41:43 +0000 (20:41 +0000)]
LinuxKPI: 802.11: deal with scan_ie_len

We only need to reserve the extra space for DSSS if
NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES is set, so add the conditional.
Also add checks in case scan_ie_len will grow beyond the maximum.
Given this is currently unlikely, leave the cleanup for later as
some other restructuring should be done first.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: cc
Differential Revision: https://reviews.freebsd.org/D42425

7 months agoLinuxKPI: 802.11: fix ieee80211_add_channel_cbw() argument
Bjoern A. Zeeb [Thu, 26 Oct 2023 00:11:43 +0000 (00:11 +0000)]
LinuxKPI: 802.11: fix ieee80211_add_channel_cbw() argument

Fix the last argument passed to ieee80211_add_channel_cbw() in
lkpi_ic_getradiocaps() for both 2Ghz and 5Ghz bands.
We passed in the unmodified version rather than the adjusted version
based on the per-band channel information possibly leaving
ieee80211_channel_flags enabled which should not be.

So far this should not have made a difference given we did not enable
HT or VHT.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: cc
Differential Revision: https://reviews.freebsd.org/D42424

7 months agoLinuxKPI: 802.11: error on state transition failure
Bjoern A. Zeeb [Wed, 25 Oct 2023 22:29:35 +0000 (22:29 +0000)]
LinuxKPI: 802.11: error on state transition failure

The state transition failures we were seeing in the early days are
solved.  If we now experience one stop processing before passing
over to net80211 (sta_newstate()) and before updating iv_state on
the vap.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: cc
Differential Revision: https://reviews.freebsd.org/D42423

7 months agoTrack upstream project rename in contrib/blocklistd
Ed Maste [Tue, 11 Oct 2022 19:27:51 +0000 (15:27 -0400)]
Track upstream project rename in contrib/blocklistd

Upstream is now https://github.com/zoulasc/blocklist/.  Rename the
contrib directory and update Makefiles to match, in advance of the next
vendor branch update.

Sponsored by: The FreeBSD Foundation

7 months agopowerpc: Fix inconsistent Altivec handling in set_mcontext
Shawn Anastasio [Fri, 3 Nov 2023 17:40:18 +0000 (14:40 -0300)]
powerpc: Fix inconsistent Altivec handling in set_mcontext

When support for fpu_kern_enter/fpu_kern_leave was added to powerpc,
set_mcontext was updated to handle Altivec state restoration in the same
way that the FPU state by lazily restoring the context on the first
trap. However the function was not correctly updated to unconditionally
clear the PCB_VEC and PSL_VEC bits from the pcb's flags and srr1
respectively which can sometimes result in a mismatch between a
process's MSR[VEC] state and its pcb_flags.

Fix this by simply clearing the VEC flags unconditionally in
set_mcontext, which is already done for FPU/VSX.

Fixes: a6662c37b6ffe ("powerpc: Implement fpu_kern_enter/fpu_kern_leave")
Reviewed by: alfredo
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D42417

7 months agofflush: Split a temporary variable in two.
Dag-Erling Smørgrav [Thu, 3 Aug 2023 15:08:03 +0000 (15:08 +0000)]
fflush: Split a temporary variable in two.

It is clearer to avoid reusing temporary variables for different
purposes.

Sponsored by: Klara, Inc.

7 months agopci_vendors: update to 2023-09-22
Baptiste Daroussin [Fri, 3 Nov 2023 16:32:35 +0000 (17:32 +0100)]
pci_vendors: update to 2023-09-22

7 months agocam: Minor tidying up the cam module Makefile
Warner Losh [Thu, 2 Nov 2023 20:41:17 +0000 (14:41 -0600)]
cam: Minor tidying up the cam module Makefile

One src per line + sorting.

Sponsored by: Netflix

7 months agocam: Make cam_debug macros atomic
Warner Losh [Thu, 2 Nov 2023 20:41:09 +0000 (14:41 -0600)]
cam: Make cam_debug macros atomic

The CAM_DEBUG* macros use multiple printfs to dump the data. This is
suboptimal when tracing things that produce even a moderate amount since
it gets intertwingled. I can't even turn on tracing with a 24-disk HBA
on boot without it getting messed up. Add helper routines to work around
clang's over-use of the stack: that way we only pay the stack penalty
when a trace hits.

Sponsored by: Netflix
Reviewed by: ken, mav
Differential Revision: https://reviews.freebsd.org/D42411

7 months agompsutil: Add higher PCIe speeds.
Alexander Motin [Fri, 3 Nov 2023 15:49:59 +0000 (11:49 -0400)]
mpsutil: Add higher PCIe speeds.

There are already PCIe Gen4 HBAs, reported improperly.

MFC after: 1 week

7 months agoriscv: Update a variable name to match a comment
Mark Johnston [Fri, 3 Nov 2023 13:34:11 +0000 (09:34 -0400)]
riscv: Update a variable name to match a comment

This makes pmap_insert_pt_page() consistent with arm64 and amd64.  No
functional change intended.

Reported by: alc
Fixes: 7703ac2e983b ("riscv: Port improvements from arm64/amd64 pmaps, part 1")

7 months agopkgbase: force OSVERSION
Baptiste Daroussin [Fri, 3 Nov 2023 08:29:23 +0000 (09:29 +0100)]
pkgbase: force OSVERSION

This is used to the package annotation helping pkg to know about
backward compatibility is set to the version of the packages not
the version of the host building the packages

7 months agopkgbase: set a default set of kernel for when PACKAGE_BUILDING=1
Baptiste Daroussin [Thu, 2 Nov 2023 13:20:11 +0000 (14:20 +0100)]
pkgbase: set a default set of kernel for when PACKAGE_BUILDING=1

PACKAGE_BUILDING is already known in the ports tree as a variable
use to defined when the packages is being actually built in an
automation process, reuse that variable to define the default set
of kernel we plan to build for the default pkgbase.

Reviewed by: manu, jrtc27
Accepted by: manu
MFC After: 1 week
Differential Revision: https://reviews.freebsd.org/D42444

7 months agoASan: Add asan_static to build
SHENG-YI HONG [Fri, 3 Nov 2023 07:02:26 +0000 (15:02 +0800)]
ASan: Add asan_static to build

This is a partial fix for building with -DWITH_ASAN.

Reviewed by: Fangrui Song, dim, emaste
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D42388

7 months agoveriexec: Simplify the initialization of loader tunable
Zhenlei Huang [Fri, 3 Nov 2023 04:08:27 +0000 (12:08 +0800)]
veriexec: Simplify the initialization of loader tunable

The loader tunable 'security.mac.veriexec.block_unlink' has been
already flagged with CTLFLAG_RDTUN, no need to re-fetch it with
TUNABLE_INT_FETCH.

While here move the definition of sysctl knob out of function body,
which is more common in FreeBSD.

No functional change intended.

Reviewed by: stevek
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42132

7 months agoloader: add target for dirdeps build
Stephen J. Kiernan [Thu, 2 Nov 2023 23:33:45 +0000 (19:33 -0400)]
loader: add target for dirdeps build

Update dependencies for the loader variations used for each
architecture.

Reviewed by: sjg
Differential Revision: https://reviews.freebsd.org/D39741

7 months agokrpc: Display stats of TLS usage
Rick Macklem [Thu, 2 Nov 2023 21:07:01 +0000 (14:07 -0700)]
krpc: Display stats of TLS usage

This patch adds some sysctls:
kern.rpc.unenc.tx_msgcnt
kern.rpc.unenc.tx_msgbytes
kern.rpc.unenc.rx_msgcnt
kern.rpc.unenc.rx_msgbytes
kern.rpc.tls.tx_msgcnt
kern.rpc.tls.tx_msgbytes
kern.rpc.tls.rx_msgcnt
kern.rpc.tls.rx_msgbytes
kern.rpc.tls.handshake_success
kern.rpc.tls.handshake_failed
kern.rpc.tls.alerts
which allow a NFS server sysadmin to determine how much
NFS-over-TLS is being used.  A large number of failed
handshakes might also indicate an NFS confirguration
problem.

This patch moves the definition of "kern.rpc" from the
kgssapi module to the krpc module.  As such, both modules
need to be rebuilt from sources.  Since __FreeBSD_version
was bumped yesterday, I will not bump it again.

Suggested by: gwollman
Discussed on: freebsd-current
MFC after: 1 month

7 months agoblacklistd: Handle fds that are pointing to routing sockets
Jose Luis Duran [Wed, 12 Oct 2022 16:14:44 +0000 (13:14 -0300)]
blacklistd: Handle fds that are pointing to routing sockets

If the fd has access to make changes via the routing socket, grant full
permission to make filter changes.

Obtained from: https://github.com/zoulasc/blocklist/commit/1b9475b2c8e0be2b9adc4d88e521ed488ac3c43c

7 months agograid3: Fix teardown races
Mark Johnston [Thu, 2 Nov 2023 18:35:37 +0000 (14:35 -0400)]
graid3: Fix teardown races

Port commit dc399583ba09 from g_mirror, which has an effectively
identical startup sequence.

This fixes a race that was occasionally causing panics during GEOM test
suite runs on riscv.

MFC after: 1 month

7 months agoriscv: Remove unnecessary invalidations in pmap_enter_quick_locked()
Mark Johnston [Thu, 2 Nov 2023 18:34:26 +0000 (14:34 -0400)]
riscv: Remove unnecessary invalidations in pmap_enter_quick_locked()

This function always overwrites an invalid PTE, so if
pmap_try_insert_pv_entry() fails it is certainly not necessary to
invalidate anything, because the PTE has not yet been written by that
point.

It should also not be necessary to invalidate TLBs after overwriting an
invalid entry.  In principle the TLB could cache negative entries, but
then the worst case scenario is a spurious fault.  Since pmap_enter()
does not bother issuing an sfence.vma, pmap_enter_quick_locked() should
behave similarly.

Reviewed by: kib
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D42291

7 months agoriscv: Port improvements from arm64/amd64 pmaps, part 3
Mark Johnston [Thu, 2 Nov 2023 18:34:07 +0000 (14:34 -0400)]
riscv: Port improvements from arm64/amd64 pmaps, part 3

- Let pmap_enter_quick_locked() trigger superpage promotions.

Reviewed by: kib
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D42290

7 months agoriscv: Port improvements from arm64/amd64 pmaps, part 2
Mark Johnston [Thu, 2 Nov 2023 18:33:55 +0000 (14:33 -0400)]
riscv: Port improvements from arm64/amd64 pmaps, part 2

- Give pmap_promote_l2() a return value indicating whether or not
  promotion succeeded.
- Check pmap_ps_enabled() in pmap_promote_l2() rather than making
  callers do it.
- Annotate superpages_enabled with __read_frequently.

Reviewed by: kib
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D42289

7 months agoriscv: Port improvements from arm64/amd64 pmaps, part 1
Mark Johnston [Thu, 2 Nov 2023 18:33:37 +0000 (14:33 -0400)]
riscv: Port improvements from arm64/amd64 pmaps, part 1

- When promoting, do not require that all PTEs all have PTE_A set.
  Instead, record whether they did and store this information in the
  PTP's valid bits.
- Synchronize some comments in pmap_promote_l2().
- Make pmap_promote_l2() scan starting from the end of the 2MB range
  instead of the beginning.  See the commit log for 9d1b7fa31f510 for
  justification of this, which I believe applies here as well.

Reviewed by: kib
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D42288

7 months agoriscv: Retire PMAP_INLINE
Mark Johnston [Thu, 2 Nov 2023 18:33:20 +0000 (14:33 -0400)]
riscv: Retire PMAP_INLINE

pmap_kremove() is not called from within pmap.c, so there's no reason to
inline it.  No functional change intended.

Reviewed by: alc, kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42287

7 months agoamd64: Remove PMAP_INLINE
Mark Johnston [Thu, 2 Nov 2023 18:30:10 +0000 (14:30 -0400)]
amd64: Remove PMAP_INLINE

With clang it expands to "inline"; clang in practice may inline
externally visible functions even without the hint.  So just remove the
hints and let the compiler decide.

No functional change intended.  pmap.o is identical before and after
this patch.

Reviewed by: alc
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42446

7 months agoino64: Fix incremental builds
Warner Losh [Thu, 2 Nov 2023 18:06:19 +0000 (12:06 -0600)]
ino64: Fix incremental builds

These files were removed, so we need to fix up depends for WITHOUT_CLEAN
builds (the default). Metamode builds aren't affected.

Sponsored by: Netflix
Feedback from: emaste
Tested by: Pierre Pronchery
Differential Revision: https://reviews.freebsd.org/D42433

7 months agoarm: Update declarations for arm_dcache_align{,_mask}
Mark Johnston [Thu, 2 Nov 2023 16:23:51 +0000 (12:23 -0400)]
arm: Update declarations for arm_dcache_align{,_mask}

Reported by: Jenkins
Fixes: 3d8f548b9e57 ("uma: Make the cache alignment mask unsigned")

7 months agobhyve(8): fix manpage formatting
Dan McGregor [Thu, 2 Nov 2023 14:50:10 +0000 (10:50 -0400)]
bhyve(8): fix manpage formatting

In commit 67c26eb2a57 a stray ".El" was introduced, breaking
formatting of options.

Reviewed by: corvink, markj
Fixes: 67c26eb2a57c ("bhyve: add cmdline option for TPM emulation")
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D42434

7 months agoEnsure 'struct thread' is aligned to a cache line
Olivier Certner [Fri, 13 Oct 2023 08:52:31 +0000 (10:52 +0200)]
Ensure 'struct thread' is aligned to a cache line

Using the new UMA_ALIGN_CACHE_AND_MASK() facility, which allows to
simultaneously guarantee a minimum of 32 bytes of alignment (the 5 lower
bits are always 0).

For the record, to this day, here's a (possibly non-exhaustive) list of
synchronization primitives using lower bits to store flags in pointers
to thread structures:
- lockmgr, rwlock and sx all use the 5 bits directly.
- rmlock indirectly relies on sx, so can use the 5 bits.
- mtx (non-spin) relies on the 3 lower bits.

Reviewed by:            markj, kib
MFC after:              2 week
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D42266

7 months agouma: Permit specifying max of cache line and some custom alignment
Olivier Certner [Fri, 13 Oct 2023 15:05:34 +0000 (17:05 +0200)]
uma: Permit specifying max of cache line and some custom alignment

To be used for structures for which we want to enforce that pointers to
them have some number of lower bits always set to 0, while still
ensuring we benefit from cache line alignment to avoid false sharing
between structures and fields within the structures (provided they are
properly ordered).

First candidate consumer that comes to mind is 'struct thread', see next
commit.

Reviewed by:            markj, kib
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D42265

7 months agolinuxkpi: dma_get_cache_alignment(): Fix off-by-one result
Olivier Certner [Fri, 13 Oct 2023 15:13:28 +0000 (17:13 +0200)]
linuxkpi: dma_get_cache_alignment(): Fix off-by-one result

Substituting 'uma_align_cache' by the appropriately named accessor
uma_get_cache_align_mask() made apparent that dma_get_cache_alignment()
was off by one, since it was defined to be the mask derived from the
alignment value.

Reviewed by:            markj, bz
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D42264

7 months agouma: New check_align_mask(): Validate alignments (INVARIANTS)
Olivier Certner [Fri, 13 Oct 2023 14:09:51 +0000 (16:09 +0200)]
uma: New check_align_mask(): Validate alignments (INVARIANTS)

New function check_align_mask() asserts (under INVARIANTS) that the mask
fits in a (signed) integer (see the comment) and that the corresponding
alignment is a power of two.

Use check_align_mask() in uma_set_align_mask() and also in uma_zcreate()
to replace the KASSERT() there (that was checking only for a power of
2).

Reviewed by:            kib, markj
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D42263

7 months agouma: Make the cache alignment mask unsigned
Olivier Certner [Fri, 13 Oct 2023 12:49:11 +0000 (14:49 +0200)]
uma: Make the cache alignment mask unsigned

In uma_set_align_mask(), ensure that the passed value doesn't have its
highest bit set, which would lead to problems since keg/zone alignment
is internally stored as signed integers.  Such big values do not make
sense anyway and indicate some programming error.  A future commit will
introduce checks for this case and other ones.

Reviewed by:            kib, markj
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D42262

7 months agoarm: Simplify get_cachetype_cp15()
Olivier Certner [Fri, 13 Oct 2023 12:22:14 +0000 (14:22 +0200)]
arm: Simplify get_cachetype_cp15()

There's no point in setting 'arm_dcache_align_mask' before the
function's end.

Reviewed by:            markj, kib
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D42261

7 months agouma: UMA_ALIGN_CACHE: Resolve the proper value at use point
Olivier Certner [Fri, 13 Oct 2023 12:13:30 +0000 (14:13 +0200)]
uma: UMA_ALIGN_CACHE: Resolve the proper value at use point

Having a special value of -1 that is resolved internally to
'uma_align_cache' provides no significant advantages and prevents
changing that variable to an unsigned type, which is natural for an
alignment mask.  So suppress it and replace its use with a call to
uma_get_align_mask().  The small overhead of the added function call is
irrelevant since UMA_ALIGN_CACHE is only used when creating new zones,
which is not performance critical.

Reviewed by:            markj, kib
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D42259

7 months agouma: Hide 'uma_align_cache'; Create/rename accessors
Olivier Certner [Fri, 13 Oct 2023 09:52:28 +0000 (11:52 +0200)]
uma: Hide 'uma_align_cache'; Create/rename accessors

Create the uma_get_cache_align_mask() accessor and put it in a separate
private header so as to minimize namespace pollution in header/source
files that need only this function and not the whole 'uma.h' header.

Make sure the accessors have '_mask' as a suffix, so that callers are
aware that the real alignment is the power of two that is the mask plus
one.  Rename the stem to something more explicit.  Rename
uma_set_cache_align_mask()'s single parameter to 'mask'.

Hide 'uma_align_cache' to ensure that it cannot be set in any other way
then by a call to uma_set_cache_align_mask(), which will perform sanity
checks in a further commit.  While here, rename it to
'uma_cache_align_mask'.

This is also in preparation for some further changes, such as improving
the sanity checks, eliminating internal resolving of UMA_ALIGN_CACHE and
changing the type of the 'uma_cache_align_mask' variable.

Reviewed by:            markj, kib
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D42258

7 months agoEnsure "init" (PID 1) also executes userret() initially
Olivier Certner [Tue, 10 Oct 2023 17:36:20 +0000 (19:36 +0200)]
Ensure "init" (PID 1) also executes userret() initially

Calling userret() from fork_return() misses the first return to
userspace of the "init" (PID 1) process.  The latter is indeed created
by fork1() followed by a call to cpu_fork_kthread_handler() call that
replaces fork_return() by start_init() as the function to execute after
fork.

A new process' initial return to userspace in the end always happens
through returning from fork_exit(), so move userret() there instead to
fix the omission.

This problem was discovered as part of a revamp of scheduling priorities
that lead to experimenting with asserting and sometimes resetting
priorities in sched_userret(), in the course of which the author
stumbled on panics being triggered only in init() or only in other
processes, depending on the modifications to sched_userret().  This
change currently has no practical effect but will have some in the near
future.

Reviewed by:            markj, kib
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D42257

7 months agopdinit(): Fix comment
Olivier Certner [Tue, 26 Sep 2023 10:26:46 +0000 (12:26 +0200)]
pdinit(): Fix comment

Reviewed by:            markj, kib
MFC after:              1 week
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D42256

7 months agoOpen-code proc_set_cred_init()
Olivier Certner [Mon, 25 Sep 2023 08:48:49 +0000 (10:48 +0200)]
Open-code proc_set_cred_init()

This function is to be called only when initializing a new process (so,
'proc0' and at fork), and not in any other circumstances.  Setting the
process' 'p_ucred' field to the result of crcowget() on the original
credentials is the only thing it does, hiding the fact that the process'
'p_ucred' field is crushed by the call.  Moreover, most of the code it
executes is already encapsulated in crcowget().

To prevent misuse and improve code readability, just remove this
function and replace it with a direct assignment to 'p_ucred'.

Reviewed by:            markj (earlier version), kib
MFC after:              1 week
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D42255

7 months agoHyper-V: vmbus: Add NULL check for vmbus_res
Zhenlei Huang [Thu, 2 Nov 2023 09:07:11 +0000 (17:07 +0800)]
Hyper-V: vmbus: Add NULL check for vmbus_res

QEMU emulates Hyper-V [1] but lacks the emulation for vmbus_res, thus no
coherence information is available. Add NULL check for it and fallback
to no coherence. This will prevent FreeBSD guests from panic on QEMU
with the Hyper-V enlightenment hv-synic enabled.

For real Hyper-V, both gen1 and gen2 have vmbus_res then they are not
affected by this change.

1. https://www.qemu.org/docs/master/system/i386/hyperv.html

PR: 274810
Reviewed by: mhorne, emaste, delphij, whu
Diagnosed by: mhorne
Fixes: e7a9817b8d32 Hyper-V: vmbus: implementat bus_get_dma_tag in vmbus
Insta-MFC approved by: re (delphij) for 14.0-RC4
Differential Revision: https://reviews.freebsd.org/D42414

7 months agohmt(4): Do not require input report HID usages to be a member of TLC
Vladimir Kondratyev [Thu, 2 Nov 2023 06:20:20 +0000 (09:20 +0300)]
hmt(4): Do not require input report HID usages to be a member of TLC

Some touchpads places button usages (in HID report descriptor) in to
the 2-nd level collection rather than in to the top level one. That
confuses current code. Remove collection level check in HID report
descriptor parser to fix device detection.

Reported by: Peter Much <pmc@citylink.dinoex.sub.org>
PR: 267094
MFC after: 1 week

7 months agoevdev: Sync event codes with Linux kernel 6.5
Vladimir Kondratyev [Thu, 2 Nov 2023 06:20:20 +0000 (09:20 +0300)]
evdev: Sync event codes with Linux kernel 6.5

MFC after: 1 week

7 months agocam/ata: Postpone removal of two compat sysctls until 15
Zhenlei Huang [Thu, 2 Nov 2023 05:14:40 +0000 (13:14 +0800)]
cam/ata: Postpone removal of two compat sysctls until 15

Prefer UNMAPPEDIO and ROTATING from flags sysctl. See
 1. aeab0812e68c (Add flags sysctl to ada)
 2. cf3ff63e55e4 (Convert unmappedio over to a flag)
 3. 96eb32bf0f5a (Convert rotating to a flag bit)

Reviewed by: imp, ken, #cam
MFC after: immediately (we want this in 14.0)
Differential Revision: https://reviews.freebsd.org/D42402

7 months agolibc: Purge unneeded cdefs.h
Warner Losh [Wed, 1 Nov 2023 22:43:37 +0000 (16:43 -0600)]
libc: Purge unneeded cdefs.h

These sys/cdefs.h are not needed. Purge them. They are mostly left-over
from the $FreeBSD$ removal. A few in libc are still required for macros
that cdefs.h defines. Keep those.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D42385