]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 months agocompiler-rt: avoid segfaults when re-exec'ing with ASLR
Dimitry Andric [Wed, 22 Nov 2023 18:23:06 +0000 (19:23 +0100)]
compiler-rt: avoid segfaults when re-exec'ing with ASLR

After 930a7c2ac67e ("compiler-rt: re-exec with ASLR disabled when
necessary") and 96fe7c8ab0f6 ("compiler-rt: support ReExec() on
FreeBSD"), binaries linked against the sanitizer libraries may segfault
due to procctl(2) being intercepted. Instead, the non-intercepted
internal_procctl() should be called.

Similarly, the ReExec() function that re-executes the binary after
turning off ASLR should not call elf_aux_info(3) and realpath(3), since
these will also be intercepted. Instead, loop directly over the elf aux
info vector to find the executable path, and avoid calling realpath(3)
since it is actually unwanted for this use case.

Fixes: 930a7c2ac67e96fe7c8ab0f6
MFC after: 3 days

(cherry picked from commit 4c9a0adad18263ec8725d9bfc5f560c6ad1da8bd)

6 months agoAdd a HISTORY section for memcpy(3) and mempcpy(3)
Gordon Bergling [Sat, 18 Nov 2023 09:09:40 +0000 (10:09 +0100)]
Add a HISTORY section for memcpy(3) and mempcpy(3)

The memcpy() function first appeared in AT&T System V UNIX and was
reimplemented for 4.3BSD-Tahoe. The mempcpy() function first appeared in
FreeBSD 13.1.

PR: 272227
Differential Revision: https://reviews.freebsd.org/D42630

(cherry picked from commit 8c8ffe541eabb23e21ddffb534ecda7ac6d7e04a)

6 months agopseudofs: fix off by one in hash iteration in pfs_purge
Alvin Chen [Mon, 20 Nov 2023 05:55:35 +0000 (05:55 +0000)]
pseudofs: fix off by one in hash iteration in pfs_purge

Sponsored by: Dell Technologies
Differential Revision: https://reviews.freebsd.org/D42628

(cherry picked from commit e0d0f0930ee22af7bf38d28d8590d4e6c822871d)

6 months agopf: sctp heartbeats confirm a connection
Kristof Provost [Fri, 17 Nov 2023 12:52:34 +0000 (13:52 +0100)]
pf: sctp heartbeats confirm a connection

When we create a new state for multihomed sctp connections (i.e.
based on INIT/INIT_ACK or ASCONF parameters) the new connection will
never see a COOKIE/COOKIE_ACK exchange. We should consider HEARTBEAT_ACK
to be a confirmation that the connection is established.

This ensures that such connections do not time out earlier than
expected.

MFC after: 1 week
Sponsored by: Orange Business Services

(cherry picked from commit 7093414c63b08864dd9348f63e67b39a70c8b1be)

6 months agopf: skip urpf check for sctp multihomed states
Kristof Provost [Thu, 16 Nov 2023 19:55:02 +0000 (20:55 +0100)]
pf: skip urpf check for sctp multihomed states

When we create a new state for multihomed sctp connections (i.e.
based on INIT/INIT_ACK or ASCONF parameters) we cannot know what
interfaces we'll be seeing that traffic on. These states are floating
states, i.e. on "all" interfaces. We cannot do reverse path filtering
for these states, so do not do so.

MFC after: 1 week
Sponsored by: Orange Business Services

(cherry picked from commit a8dbbeb1c71b6f302818b8e041a2b50486b90180)

6 months agopf: always create multihomed states as floating
Kristof Provost [Thu, 16 Nov 2023 16:06:29 +0000 (17:06 +0100)]
pf: always create multihomed states as floating

When we create a new state for multihomed sctp connections (i.e.
based on INIT/INIT_ACK or ASCONF parameters) we cannot know what
interfaces we'll be seeing that traffic on. Make those states floating,
irrespective of state policy.

MFC after: 1 week
Sponsored by: Orange Business Services

(cherry picked from commit 0fe663b2a815dcb41431543940ec51408f418392)

6 months agolibpfctl: handle pfctl_do_ioctl() failures better
Kristof Provost [Fri, 17 Nov 2023 09:19:38 +0000 (10:19 +0100)]
libpfctl: handle pfctl_do_ioctl() failures better

Ensure that we free nvlists and other allocations if pfctl_do_ioctl()
fails.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 498934c5ff51e6b0d3199db5d27ed11b1e8b9582)

6 months agolibpfctl: handle allocation failure
Kristof Provost [Fri, 17 Nov 2023 09:14:59 +0000 (10:14 +0100)]
libpfctl: handle allocation failure

While it's unlikely for userspace to fail to allocate memory it is still
possible. Handle malloc() returning NULL.

Reported by: Bill Meeks <bill@themeeks.net>
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 33d55d0d0f33787e9e2796b5000be73af42573bc)

6 months agokernel: add missed FEATUREs compat_freebsd 8-14
Konstantin Belousov [Thu, 16 Nov 2023 20:47:18 +0000 (22:47 +0200)]
kernel: add missed FEATUREs compat_freebsd 8-14

(cherry picked from commit e256f71389fbf0ef6cf8f547342d5f789e69f918)

6 months agofuse_vnop_copy_file_range(): add safety
Konstantin Belousov [Tue, 14 Nov 2023 22:49:35 +0000 (00:49 +0200)]
fuse_vnop_copy_file_range(): add safety

(cherry picked from commit 4c6cded2166111079c6b5e8b2353171dcc7ed0c4)

6 months agofuse_vnop_copy_file_range(): use vn_lock_pair()
Konstantin Belousov [Tue, 14 Nov 2023 22:48:47 +0000 (00:48 +0200)]
fuse_vnop_copy_file_range(): use vn_lock_pair()

(cherry picked from commit 318c56714aa8c170132ebe008f52904e0f119b5f)

6 months agovn_lock_pair(): reasonably handle vp1 == vp2 case
Konstantin Belousov [Thu, 16 Nov 2023 22:42:25 +0000 (00:42 +0200)]
vn_lock_pair(): reasonably handle vp1 == vp2 case

(cherry picked from commit 22bac49b09a9f975330dc0d811436599ce740890)

6 months agoSEE ALSO section improvements for tuning(7), tunefs(8) and fsck_ffs(8)
Gordon Bergling [Fri, 17 Nov 2023 18:24:22 +0000 (19:24 +0100)]
SEE ALSO section improvements for tuning(7), tunefs(8) and fsck_ffs(8)

cross-reference ffs(7) in fsck_ffs(8)
cross-reference ffs(7) and tuning(7) in tunefs(8)
cross-reference ffs(7) in tuning(7)

PR: 263433
Reviewed by: bcr
Differential Revision: https://reviews.freebsd.org/D42631

(cherry picked from commit 115459be3132079f38b848749d20c972fa823fbb)

6 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.

(cherry picked from commit 501bdf3001190686bf55d9d333cb533858c2cf2f)

6 months agonfscl: Handle a Getattr failure with NFSERR_DELAY following Open
Rick Macklem [Sun, 22 Oct 2023 01:33:33 +0000 (18:33 -0700)]
nfscl: Handle a Getattr failure with NFSERR_DELAY following Open

During testing at a recent IETF NFSv4 Bakeathon, a non-FreeBSD
server was rebooted.  After the reboot, the FreeBSD client sent
an Open/Claim_previous with a Getattr after the Open in the same
compound.  The Open/Claim_previous was done to recover the Open
and a Delegation for for a file.  The Open succeeded, but the
Getattr after the Open failed with NFSERR_DELAY.  This resulted
in the FreeBSD client retrying the entire RPC over and over again,
until the server's recovery grace period ended.  Since the Open
succeeded, there was no need to retry the entire RPC.

This patch modifies the NFSv4 client side recovery Open/Claim_previous
RPC reply handling to deal with this case.  With this patch, the
Getattr reply of NFSERR_DELAY is ignored and the successful Open
reply is processed.

This bug will not normally affect users, since this non-FreeBSD
server is not widely used (it may not even have shipped to any
customers).

(cherry picked from commit 14bbf4fe5abb20f1126168e66b03127ae920f78e)

6 months agoipfw: fix copy&paste bug for number:array tables
Andrey V. Elsukov [Tue, 14 Nov 2023 04:37:04 +0000 (07:37 +0300)]
ipfw: fix copy&paste bug for number:array tables

Use compare_numarray() method for binary search. This fixes
table lookups for keys greater than UINT16_MAX.

Obtained from: Yandex LLC
MFC after: 1 week
Sponsored by: Yandex LLC

(cherry picked from commit 194df014feebd8b169b41ecd75ae73d63a792d6b)

6 months agogetpeerid.3: Clarify the 's' argument
Gordon Bergling [Sat, 18 Nov 2023 09:02:12 +0000 (10:02 +0100)]
getpeerid.3: Clarify the 's' argument

The argument 's' of getpeerid(3) must be a connected UNIX-domain socket,
so document it.

PR: 248614
Differential Revision: https://reviews.freebsd.org/D42629

(cherry picked from commit fa9f74220146233b7224da7c94870540dc39ae68)

6 months agotty: properly check character position when handling IUTF8 backspaces
Bojan Novković [Mon, 13 Nov 2023 18:02:30 +0000 (20:02 +0200)]
tty: properly check character position when handling IUTF8 backspaces

The tty_rubchar() code handling backspaces for UTF-8 characters didn't
properly check whether the beginning of the current line was reached.
This resulted in a kernel panic in ttyinq_unputchar() when prodded with
certain malformed UTF-8 sequences.

PR: 275009
Reviewed by: christos
Differential Revision: https://reviews.freebsd.org/D42564

(cherry picked from commit c6d7be214811c315d234d64c6cbaa92d4f55d2c1)

6 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

(cherry picked from commit bb830e346bd50545e9868a1802d631afb6b50bb0)

6 months agovn_copy_file_range(): busy both in and out mp around call to VOP_COPY_FILE_RANGE()
Konstantin Belousov [Sun, 12 Nov 2023 18:37:29 +0000 (20:37 +0200)]
vn_copy_file_range(): busy both in and out mp around call to VOP_COPY_FILE_RANGE()

(cherry picked from commit 23210f538a008788b2e16b9eddafa4f598a21663)

6 months agovn_copy_file_range(): use local variables for invp/outvp vnodes v_mounts
Konstantin Belousov [Sun, 12 Nov 2023 18:29:14 +0000 (20:29 +0200)]
vn_copy_file_range(): use local variables for invp/outvp vnodes v_mounts

(cherry picked from commit 89188bd6ba8d8332c65498f2b71c90e5ed4b9dae)

6 months agoreboot(8): print syscall error on sysctl failure
Konstantin Belousov [Mon, 13 Nov 2023 01:46:51 +0000 (03:46 +0200)]
reboot(8): print syscall error on sysctl failure

(cherry picked from commit a294b02fbc07fa8466c8fc12311e7d4e92332467)

6 months agoreboot(8): adapt for vmmeter v_swappgsin expansion to 64bit
Konstantin Belousov [Mon, 13 Nov 2023 01:30:53 +0000 (03:30 +0200)]
reboot(8): adapt for vmmeter v_swappgsin expansion to 64bit

PR: 275048

(cherry picked from commit 194cc45a81f70aa280546b7a5e658028df0303e7)

6 months agonetstat: fix missing tab in icmp6 output
Kristof Provost [Sun, 12 Nov 2023 17:23:04 +0000 (18:23 +0100)]
netstat: fix missing tab in icmp6 output

PR: 275044
Submitted by: sigsys@gmail.com
Reviewed by: kp
MFC after: 1 week

(cherry picked from commit 4b5634f4e56ddc0554c5ebba610d45eb48b9210d)

6 months agoif_wg: Missing radix unlock can cause deadlock
Aaron LI [Sat, 11 Nov 2023 13:13:08 +0000 (14:13 +0100)]
if_wg: Missing radix unlock can cause deadlock

In function 'wg_aip_add()', the error path of returning ENOMEM when
(node == NULL) is forgetting to unlock the radix tree, and thus may lead
to a deadlock.

PR: 275001
Reviewed by: kp
MFC after: 1 week

(cherry picked from commit dcc4d2939f789a6d1f272ffeab2068ba2b7525ea)

6 months agopf_purge_expired_states(): fix build without SDT probes
Konstantin Belousov [Thu, 9 Nov 2023 20:17:53 +0000 (22:17 +0200)]
pf_purge_expired_states(): fix build without SDT probes

Sponsored by: The FreeBSD Foundation

(cherry picked from commit af21145f33d75c8d754b2371d03c181cd0c730e7)

6 months agonfsd: Avoid acquiring a vnode for some NFSv4 Readdir operations
Rick Macklem [Tue, 17 Oct 2023 20:55:48 +0000 (13:55 -0700)]
nfsd: Avoid acquiring a vnode for some NFSv4 Readdir operations

Without this patch, a NFSv4 Readdir operation acquires the vnode for
each entry in the directory.  If only the Type, Fileid, Mounted_on_fileid
and ReaddirError attributes are requested by a client, acquiring the vnode
is not necessary for non-directories.  Directory vnodes must be acquired
to check for server file system mount points.

This patch avoids acquiring the vnode, as above, resulting in a 3-8%
improvement in Readdir RPC RTT for some simple tests I did.

Note that only non-rdirplus NFSv4 mounts will benefit from this change.

Tested during a recent IETF NFSv4 Bakeathon testing event.

(cherry picked from commit cd5edc7db261fb228be4044e6fdd38850eb4e9c4)

6 months agopf: add hashtable row count SDT
Kristof Provost [Thu, 9 Nov 2023 12:39:56 +0000 (13:39 +0100)]
pf: add hashtable row count SDT

This allows us to figure out how many states each hashrow contains. That
can be important to know when debugging performance issues.

A simple probe could be:

dtrace -n 'pf:purge:state:rowcount { @counts["states per row"] = quantize(arg1); }'
dtrace: description 'pf:purge:state:rowcount ' matched 1 probe
^C

  states per row
           value  ------------- Distribution ------------- count
              -1 |                                         0
               0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 8257624
               1 |                                         14321
               2 |                                         0

MFC after: 1 week
Sponsored by: Modirum MDPay

(cherry picked from commit 0d2ab4a4ced0f153a6b6a58ca3cfa6efbeeec7a2)

6 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

(cherry picked from commit 8d6c0743e36e3cff9279c40468711a82db98df23)

6 months agonfscl: Handle the NFSERR_RETRYUNCACHEDREP error from a NFSv4 server
Rick Macklem [Wed, 18 Oct 2023 19:42:12 +0000 (12:42 -0700)]
nfscl: Handle the NFSERR_RETRYUNCACHEDREP error from a NFSv4 server

In a recent email list discussion related to NFSv4 mount problems
against a non-FreeBSD NFSv4 server, the reporter of the issue noted
that the server had replied 10068 (NFSERR_RETRYUNCACHEDREP).  This
did not seem related to the mount problem, but I had never seen this
error before.  It indicates that an RPC retry after a new TCP
connection has been established failed because the server did not
cache the reply.  Since this should only happen for idempotent
operations, redoing the RPC should be safe.

This patch modifies the NFSv4.1/4.2 client to redo the RPC instead
of considering the server error fatal.  It should only affect the
unusual case where TCP connections to NFSv4 servers are breaking
without the NFSv4 server rebooting.

MFC after: 2 weeks

(cherry picked from commit c4e298251ab01665f5bb3edeb740a51331818a45)

6 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'

(cherry picked from commit 96cb1d70008e6d42750e95135316cafd6899384f)

6 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()

(cherry picked from commit 05fe82455f263ad107a860ce20dd89e1a5c1619c)

6 months agoauxv: make AT_BSDFLAGS unsigned
Brooks Davis [Thu, 26 Oct 2023 17:38:35 +0000 (18:38 +0100)]
auxv: make AT_BSDFLAGS unsigned

AT_BSDFLAGS shouldn't be sign extended on 64-bit systems so use a
uint32_t instead of an int.

Reviewed by: imp, kib
Differential Revision: https://reviews.freebsd.org/D42365

(cherry picked from commit 326bf5089ca788d5ff1951eed7a9067281a2b65e)

6 months agoprocctl.2: improve phrasing for ASLR disable
Brooks Davis [Thu, 26 Oct 2023 17:38:14 +0000 (18:38 +0100)]
procctl.2: improve phrasing for ASLR disable

Reported by: jrtc27
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D42364

(cherry picked from commit 4894205482555447c6b3372598c7589a66596724)

6 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

(cherry picked from commit 3e356fb885f6a742c496cefd71d8d33564de542a)

6 months agoping: Avoid reporting NaNs
Jose Luis Duran [Fri, 6 Oct 2023 17:55:06 +0000 (17:55 +0000)]
ping: Avoid reporting NaNs

Avoid calculating the square root of negative zero, which can easily
happen on certain architectures when calculating the population standard
deviation with a sample size of one, e.g., 0.01 - (0.1 * 0.1) =
-0.000000.

Avoid returning a NaN by capping the minimum possible variance value to
zero (positive).

In the future, maybe skip reporting statistics at all for a single
sample.

Reported by: Jenkins
Reviewed by: asomers
MFC after: 1 week
Pull Request: https://github.com/freebsd/freebsd-src/pull/863
Differential Revision: https://reviews.freebsd.org/D42114

(cherry picked from commit 4d348e83b738347f6aaf2b110459a01c5402d04e)

6 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

(cherry picked from commit a6173e94635b03aa7aab90a67785c8c3e7c6247b)

6 months agobpf: Make dead_bpf_if const
Zhenlei Huang [Sat, 21 Oct 2023 04:52:27 +0000 (12:52 +0800)]
bpf: Make dead_bpf_if const

The dead_bpf_if is not subjected to be written. Make it const so that
on destructive writing to it the kernel will panic instead of silent
memory corruption.

No functional change intended.

Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42189

(cherry picked from commit 7a974a649848e1222a49d0d49726d06bd5c1dbd9)
(cherry picked from commit 5d031613affa14b3de64f8cf9fed15604fb826d3)

6 months agoDelete snapshot after opening it when running fsck_ffs(9) in background.
Kirk McKusick [Wed, 25 Oct 2023 22:36:45 +0000 (15:36 -0700)]
Delete snapshot after opening it when running fsck_ffs(9) in background.

PR:           106107

(cherry picked from commit d3a36e4b7459b2d62c4cd50de7a8e3195d7241c7)

6 months agovfs_domount_update(): ensure that 'goto end' works
Konstantin Belousov [Thu, 9 Nov 2023 20:18:47 +0000 (22:18 +0200)]
vfs_domount_update(): ensure that 'goto end' works

PR: 274992

(cherry picked from commit ede4c412b3ea9289ef42c664b01b6b5ff7eac434)

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

(cherry picked from commit d093fe94e10f88fb5f46108f28555584f2f90d08)

6 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

PR: 274705

(cherry picked from commit 967022aa5aa60a18764a668ae0fb78e39e16fa8e)

6 months agolibpfctl: fix label setting
Franco Fichtner [Fri, 10 Nov 2023 11:42:17 +0000 (12:42 +0100)]
libpfctl: fix label setting

A mismerge caused the labels list to be added to the wrong nvlist,
breaking label configuration.

If you compare the change from from main and stable/13 you
can see that main uses "nvl" and stable/13 has "nlvr" for
nvlist_append_string_array() but the backport changes it to "nlv".

This code was supposed to apply to pfctl_add_eth_rule() but instead
applied to pfctl_add_rule() for otherwise interesting reasons.  Since
pfctl_add_eth_rule() uses "nvl" and pfctl_add_rule() uses "nvlr" but
also has "nvl" this compiled fine but still broke the label set.

Direct commit to stable/13.

PR: 275006

6 months agoping6(8): Add ping6(8) as MLINK to ping(8)
Antranig Vartanian [Tue, 7 Nov 2023 21:14:59 +0000 (05:14 +0800)]
ping6(8): Add ping6(8) as MLINK to ping(8)

Reviewed by: chuck
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D42203

(cherry picked from commit d6e457328d0e57176b66ba5f5c614becca680fea)

6 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

(cherry picked from commit 7bca09e2bb7f812913249a1e5883742d6d6ac6b2)

6 months agofflush: correct buffer handling in __sflush
Ed Maste [Tue, 7 Nov 2023 14:16:13 +0000 (09:16 -0500)]
fflush: correct buffer handling in __sflush

Two additional stdio changes followed 86a16ada1ea6 and need to be
reverted as part of the fflush fix.

This reverts commit 6e13794fbe6e82c21365d0fd66769bf8b19c0197.
This reverts commit bafaa70b6f9098d83d074968c8e6747ecec1e118.

Fixes: d09a3bf72c0b ("fflush: correct buffer handling in __sflush")
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42491

(cherry picked from commit 4e0e01bf6511c28212d7dff94fe131a502e13026)
(cherry picked from commit d2c65a1c948648f11342274029a3f18b90aa58d2)

Approved by: so

6 months agolibc: remove unused errno.h include
Ed Maste [Tue, 7 Nov 2023 15:00:35 +0000 (10:00 -0500)]
libc: remove unused errno.h include

errno.h was added in 44cf1e5eb470, which has been reverted.

Fixes: d09a3bf72c0b ("fflush: correct buffer handling in __sflush")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 418f026bd5a5084c1c4e2e91ad38051f6caa928c)
(cherry picked from commit abe12d2f4ce31c3da0961b1b0a58df11f5a41e19)

Approved by: so

6 months agopf: support SCTP-specific timeouts
Kristof Provost [Fri, 27 Oct 2023 14:45:07 +0000 (16:45 +0200)]
pf: support SCTP-specific timeouts

Allow SCTP state timeouts to be configured independently from TCP state
timeouts.

Reviewed by: tuexen
MFC after: 1 week
Sponsored by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D42393

(cherry picked from commit ca9dbde88122beb079b55fb4580b200f73044da6)

6 months agolibpfctl: be more tolerant of kernel extensions
Kristof Provost [Fri, 27 Oct 2023 12:13:57 +0000 (14:13 +0200)]
libpfctl: be more tolerant of kernel extensions

Allow the kernel to supply more array elements than expected, but cut
off when we hit what we think the maximum is. This will improve forward
compatibility (i.e. old userspace with newer kernel).

Reviewed by: zlei
MFC after: 1 week
Sponsored by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D42392

(cherry picked from commit 2b1eb63fc9c6d6f64baaac59b7ea7c2a3228c03f)

6 months agopf tests: ensure that we generate all permutations for SCTP multihome
Kristof Provost [Tue, 10 Oct 2023 09:56:15 +0000 (11:56 +0200)]
pf tests: ensure that we generate all permutations for SCTP multihome

The initial multihome implementation was a little simplistic, and failed
to create all of the required states. Given a client with IP 1 and 2 and
a server with IP 3 and 4 we end up creating states for 1 - 3 and 2 - 3,
as well as 3 - 1 and 4 - 1, but not for 2 - 4.

Check for this.

MFC after: 1 week
Sponsored by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D42362

(cherry picked from commit 483d5c4075e06e52d5daa23aef2b4f4a2eb64443)

6 months agopf: fix missing SCTP multihomed states
Kristof Provost [Tue, 17 Oct 2023 16:10:39 +0000 (18:10 +0200)]
pf: fix missing SCTP multihomed states

The existing code to create extra states when SCTP endpoints supplied
extra addresses missed a case. As a result we failed to generate all of
the required states.

Briefly, if host A has address 1 and 2 and host B has addres 3 and 4 we
generated 1 - 3 and 2 - 3, as well as 1 - 4, but not 2 - 4.

Store the list of endpoints supplied by each host and use those to
generate all of the connection permutations.

MFC after: 1 week
Sponsored by: Orange Business Services
Differential Revision: https://reviews.freebsd.org/D42361

(cherry picked from commit d6d38b02ee57920cc02a306a6d8d2aec9c4b759c)

6 months agofflush: Add test for buffer handling in __sflush
Dag-Erling Smørgrav [Thu, 3 Aug 2023 15:13:45 +0000 (15:13 +0000)]
fflush: Add test for buffer handling in __sflush

Sponsored by: Klara, Inc.

(cherry picked from commit b8dbfb0a6c181a9aeab0b793deb0813d06052df9)
(cherry picked from commit ba490dfc95e0941216420a2003757b3c4b5b2ec2)

Approved by: so

6 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.

(cherry picked from commit d09a3bf72c0b5f1779c52269671872368c99f02a)
(cherry picked from commit 92709431b14df6c0687446247ac57cfc189ee827)

Approved by: so

6 months agosetkey(8): make the policy specification more readable
Konstantin Belousov [Tue, 31 Oct 2023 04:07:10 +0000 (06:07 +0200)]
setkey(8): make the policy specification more readable

(cherry picked from commit 224fc33f603884e7eb9ed219afdd4c57ddec3cb9)

6 months agocap_net: correct capability name from addr2name to name2addr
Mariusz Zaborski [Mon, 23 Oct 2023 21:03:51 +0000 (23:03 +0200)]
cap_net: correct capability name from addr2name to name2addr

Previously, while checking name2addr capabilities, we mistakenly used
the addr2name set. This error could cause a process to inadvertently
reset its limitations.

Reported by: Shawn Webb <shawn.webb@hardenedbsd.org>

(cherry picked from commit afd74c400075d94e01dd3430844bb290834660ef)
(cherry picked from commit 765757c6301fa41c0b59108347c600fbc9020c39)

6 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.

(cherry picked from commit 1f90b4edffe815aebb35e74b79e10593b31f6b75)
(cherry picked from commit 1e99535be2ea9c0ef8bc57fc885e9c01fa95d2dd)

6 months agoibcore: Introduce enum ib_raw_packet_caps from Linux 4.11
Ka Ho Ng [Sat, 28 Oct 2023 20:57:49 +0000 (16:57 -0400)]
ibcore: Introduce enum ib_raw_packet_caps from Linux 4.11

This enum also exists as enum ibv_raw_packet_caps in libibverbs/verbs.h.

[khng: cherry-picked from Linux
ebaaee253ad3a3c573ab7d3d77e849056bdfa9ea]

Sponsored by: Juniper Networks, Inc.
MFC after: 7 days
Reviewed by: kib, zlei
Differential Revision: https://reviews.freebsd.org/D42177

(cherry picked from commit a69b6af2024fdd501b4bbc674092fb2b6d466364)

6 months agomlx5ib: Fix RSS Toeplitz setup to be aligned with the HW specification
Yishai Hadas [Sat, 28 Oct 2023 20:55:47 +0000 (16:55 -0400)]
mlx5ib: Fix RSS Toeplitz setup to be aligned with the HW specification

The specification for the Toeplitz function doesn't require to set the key
explicitly to be symmetric. In case a symmetric functionality is required
a symmetric key can be simply used.

Wrongly forcing the algorithm to symmetric causes the wrong packet
distribution and a performance degradation.

Link: https://lore.kernel.org/r/20190723065733.4899-7-leon@kernel.org
Fixes: 28d6137008b2 ("IB/mlx5: Add RSS QP support")
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Reviewed-by: Alex Vainman <alexv@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
[khng: cherry-picked from Linux
b7165bd0d6cbb93732559be6ea8774653b204480]

Sponsored by: Juniper Networks, Inc.
MFC after:      7 days
Reviewed by: kib, zlei
Differential Revision: https://reviews.freebsd.org/D42178

(cherry picked from commit 813d981e1e78daffde4b2a05df35d054fcb4343f)

6 months agomlx5ib: Fix ethertype to be ETH_P_IPV6
Ka Ho Ng [Sat, 28 Oct 2023 20:54:32 +0000 (16:54 -0400)]
mlx5ib: Fix ethertype to be ETH_P_IPV6

Sponsored by: Juniper Networks, Inc.
MFC after: 7 days
Reviewed by: ae, kib, zlei
Differential Revision: https://reviews.freebsd.org/D42184

(cherry picked from commit 3b173281764ba7c02f9de0a67caa1c4eca604413)

6 months agonfsd: Fix a server crash
Rick Macklem [Wed, 18 Oct 2023 02:40:23 +0000 (19:40 -0700)]
nfsd: Fix a server crash

PR#274346 reports a crash which appears to be caused by a NULL default session
being destroyed.  This patch should avoid the crash.

PR: 274346

(cherry picked from commit db7257ef972ed75e33929d39fd791d3699b53c63)

6 months agonfsd: Fix NFSv4.1/4.2 Claim_Deleg_Cur_FH
Rick Macklem [Thu, 19 Oct 2023 19:35:35 +0000 (12:35 -0700)]
nfsd: Fix NFSv4.1/4.2 Claim_Deleg_Cur_FH

When I implemented a test patch using Open Claim_Deleg_Cur_FH
I discovered that the NFSv4.1/4.2 server was broken for this
Open option.  Fortunately it is never used by the FreeBSD
client and never used by other clients unless delegations
are enabled. (The FreeBSD NFSv4 server does not have delegations
enabled by default.)

Claim_Deleg_Cur_FH was broken because the code mistakenly
assumed a stateID argument, which is not the case.
This patch fixes the bug by changing the XDR parser to not
expect a stateID and to fill most of the stateID in from the
clientID. The clientID is the first two elements of the "other"
array for the stateID and is sufficient to identify which
client the delegation is issued to.  Since there is only one
delegation issued to a client per file, this is sufficient to
locate the correct delegation.

If you are running non-FreeBSD NFSv4.1/4.2 mounts against the
FreeBSD server, you need this patch if you have delegations enabled.

PR: 274574

(cherry picked from commit f300335d9aebf2e99862bf783978bd44ede23550)

6 months agonetlink: fix powerpc build.
Alexander V. Chernikov [Tue, 25 Apr 2023 14:59:04 +0000 (14:59 +0000)]
netlink: fix powerpc build.

(cherry picked from commit 9e81e2c4520cdc9b68428a9acc695ad091083ebb)

6 months agolibpfctl: remove unused field from struct pfctl_states
Kristof Provost [Mon, 30 Oct 2023 18:04:12 +0000 (19:04 +0100)]
libpfctl: remove unused field from struct pfctl_states

We never populate this, or use it, so remove it.

MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 87c5032353106764f324e82541662f448e68f38a)

6 months agolibpfctl: add missing pfctl_status_lcounter() function
Kristof Provost [Mon, 30 Oct 2023 18:02:29 +0000 (19:02 +0100)]
libpfctl: add missing pfctl_status_lcounter() function

We already had accessors for the other types of counters, but not this
one.

MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 1c824f430a395cdc66e22406e72f20ebd300e47e)

6 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

(cherry picked from commit d24729b2fd66a87c2b925b0c30e46bb0a9d6446a)
(cherry picked from commit fb288d493989d9df4c4f9c8eb3d7e28af61f8302)

6 months agoGiant: Postpone removal of Giant-locked drivers until 15
Zhenlei Huang [Tue, 31 Oct 2023 12:45:14 +0000 (20:45 +0800)]
Giant: Postpone removal of Giant-locked drivers until 15

Reviewed by: imp
MFC after: 1 day
Differential Revision: https://reviews.freebsd.org/D42401

(cherry picked from commit a8bd34bfc0db38c1c11e9c36b7dd849d607c17a8)
(cherry picked from commit 5019a5acc5b01804e9dccd3796e9e0ea7c82ba90)

6 months agopf: update pf(4) man page to list DIOCGETSTATESV2
Kristof Provost [Mon, 23 Oct 2023 15:11:15 +0000 (17:11 +0200)]
pf: update pf(4) man page to list DIOCGETSTATESV2

The nvlist based state retrieval ioctl has been replaced by an old-style
ioctl for performance reasons. Document that one.

Reported by: Michael Gmelin <grembo@freebsd.org>
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D42331

(cherry picked from commit 6869f90bf5bbb2f5ae5400e3a435b3680991321d)

6 months agolibpfctl: fix Coverity issues
Kristof Provost [Mon, 23 Oct 2023 11:46:11 +0000 (13:46 +0200)]
libpfctl: fix Coverity issues

 - handle snl_finalize_msg() returning NULL
 - insert the correct data into the states list
 - add missing nvlist_destroy()
 - incorrect order for array bounds

Coverity: 152292915229251522923152292115227801522770152276414877851471250
Reviewed by: emaste
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D42330

(cherry picked from commit 4abc3b482e0d246cd3518622223795c8de102130)

6 months agolibpfctl: fix pfctl_do_ioctl()
Kristof Provost [Mon, 23 Oct 2023 11:43:52 +0000 (13:43 +0200)]
libpfctl: fix pfctl_do_ioctl()

pfctl_do_ioctl() copies the packed request data into the request buffer
and then frees it. However, it's possible for the buffer to be too small
for the reply, causing us to allocate a new buffer. We then copied from
the freed request, and freed it again.

Do not free the request buffer until we're all the way done.

PR: 274614
Reviewed by: emaste
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D42329

(cherry picked from commit 2cffb52514b070e716e700c7f58fdb8cd9b05335)

6 months agonetlink: fix potential llentry lock leak in newneigh handler
R. Christian McDonald [Mon, 23 Oct 2023 11:23:55 +0000 (13:23 +0200)]
netlink: fix potential llentry lock leak in newneigh handler

The netlink newneigh handler has the potential to leak the lock on
llentry objects in the kernel. This patch reconciles several paths
through the newneigh handler that could result in a lock leak.

MFC after: 1 week
Reviewed by: markj, kp
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D42307

(cherry picked from commit ae2ca32781a90abe987e128ca167ab400a87f369)

6 months agonetlink: allow creation of temporary lle entries.
Alexander V. Chernikov [Tue, 25 Apr 2023 11:08:47 +0000 (11:08 +0000)]
netlink: allow creation of temporary lle entries.

MFC after: 2 weeks

(cherry picked from commit a2728a9a5b8da974e238e6413a980134dbd6297f)

6 months agouser stack randomization: only enable by default for 64bit processes
Konstantin Belousov [Tue, 24 Oct 2023 21:44:06 +0000 (00:44 +0300)]
user stack randomization: only enable by default for 64bit processes

(cherry picked from commit 1798b44fda382c473c9fc7762e162613a39dc23c)

7 months agoisa: Postpone removal of the non-PNP driver until 15
Zhenlei Huang [Sat, 28 Oct 2023 20:31:11 +0000 (04:31 +0800)]
isa: Postpone removal of the non-PNP driver until 15

Reviewed by: imp
MFC after: 1 day
Differential Revision: https://reviews.freebsd.org/D42387

(cherry picked from commit 98a670cdd6720da4988f902192177fa368b9f9e9)
(cherry picked from commit 699526792d2fac156d72654dba89a4b94c8a4c67)

7 months agopthread_mutexattr(3), _condattr(3): reference libthr(3)
Konstantin Belousov [Mon, 23 Oct 2023 23:03:42 +0000 (02:03 +0300)]
pthread_mutexattr(3), _condattr(3): reference libthr(3)

(cherry picked from commit 4f03a2cae8ae96446064da4e8a533ab24172bdcb)

7 months agopthread_mutexattr_init(3): describe pthread_mutexattr_{set,get}pshared
Konstantin Belousov [Mon, 23 Oct 2023 22:54:54 +0000 (01:54 +0300)]
pthread_mutexattr_init(3): describe pthread_mutexattr_{set,get}pshared

PR: 274678

(cherry picked from commit 2152c4e2db88b9264c6400f2510440465d39c7b8)

7 months agoFix a bug in fsck_ffs(8) triggered by corrupted filesystems.
Kirk McKusick [Fri, 20 Oct 2023 22:14:46 +0000 (15:14 -0700)]
Fix a bug in fsck_ffs(8) triggered by corrupted filesystems.

Reported-by: Andreas Bock
PR:           274404
(cherry picked from commit 1e39a0886e0999520a7e7136e3f7d09e9cd9a5f2)

7 months agoufs quotas: fix configuring soft quota grace time
Mikel Lechner [Sat, 21 Oct 2023 06:08:38 +0000 (09:08 +0300)]
ufs quotas: fix configuring soft quota grace time

PR: 274552

(cherry picked from commit 2fee3974603bce6f2dc153eb6af459cb4f864ab4)

7 months agobhyve: fix arguments to ioctl(VMIO_SIOCSIFFLAGS)
Gleb Smirnoff [Thu, 26 Oct 2023 09:59:21 +0000 (02:59 -0700)]
bhyve: fix arguments to ioctl(VMIO_SIOCSIFFLAGS)

ioctl(2)'s with integer argument shall pass command argument by value,
not by pointer.  The ioctl(2) manual page is not very clear about that.
See sys/kern/sys_generic.c:sys_ioctl() near IOC_VOID.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D42366
Fixes: fd8b9c73a5a63a7aa438a73951d7a535b4f25d9a

(cherry picked from commit f407a72a506d2630d60d9096c42058f12dff874e)

7 months agopfctl: fix incorrect mask on dynamic address
Kristof Provost [Fri, 6 Oct 2023 12:20:17 +0000 (14:20 +0200)]
pfctl: fix incorrect mask on dynamic address

A PF rule using an IPv4 address followed by an IPv6 address and then a
dynamic address, e.g. "pass from {192.0.2.1 2001:db8::1} to (pppoe0)",
will have an incorrect /32 mask applied to the dynamic address.

MFC after: 3 weeks
Obtained from: OpenBSD
See also: https://ftp.openbsd.org/pub/OpenBSD/patches/5.6/common/007_pfctl.patch.sig
Sponsored by: Rubicon Communications, LLC ("Netgate")
Event: Oslo Hackathon at Modirum

(cherry picked from commit 7ce98cf2f87a22240b66e4c38fd887431a25bf7d)

7 months agomips: add enough glue for membarrier(2)
Konstantin Belousov [Thu, 26 Oct 2023 22:26:46 +0000 (01:26 +0300)]
mips: add enough glue for membarrier(2)

This is direct commit to stable/13.

7 months agolibprocstat: improve conditional for 32-bit compat
Brooks Davis [Thu, 26 Oct 2023 20:38:41 +0000 (21:38 +0100)]
libprocstat: improve conditional for 32-bit compat

Include support for translating 32-bit auxv vectors on non-64-bit
platforms that aren't riscv (which has no 32-bit ABI support and
probably never will).

Reviewed by: markj
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D42201

(cherry picked from commit 248fe3d3483cb3ec2c78dd31dc02a467060a6577)

7 months agolibprocstat: copy all the 32-bit auxv entries
Brooks Davis [Thu, 26 Oct 2023 20:38:41 +0000 (21:38 +0100)]
libprocstat: copy all the 32-bit auxv entries

Use source struct size not the destination struct size so we copy all
the auxv entries, not just the first half of them.

Fix a style issue on an adjacent line.

Reviewed by: markj
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D42200

(cherry picked from commit 8f06fabe39ac3ebca4ab448a456945008305a23f)

7 months agolibprocstat: make sv_name not static
Brooks Davis [Thu, 26 Oct 2023 20:38:41 +0000 (21:38 +0100)]
libprocstat: make sv_name not static

Making this variable static makes is_elf32_sysctl() and callers thread
unsafe.

Use a less absurd length for sv_name.  The longest name in the system is
"FreeBSD ELF64 V2" which tips the scales at 16+1 bytes.  We'll almost
certainly have other problems if we exceed 32 characters.

Reviewed by: markj
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D42199

(cherry picked from commit 72a4ee26a7c665ae1c31abe1c6feeaa7ccaba140)

7 months agolibprocstat: simplify auxv value conversion
Brooks Davis [Thu, 26 Oct 2023 20:38:41 +0000 (21:38 +0100)]
libprocstat: simplify auxv value conversion

Avoid a weird dance through the union and treat all 32-bit values as
unsigned integers.  This avoids sign extension of flags and userspace
pointers.

Reviewed by: markj
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D42198

(cherry picked from commit 9735cc0e41825bb9e95d16433d381ffe4c190f38)

7 months agolibprocstat: style: space after switch
Brooks Davis [Thu, 26 Oct 2023 20:38:40 +0000 (21:38 +0100)]
libprocstat: style: space after switch

Style demands a space after the switch keyword.

Noticed reviewing code in CheriBSD that propagated the style bug.

Reported by: markj
Sponsored by: DARPA
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D42041

(cherry picked from commit ccac440f7cbb013de41aa3933f3f7be77225c44f)

7 months agoRegen
Konstantin Belousov [Thu, 26 Oct 2023 04:06:56 +0000 (07:06 +0300)]
Regen

7 months agoAdd membarrier(2)
Konstantin Belousov [Thu, 7 Oct 2021 21:10:07 +0000 (00:10 +0300)]
Add membarrier(2)

(cherry picked from commit 4a69fc16a583face922319c476f3e739d9ce9140)

7 months agoAdd cpu_sync_core()
Konstantin Belousov [Thu, 7 Oct 2021 21:57:55 +0000 (00:57 +0300)]
Add cpu_sync_core()

(cherry picked from commit 74ccb8ecf6c115a79f008bc32d4981f1126b63a8)

7 months agoadd pmap_active_cpus()
Konstantin Belousov [Thu, 7 Oct 2021 22:25:54 +0000 (01:25 +0300)]
add pmap_active_cpus()

(cherry picked from commit 8882b7852acf2588d87ccb6d4c6bf7694511fc56)

7 months agomakesyscall: Stop generating $FreeBSD$
Warner Losh [Fri, 9 Jun 2023 13:26:07 +0000 (07:26 -0600)]
makesyscall: Stop generating $FreeBSD$

With 14 coming, we no longer need to generate the $FreeBSD$. We can
likely MFC that to 13 as well.

MFC After: 2 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D39879

(cherry picked from commit 61fe63f698148f8d63fe6f366c5e20bc7ad60b87)

7 months agomakesyscalls.lua: Minor fluff removal
Warner Losh [Thu, 20 Apr 2023 22:16:16 +0000 (16:16 -0600)]
makesyscalls.lua: Minor fluff removal

luacheck pointed out two minor issues: line isn't declared as a global,
so declare it local. Also remove an unused parameter.

Suggested by: kevans
Sponsored by: Netflix

(cherry picked from commit c1e987e0624ebf509a6d86099dd47ae6d72a8c03)

7 months agomakesyscalls.lua: Make more luaish
Warner Losh [Thu, 20 Apr 2023 22:15:57 +0000 (16:15 -0600)]
makesyscalls.lua: Make more luaish

x["y"] can be written as x.y, which looks better and is a more typical
lua idiom.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D39709

(cherry picked from commit 1dd350fce0aad85c559b962654f71d1449f21727)

7 months agoacpi_pcib: Rename decoded_bus_range to get_decoded_bus_range
John Baldwin [Fri, 20 Oct 2023 21:53:49 +0000 (14:53 -0700)]
acpi_pcib: Rename decoded_bus_range to get_decoded_bus_range

While here, change the return value to bool.

Discussed by: gibbs

(cherry picked from commit f6c2774fe415f3b79c551b8075c159d6a7d4d0bf)

7 months agox86: Cosmetic cleanups to struct msi_intsrc
John Baldwin [Fri, 20 Oct 2023 21:53:05 +0000 (14:53 -0700)]
x86: Cosmetic cleanups to struct msi_intsrc

- Sort members by size.

- Change msi_msix from a u_int to a bool.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D42305

(cherry picked from commit bfccb4a429795954cfeca4ba60a07c0e1ec35e07)

7 months agox86 msi: Enable/disable IDT vectors for MSI groups all at once
John Baldwin [Fri, 20 Oct 2023 21:52:38 +0000 (14:52 -0700)]
x86 msi: Enable/disable IDT vectors for MSI groups all at once

Unlike MSI-X, when a device uses multiple MSI interrupts, the entire
group of interrupts are enabled/disabled at once in the relevant PCI
config register.  Currently, the interrupt code enables the IDT vector
for each MSI interrupt when a handler is first registered.  If the PCI
device triggers an MSI interrupt which doesn't yet have a handler,
this can trigger a panic when the Xrsvd ISR executes rather than
treating it as a stray device interrupt.

To fix, enable all the IDT vectors for an MSI group when the first
interrupt handler is configured, and don't disable the IDT vectors
until the last interrupt handler for the group is torn down.

When migrating an MSI group between CPUs, enable/disable the entire
group of IDT vectors if at least one interrupt handler is configured
for the group.

Reported by: jhay
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D42232

(cherry picked from commit 2d4924892144f653a7a7afba27ed1bf536dd7e51)

7 months agoacpi_pcib: Trust decoded bus range from _CRS over _BBN
John Baldwin [Mon, 16 Oct 2023 22:19:07 +0000 (15:19 -0700)]
acpi_pcib: Trust decoded bus range from _CRS over _BBN

Currently if _BBN doesn't match the first bus in the decoded bus range
from _CRS for a Host to PCI bridge, the driver fails to attach as a
defensive measure.

There is now firmware in the field where these do not match, and the
_BBN values are clearly wrong, so rather than failing attach, trust
the range from _CRS over _BBN.

Co-authored-by: Justin Gibbs <gibbs@FreeBSD.org>
Reported by: gibbs
Reviewed by: imp (earlier version)
Differential Revision: https://reviews.freebsd.org/D42231

(cherry picked from commit 22a6678b627b39ceb94f7323be1010e928d92494)

7 months agobhyve: Replace many fprintf(stderr, ...) calls with EPRINTLN
John Baldwin [Mon, 16 Oct 2023 22:17:48 +0000 (15:17 -0700)]
bhyve: Replace many fprintf(stderr, ...) calls with EPRINTLN

EPRINTLN handles newlines appropriately when stdout/stderr have been
reused as the backend for a serial port.

For bhyverun.c itself, the rule this attempts to follow is to use
regular fprintf/perror/warn/err prior to init_pci() (which is when
serial ports are configured) and to switch to EPRINTLN afterwards.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D42182

(cherry picked from commit b0936440b8fcee523c0b26fdbbef7c3b2b5098bf)

7 months agobhyve ahci: Replace WPRINTF with EPRINTLN
John Baldwin [Fri, 13 Oct 2023 19:26:58 +0000 (12:26 -0700)]
bhyve ahci: Replace WPRINTF with EPRINTLN

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

(cherry picked from commit edd2a9b887864d07ac5af480b4b8f35cb76443f6)

7 months agobhyve: Some fwctl simplifications.
John Baldwin [Fri, 13 Oct 2023 19:26:22 +0000 (12:26 -0700)]
bhyve: Some fwctl simplifications.

- Collapse IDENT_SEND/IDENT_WAIT states down to a single state.

- Remove unused 'len' argument to op_data callback.  The value passed
  in (total amount of remaining data to receive) didn't seem very useful
  and no op_data implementations used it.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D41286

(cherry picked from commit f0852344e7abf4d74508185e67a1b98d6cdbd026)

7 months agobhyve: Document the hw.vmm.maxcpu tunable and the current limit on vCPUs
Yuri Pankov [Thu, 12 Oct 2023 19:49:47 +0000 (12:49 -0700)]
bhyve: Document the hw.vmm.maxcpu tunable and the current limit on vCPUs

Reviewed by: corvink (original version)
Co-authored-by: John Baldwin <jhb@FreeBSD.org>
Differential Revision: https://reviews.freebsd.org/D40074

(cherry picked from commit da202b0fe616e9314739f01493ae310e37a36d8d)