]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 weeks agoAdd UPDATING entries and bump the branch version. releng/13.3
Gordon Tetlow [Thu, 28 Mar 2024 03:03:42 +0000 (20:03 -0700)]
Add UPDATING entries and bump the branch version.

Approved by: so
Approved by: re (so, implicit, appease the commit-hook)

5 weeks agoMerge commit f800c1f3b207 from llvm-project (by Arthur Eubanks):
Dimitry Andric [Mon, 4 Mar 2024 20:30:54 +0000 (21:30 +0100)]
Merge commit f800c1f3b207 from llvm-project (by Arthur Eubanks):

  [PEI] Don't zero out noreg operands

  A tail call may have $noreg operands.

  Fixes a crash.

  Reviewed By: xgupta

  Differential Revision: https://reviews.llvm.org/D156485

This should fix an assertion failure building qemu, specifically those
parts using -fzero-call-used-regs.

Reported by: Daniel Berrangé <dan-freebsd@berrange.com>
PR: 277474
MFC after: 3 days
Approved by: so
Approved by: re (so, implicit, appease the commit-hook)
Security: FreeBSD-EN-24:07.clang

(cherry picked from commit a39b3aa463f3474fabb3aedb5aecf943b54b4357)
(cherry picked from commit 961271f952fc390396f967d50903291e3e6c59c6)

5 weeks agoif_wg: use proper barriers around pkt->p_state
Kyle Evans [Fri, 15 Mar 2024 01:19:18 +0000 (20:19 -0500)]
if_wg: use proper barriers around pkt->p_state

Without appropriate load-synchronization to pair with store barriers in
wg_encrypt() and wg_decrypt(), the compiler and hardware are often
allowed to reorder these loads in wg_deliver_out() and wg_deliver_in()
such that we end up with a garbage or intermediate mbuf that we try to
pass on.  The issue is particularly prevalent with the weaker
memory models of !x86 platforms.

Switch from the big-hammer wmb() to more explicit acq/rel atomics to
both make it obvious what we're syncing up with, and to avoid somewhat
hefty fences on platforms that don't necessarily need this.

With this patch, my dual-iperf3 reproducer is dramatically more stable
than it is without on aarch64.

PR: 264115
Reviewed by: andrew, zlei
Approved by: so
Approved by: re (so, implicit, appease the commit-hook)
Security: FreeBSD-EN-24:06.wireguard

(cherry picked from commit 3705d679a6344c957cae7a1b6372a8bfb8c44f0e)
(cherry picked from commit 806e51f81dbae21feb6e7ddd95d2ed2a28b04f8f)

2 months agoUpdate in preparation for 13.3-RELEASE
Colin Percival [Fri, 1 Mar 2024 19:00:16 +0000 (11:00 -0800)]
Update in preparation for 13.3-RELEASE

- Bump BRANCH to RELEASE
- Add the anticipated RELEASE announcement date
- Set a static __FreeBSD_version

Approved by:    re (implicit)
Sponsored by:   https://www.patreon.com/cperciva

2 months agokern: fix panic with disabled ttys
Ed Maste [Mon, 26 Feb 2024 15:38:45 +0000 (10:38 -0500)]
kern: fix panic with disabled ttys

PR: 277240, 277329
Reviewed by: kib (earlier version)
Fixes: f1d0a0cbecf2 ("jail: Fix information leak.")
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D44086

(cherry picked from commit 975d7730828a8bde28c2a0092b6e95c4c4e22f34)
(cherry picked from commit 8d22744f5be165a2a82a2a204789e44bbdc5a2ee)
(cherry picked from commit a60220bbb5511469fe53fd4290713ba891f8f48a)

Approved by: re (cperciva)

2 months agojail: Fix information leak.
Pawel Jakub Dawidek [Wed, 17 Jan 2024 17:43:55 +0000 (09:43 -0800)]
jail: Fix information leak.

There is a lack of proper visibility checking in kern.ttys sysctl handler
which leads to information leak about processes outside the current jail.

This can be demonstrated with pstat -t: when called from within a jail,
it will output all terminal devices including process groups and
session leader process IDs:

jail# pstat -t | grep pts/ | head
      LINE   INQ  CAN  LIN  LOW  OUTQ  USE  LOW   COL  SESS  PGID STATE
     pts/2  1920    0    0  192  1984    0  199     0  4132 27245 Oi
     pts/3  1920    0    0  192  1984    0  199    16 24890 33627 Oi
     pts/5     0    0    0    0     0    0    0    25 17758     0 G
    pts/16     0    0    0    0     0    0    0     0 52495     0 G
    pts/15     0    0    0    0     0    0    0    25 53446     0 G
    pts/17     0    0    0    0     0    0    0  6702 33230     0 G
    pts/19     0    0    0    0     0    0    0    14  1116     0 G
     pts/0     0    0    0    0     0    0    0     0  2241     0 G
    pts/23     0    0    0    0     0    0    0    20 15639     0 G
     pts/6     0    0    0    0     0    0    0     0 44062 93792 G
jail# pstat -t | grep pts/ | wc -l
      85

Devfs does the filtering correctly and we get only one entry:

jail# ls /dev/pts/
2

Approved by: mzaborski, secteam
MFC after: 1 week
Sponsored by: Fudo Security

(cherry picked from commit f1d0a0cbecf2c688061f35adea85bfb29c9ec893)
(cherry picked from commit a376108029a20f4ce51476d98f2483a7008ce7b5)
(cherry picked from commit 41ac0b4ce00bae061164384f23356a4df6e0e695)
(cherry picked from commit 9bff7ec98354a76c171905ce9530f85685725ee7)

Approved by: re (cperciva)

2 months ago13.3: update to RC1
Colin Percival [Sun, 25 Feb 2024 07:49:41 +0000 (23:49 -0800)]
13.3: update to RC1

Now that we're at RC1, switch from "quarterly" packages to the release
package set.

Approved by: re (implicit)
Sponsored by: https://www.patreon.com/cperciva

2 months agoirdma(4): Upgrade to 1.2.36-k
Bartosz Sobczak [Fri, 16 Feb 2024 21:55:08 +0000 (13:55 -0800)]
irdma(4): Upgrade to 1.2.36-k

Update Intel irdma driver to version 1.2.36-k.

Notable changes:

- Start using ib_sge directly instead of irdma_sge
- Turn off flush completion generator for libirdma
- Minor formatting changes

Signed-off-by: Bartosz Sobczak <bartosz.sobczak@intel.com>
Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Reviewed by: erj@
Approved by: re (cperciva@)
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D43567

(cherry picked from commit 5b5f7d0e77a9eee73eb5d596f43aef4e1a3674d8)
(cherry picked from commit a4510dafa8045bfa521303db7f23123a47d8749f)

2 months agomsdosfs: fix potential inode collision on FAT12 and FAT16
Stefan Eßer [Tue, 20 Feb 2024 12:02:24 +0000 (13:02 +0100)]
msdosfs: fix potential inode collision on FAT12 and FAT16

FAT file systems do not use inodes, instead all file meta-information
is stored in directory entries.

FAT12 and FAT16 use a fixed size area for root directories, with
typically 512 entries of 32 bytes each (for a total of 16 KB) on hard
disk formats. The file system data is stored in clusters of typically
512 to 4096 bytes, depending on the size of the file system.

The current code uses the offset of a DOS 8.3 style directory entry as
a pseudo-inode, which leads to inode values of 0 to 16368 for typical
root directories with 512 entries.

Sub-directories use 2 cluster length plus the byte offset of the
directory entry in the data area for the pseudo-inode, which may be
as low as 1024 in case of 512 byte clusters. A sub-directory in
cluster 2 and with 512 byte clusters will therefore lead to a
re-use of inode 1024 when there are at least 32 DOS 8.3 style
filenames in the root directory (or 11 14-character Windows
long file names, each of which takes up 3 directory entries).

FAT32 file systems are not affected by this issue and FAT12/FAT16
file systems with larger cluster sizes are unlikely to have as
many directory entries in the root directory as are required to
cause the collision.

This commit leads to inode numbers that are guaranteed to not collide
for all valid FAT12 and FAT16 file system parameters. It does also
provide a small speed-up due to more efficient use of the vnode cache.

PR:             277239
Reviewed by: mckusick
Approved by:    re (cperciva)

(cherry picked from commit 445d3d227e68f85157d0301d1706aa488e8423da)
(cherry picked from commit a495e7f5c5c2088bf32cd7349e2ca344ee089552)

2 months agotzcode: Fix overflow handling in TZ parser.
Dag-Erling Smørgrav [Sun, 18 Feb 2024 09:48:08 +0000 (10:48 +0100)]
tzcode: Fix overflow handling in TZ parser.

Obtained from: upstream 9fc11a27
MFC after: 1 week
PR: 276281
Approved by: re (cperciva)

(cherry picked from commit 1365bb722af1365baee6ea1e3d44917533908d53)
(cherry picked from commit beb958dca02abf79a2172e702c2d24bbccde60fa)

2 months agoacpi: Defer reserving resources for ACPI devices
John Baldwin [Thu, 22 Feb 2024 18:43:43 +0000 (10:43 -0800)]
acpi: Defer reserving resources for ACPI devices

The goal of reserving firmware-assigned resources is to ensure that
"wildcard" resource allocation requests will not claim an address
range that is actually in use even if no attached driver is actively
using that range.  However, the current approach can break in some
cases.

In particular, ACPI can enumerate devices behind PCI bridges that
don't show up in a normal PCI scan, but those device_t objects can end
up as direct children of acpi0.  Reserving resources for those devices
directly from acpi0 ends up conflicting with later attempts to reserve
the PCI bridge windows.

As a workaround, defer reserving unclaimed resources until after the
initial probe and attach scan.  Eventually this pass of reserving
unclaimed resources can be moved earlier, but it requires changes to
other drivers in the tree to permit enumerating devices and reserving
firmware-assigned resources in a depth-first traversal before
attaching devices whose drivers request wildcard allocations.

PR: 272507
Reported by: Justin Tocci <justin@tocci.org>
Reported by: john@feith.com, many others
Tested by: Oleg Sidorkin <osidorkin@gmail.com>, dch

(cherry picked from commit f2fcb68074a51a8b399dc80d4c03fbe98a0ab92c)
(cherry picked from commit eaa51e59e560c556d0a8273d29eea4309e6b6a4f)

Approved by: re (cperciva)

2 months agoheimdal: Fix NULL deref
Cy Schubert [Thu, 15 Feb 2024 15:41:07 +0000 (07:41 -0800)]
heimdal: Fix NULL deref

A flawed logical condition allows a malicious actor to remotely
trigger a NULL pointer dereference using a crafted negTokenInit
token.

Upstream notes:

    Reported to Heimdal by Michał Kępień <michal@isc.org>.

    From the report:

    Acknowledgement
    ---------------

    This flaw was found while working on addressing ZDI-CAN-12302: ISC BIND
    TKEY Query Heap-based Buffer Overflow Remote Code Execution
    Vulnerability, which was reported to ISC by Trend Micro's Zero Day

Security: CVE-2022-3116
Obtained from: upstream 7a19658c1
MFS requested by: re (cperciva)
Approved by: re (cperciva)

(cherry picked from commit fc773115fa2dbb6c01377f2ed47dabf79a4e361a)
(cherry picked from commit 6b421e431a2de6eb9e8bd670efffe76e6617d520)

2 months agoheimdal: always confirm PA-PKINIT-KX for anon PKINIT
Cy Schubert [Thu, 15 Feb 2024 01:58:06 +0000 (17:58 -0800)]
heimdal: always confirm PA-PKINIT-KX for anon PKINIT

Import upstream 38c797e1a.

Upstream notes:

    RFC8062 Section 7 requires verification of the PA-PKINIT-KX key
    excahnge when anonymous PKINIT is used.  Failure to do so can
    permit an active attacker to become a man-in-the-middle.

Reported by: emaste
Obtained from: upstream 38c797e1a
Security: CVE-2019-12098
MFS requested by: re (cperciva)
Approved by:  re (cperciva)

(cherry picked from commit 60616b445eb5b01597092fef5b14549f95000130)
(cherry picked from commit a311b9d70863f78c232d5622ee579c6cd45bb1d8)

2 months agoHeimdal: CVE-2018-16860 Heimdal KDC: Reject PA-S4U2Self with unkeyed checksum
Cy Schubert [Wed, 14 Feb 2024 20:04:30 +0000 (12:04 -0800)]
Heimdal: CVE-2018-16860 Heimdal KDC: Reject PA-S4U2Self with unkeyed checksum

Upstream's explanation of the problem:

    S4U2Self is an extension to Kerberos used in Active Directory to allow
    a service to request a kerberos ticket to itself from the Kerberos Key
    Distribution Center (KDC) for a non-Kerberos authenticated user
    (principal in Kerboros parlance). This is useful to allow internal
    code paths to be standardized around Kerberos.

    S4U2Proxy (constrained-delegation) is an extension of this mechanism
    allowing this impersonation to a second service over the network. It
    allows a privileged server that obtained a S4U2Self ticket to itself
    to then assert the identity of that principal to a second service and
    present itself as that principal to get services from the second
    service.

    There is a flaw in Samba's AD DC in the Heimdal KDC. When the Heimdal
    KDC checks the checksum that is placed on the S4U2Self packet by the
    server to protect the requested principal against modification, it
    does not confirm that the checksum algorithm that protects the user
    name (principal) in the request is keyed.  This allows a
    man-in-the-middle attacker who can intercept the request to the KDC to
    modify the packet by replacing the user name (principal) in the
    request with any desired user name (principal) that exists in the KDC
    and replace the checksum protecting that name with a CRC32 checksum
    (which requires no prior knowledge to compute).

    This would allow a S4U2Self ticket requested on behalf of user name
    (principal) user@EXAMPLE.COM to any service to be changed to a
    S4U2Self ticket with a user name (principal) of
    Administrator@EXAMPLE.COM. This ticket would then contain the PAC of
    the modified user name (principal).

Reported by: emaste
Security: CVE-2018-16860
Obtained from: Upstream c6257cc2c
MFS requested by: re (cperciva)
Approved by: re (cperciva)

(cherry picked from commit 24339377490f9e362d040712b534d2963decd2d7)
(cherry picked from commit 143a962d0e871c60b91589aa1045afdeca13742b)

2 months agoHeimdal: Fix transit path validation CVE-2017-6594
Cy Schubert [Wed, 14 Feb 2024 19:56:18 +0000 (11:56 -0800)]
Heimdal: Fix transit path validation CVE-2017-6594

Apply upstream b1e699103. This fixes a bug introduced by upstream
f469fc6 which may in some cases enable bypass of capath policy.

Upstream writes in their commit log:

    Note, this may break sites that rely on the bug.  With the bug some
    incomplete [capaths] worked, that should not have.  These may now break
    authentication in some cross-realm configurations.

Reported by: emaste
Security: CVE-2017-6594
Obtained from: upstream b1e699103
MFS requested by: re (cperciva
Approved by: re (cperciva)

(cherry picked from commit f8041e3628bd70cf5562a9c13eb3d6af8463e720)
(cherry picked from commit 9a7121454dc0f68af2687699d5feabf736692fa6)

2 months agomsdosfs: fix directory corruption after rename operation
Stefan Eßer [Sat, 17 Feb 2024 21:04:49 +0000 (22:04 +0100)]
msdosfs: fix directory corruption after rename operation

PR:             268005
Reviewed by:    mckusick
Approved by:    re (cperciva)

(cherry picked from commit 8b67c670a49b4efe7e1557121b5bbae682ea3bc7)
(cherry picked from commit 5f4753501e9cc59e0d15f849c9459478ea5c8dc7)

2 months agoMFS: MFC: MFV: zlib 1.3.1.
Xin LI [Sun, 18 Feb 2024 06:12:51 +0000 (22:12 -0800)]
MFS: MFC: MFV: zlib 1.3.1.

Approved by: re (cperciva)

(cherry picked from commit 6255c67c3d1a268535c50de74d3300fd86d8f15d)
(cherry picked from commit d111b1e4a0a78aa4de8c0b68f031fdcec3a15ea0)

2 months agoMFC: MFV: expat 2.6.0.
Xin LI [Sat, 17 Feb 2024 21:56:56 +0000 (13:56 -0800)]
MFC: MFV: expat 2.6.0.

Approved by: re (cperciva)

(cherry picked from commit 4543ef516683042d46f3bd3bb8a4f3f746e00499)
(cherry picked from commit 60cfaec917dad12ceab7450a518616668d9f1ed0)

2 months agoLinuxKPI: 802.11: lsta txq locking cleanup
Bjoern A. Zeeb [Wed, 14 Feb 2024 21:56:48 +0000 (21:56 +0000)]
LinuxKPI: 802.11: lsta txq locking cleanup

Rename the LSTA lock to LSTA_TXQ lock as that is really what it is and
put down the full set of macros.  Replace the init and destroy with the
macro invocation rather than direct code.

Put locking around the txq_ready unset and check. Move the taskq_enqueue
call under lock to be sure we do not call it anymore after txq_ready
got unset.

Leave a comment related to the node reference which is passed into the
TX path on the recvif mbuf pointer.

Approved by: re (cperciva)
Fixes: 0936c648ad0ee
PR: 274382 (possibly)
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D43909

(cherry picked from commit fa4e4257943650c0b5f58c01bb0bdfadea61dfb2)
(cherry picked from commit 763b10806cd4ebdcbd2b6753d4f50ec088dc57fb)

2 months agoLinuxKPI: 802.11: update the ni/lsta reference cycle
Bjoern A. Zeeb [Mon, 5 Feb 2024 14:51:08 +0000 (14:51 +0000)]
LinuxKPI: 802.11: update the ni/lsta reference cycle

Update the ni/lsta reference cycle, add extra checks and assertions.
This is to accomodate problems we were seeing based on net80211
behaviour (join1() and (*iv_update_bss)() as well as state changes for
new iv_bss nodes during an active session).
This should hopefully help to stabilise behaviour until the underlying
problems gets properly addressed (for this and all other device drivers).

Approved by: re (cperciva)
PR: 272607, 273985, 274003
Reviewed by: cc
Differential Revision: https://reviews.freebsd.org/D43753

(cherry picked from commit 0936c648ad0ee5152dc19f261e77fe9c1833fe05)
(cherry picked from commit 223edc1a3c2fc86dbc7fa0ecd00f26a85d7c7b43)

2 months agoLinuxKPI: 802.11: band-aid for invalid state changes after (*iv_update_bss)
Bjoern A. Zeeb [Sat, 3 Feb 2024 16:33:56 +0000 (16:33 +0000)]
LinuxKPI: 802.11: band-aid for invalid state changes after (*iv_update_bss)

With firmware based solutions we cannot just jump from an active session
to a new iv_bss node without tearing down state for the old and bringing
up the new node.  This likely used to work on softmac based cards/drivers
where one could essentially set the state and fire at will.

We track (*iv_update_bss) calls from net80211 and set a local flag that
we are out of synch and do not allow any further operations up the state
machine until we hit INIT or SCAN.  That means someone will take the state
down, clean up firmware state and then we can join again and build up
state.

Apparently this problem has been "known" for a while as native iwm(4) and
others have similar workarounds (though less strict) and can be equally
pestered into bad states.  For LinuxKPI all the KASSERTs just massively
brought this problem out.  The solution will be some rewrites in net80211.
Until then, try to keep us more stable at least and not die on second
join1() calls triggered by service netif start wlan0 and similar.

Approved by: re (cperciva)
PR: 271979, 271988, 275255, 263613, 274003
Sponsored by: The FreeBSD Foundation (2023, partial)
Reviewed by: cc
Differential Revision: https://reviews.freebsd.org/D43725

(cherry picked from commit 2ac8a2189ac6707f48f77ef2e36baf696a0d2f40)
(cherry picked from commit 184ccc414686ea32c64f063c081c7cc1adeae7c3)

2 months agoBump __FreeBSD_version for net80211 'struct ieee80211vap' changes
Bjoern A. Zeeb [Mon, 19 Feb 2024 08:35:44 +0000 (08:35 +0000)]
Bump __FreeBSD_version for net80211 'struct ieee80211vap' changes

Change 9b998db87c28 changed 'struct ieee80211vap' internals in net80211.
Given we do not have enough spares and the struct is allocated by
drivers, all wireless drivers have to be recompiled.
__FreeBSD_version is updated to 1303001 to track this change.

Approved by: re (cperciva)

2 months agonet80211: deal with lost state transitions
Bjoern A. Zeeb [Wed, 10 Jan 2024 10:14:16 +0000 (10:14 +0000)]
net80211: deal with lost state transitions

Since 5efea30f039c4 we can possibly lose a state transition which can
cause trouble further down the road.
The reproducer from 643d6dce6c1e can trigger these for example.
Drivers for firmware based wireless cards have worked around some of
this (and other) problems in the past.

Add an array of tasks rather than a single one as we would simply
get npending > 1 and lose order with other tasks.  Try to keep state
changes updated as queued in case we end up with more than one at a
time.  While this is not ideal either (call it a hack) it will sort
the problem for now.
We will queue in ieee80211_new_state_locked() and do checks there
and dequeue in ieee80211_newstate_cb().
If we still overrun the (currently) 8 slots we will drop the state
change rather than overwrite the last one.
When dequeing we will update iv_nstate and keep it around for historic
reasons for the moment.

The longer term we should make the callers of
ieee80211_new_state[_locked]() actually use the returned errors
and act appropriately but that will touch a lot more places and
drivers (possibly incl. changed behaviour for ioctls).

rtwn(4) and rum(4) should probably be revisted and net80211 internals
removed (for rum(4) at least the current logic still seems prone to
races).

PR: 271979, 271988, 275255, 263613, 274003
Sponsored by: The FreeBSD Foundation (in 2023)
Reviewed by: cc
Differential Revision: https://reviews.freebsd.org/D43389

(cherry picked from commit 713db49d06deee90dd358b2e4b9ca05368a5eaf6)

Given this changes the internal structure of 'struct ieee80211vap',
which gets allocated by the drivers, and we do not have enough
spares, all wireless drivers need to be recompiled.
Given we are forced to do the update, we leave fields in the middle
of the struct and add more spares at the same time.
__FreeBSD_version will get updated to 1303001 to be able to detect
this change.

Approved by: re (cperciva)

(cherry picked from commit a890a3a5ddf33acb0a4000885945b89156799b07)
(cherry picked from commit a7e1fc7f620d3341549c1380f550aaafbdb45622)

2 months agonet80211: make sure calls to (*iv_update_bss)() are locked
Bjoern A. Zeeb [Fri, 19 Jan 2024 14:52:03 +0000 (14:52 +0000)]
net80211: make sure calls to (*iv_update_bss)() are locked

It turned out thare various calls into (*iv_update_bss)(), that is
direct changes to vap->iv_bss in the old days, happened without
synchronisation.

Use locking assertions to document the requirement or status quo
at some callers given ic locking will eventually have to be dealt
with.

Approved by: re (cperciva)
Reviewed by: cc
Differential Revision: https://reviews.freebsd.org/D43512

(cherry picked from commit 49619f73151aeaca4cef5adf631253da04a46e19)
(cherry picked from commit f8ec0379435745d800ec149f9289401c792e61bb)

2 months agonet80211: fix a NULL deref in ieee80211_sta_join1()
Bjoern A. Zeeb [Tue, 16 Jan 2024 18:53:06 +0000 (18:53 +0000)]
net80211: fix a NULL deref in ieee80211_sta_join1()

When ieee80211_sta_join1() gets an obss without ni_nt trying to lock
that will cause a NULL pointer deref.  Check for the table to be
valid and deal with the obss node accordingly.

This can happen if sta_newstate() calls ieee80211_reset_bss() for
nstate == INIT and ostate != INIT.  ieee80211_reset_bss() itself
calls ieee80211_node_table_reset() which calls node_reclaim()
which ends up in ieee80211_del_node_nt() which does remove the
node from the table and sets ni_table to NULL.
That node (former iv_bss) can then be returned as obss in the
(*iv_update_bss)() call in join1().

Approved by: re (cperciva)
Reviewed by: adrian, cc
Differential Revision: https://reviews.freebsd.org/D43469

(cherry picked from commit 8a5a3e3d0436a2de9dc5c2c10bd9a471b6338233)
(cherry picked from commit 755a04671dd47390f6d49695a6ac9c2d31c9935c)

2 months agoLinuxKPI: 802.11: fix field order in ieee80211_key_conf
Bjoern A. Zeeb [Sun, 28 Jan 2024 00:51:23 +0000 (00:51 +0000)]
LinuxKPI: 802.11: fix field order in ieee80211_key_conf

When adding the new field link_id to struct ieee80211_key_conf, it
was erroneously placed at the end of the struct;  the zero-length
(variable sized) array for the key always needs to stay last.
Resort fields and add hopefully helpful comment to avoid the problem
in the future.

Approved by: re (cperciva)
Fixes: adff403fe7a87
Reviewed by: cc
Differential Revision: https://reviews.freebsd.org/D43635

(cherry picked from commit 828ce22f079df77b3bf52c4cf296959ea66bdc11)
(cherry picked from commit 1cf1f094680fe3bfd9836800f83ed0b79e180340)

2 months agonet80211: improve logging about state transitions lost
Bjoern A. Zeeb [Sun, 12 Nov 2023 23:51:14 +0000 (23:51 +0000)]
net80211: improve logging about state transitions lost

It is possible that we call ieee80211_new_state_locked() again before
a previous task finished to completion (not run yet or unlocked in
between) since 5efea30f039c4 (and follow-up).
In either case we would overwrite the new state and argument in the vap.

While most drivers somehow deal with that (or not), LinuxKPI 802.11 compat
code has KASSERTs to keep net80211, LinuxKPI and driver/firmware state in
sync and they may trigger due to a missing transition or more likely a
changed ni/lsta.

Enhance the wlandebug +state logging for these cases so they
are easier to debug.

While here remove the unconditional logging to the message buffer;
it has been here for a good decade but not helped to actually identify
and sort the problem.

Approved by: re (cperciva)
Sponsored by:   The FreeBSD Foundation
Reviewed by: cc
Differential Revision: https://reviews.freebsd.org/D42560

(cherry picked from commit 72bb33a36b62fa30f69f01d3f6ae372be2c95b59)
(cherry picked from commit a2764047702db519aca9e1b3cf6b475e5a723c65)

2 months agoLinuxKPI: 802.11: more TXQ implementation and locking
Bjoern A. Zeeb [Tue, 12 Dec 2023 01:59:17 +0000 (01:59 +0000)]
LinuxKPI: 802.11: more TXQ implementation and locking

Implement ieee80211_handle_wake_tx_queue() and ieee80211_tx_dequeue_ni()
while looking at the code.  They are needed by various wireless drivers.

Introduce an ltxq lock and protect the skbq by that.
This prevents panics due to a race between a driver upcall and
the net80211 tx downcall.  While the former should be rcu protected we
cannot rely on that.
It remains questionable if we need to protect further fields there
(with a different lock?).

Also introduce a txq_mtx on the lhw which needs to be further deployed
but we need to come up with a good strategy to not end up with 7 different
locks.

Approved by: re (cperciva)
Sponsored by: The FreeBSD Foundation
PR: 274178, 275710
Tested by: cc

(cherry picked from commit eac3646fcdd445297cade756630335e23e92ea13)
(cherry picked from commit 3df959638baa60c1c88e9ac66289502f99ad8418)

2 months agowpa: ctrl_iface set sendbuf size
Bjoern A. Zeeb [Sun, 12 Nov 2023 20:33:41 +0000 (20:33 +0000)]
wpa: ctrl_iface set sendbuf size

In order to avoid running into the default net.local.dgram.maxdgram
of 2K currently when calling sendto(2) try to set the sndbuf size to
the maximum ctrl message size.
While on 14 and 15 this does not actually raise the limit anymore (and
be7c095ac99ad29fd72b780c7d58949a38656c66 raised it for syslogd and this),
FreeBSD 13 still requires this change and it will work as expected there.
In addition we always ensure a large enough send buffer this way
independent of kernel defaults.
The problem occured, e.g., when the scan_list result had enough BSSIDs
so the text output would exceed 2048 bytes.

Approved by: re (cperciva)
Sponsored by: The FreeBSD Foundation
PR: 274990
Reviewed by: cy, adrian (with previous comment)
Differential Revision: https://reviews.freebsd.org/D42558

(cherry picked from commit 1edc20b76953d9ef571b0bcf89b206b98ed13d9b)
(cherry picked from commit 97186b5cf5aa1d97f1a4e8e1b811315a39fb163d)

2 months agoiwlwififw: add firmware for the Bz/B200 chipset
Bjoern A. Zeeb [Wed, 29 Nov 2023 21:33:23 +0000 (21:33 +0000)]
iwlwififw: add firmware for the Bz/B200 chipset

The iwlwifi driver already supports the chipset as "Bz TBD"
(also in 14.0).  Add the firmware for it.  Successfully tested
for 0x8086/0x272b/0x8086/0x00f4 on arm64 thanks to donated
hardware [1].

    Firmware was obtained from linux-firmware at
    9552083a783e5e48b90de674d4e3bf23bb855ab0 .

Sponsored by: The FreeBSD Foundation
Sponsored by: Martin Hoehne / minipci.biz (B200 card) [1]
Approved by: re (cperciva)

(cherry picked from commit b647615ede46af66cd0c8bd5a321d4a2cccdabe0)
(cherry picked from commit d1d5dbcf2539d708d36cd4239ea428914a63321d)

2 months agobwn: remove unused ic_headroom
Frank Hilgendorf [Wed, 13 Dec 2023 23:48:08 +0000 (23:48 +0000)]
bwn: remove unused ic_headroom

Unlike bwi(4), bwn(4) does not rely on ic_headroom (despite having it
set) but splits the bwn_txhdr (first) segment into its own transaction.
Remove ic_headroom to avoid net80211 troubles with not enough space in
the mbuf around ieee80211_mbuf_adjust().

PR: 275616
Approved by: re (cperciva)

(cherry picked from commit 59dba901f227420647e4856f03cb782a3375c220)
(cherry picked from commit 0f032804b6ec70c8f8ee4fe1ed83a3356946b5e8)

2 months agordmsr_safe/wrmsr_safe: handle pcb_onfault nesting
Andriy Gapon [Tue, 30 Jan 2024 06:45:01 +0000 (08:45 +0200)]
rdmsr_safe/wrmsr_safe: handle pcb_onfault nesting

rdmsr_safe and wrmsr_safe can be called while pcb_onfault is already
set, so the functions are modified to preserve the handler rather than
resetting it before returning.

One case where that happens is when AMD microcode update routine
is executed on a stack where copyin / copyout was already active.

Here is a sample panic message from a crash caused by resetting the
handler:

  <118>Updating CPU Microcode...

  Fatal trap 12: page fault while in kernel mode
  cpuid = 3; apic id = 03
  fault virtual address   = 0x11ed0de6000
  fault code              = supervisor write data, page not present
  instruction pointer     = 0x20:0xffffffff80c2df03
  stack pointer           = 0x28:0xfffffe01ce4a4c70
  frame pointer           = 0x28:0xfffffe01ce4a4c70
  code segment            = base 0x0, limit 0xfffff, type 0x1b
                          = DPL 0, pres 1, long 1, def32 0, gran 1
  processor eflags        = interrupt enabled, resume, IOPL = 0
  current process         = 117 (logger)
  trap number             = 12
  panic: page fault
  cpuid = 3
  time = 1681462027
  KDB: stack backtrace:
  db_trace_self_wrapper() at 0xffffffff80615deb = db_trace_self_wrapper+0x2b/frame 0xfffffe01ce4a4830
  kdb_backtrace() at 0xffffffff80943c77 = kdb_backtrace+0x37/frame 0xfffffe01ce4a48e0
  vpanic() at 0xffffffff808f5fe5 = vpanic+0x185/frame 0xfffffe01ce4a4940
  panic() at 0xffffffff808f5da3 = panic+0x43/frame 0xfffffe01ce4a49a0
  trap_fatal() at 0xffffffff80c31849 = trap_fatal+0x379/frame 0xfffffe01ce4a4a00
  trap_pfault() at 0xffffffff80c318b5 = trap_pfault+0x65/frame 0xfffffe01ce4a4a60
  trap() at 0xffffffff80c30f5f = trap+0x29f/frame 0xfffffe01ce4a4b80
  trap_check() at 0xffffffff80c31c29 = trap_check+0x29/frame 0xfffffe01ce4a4ba0
  calltrap() at 0xffffffff80c07fd8 = calltrap+0x8/frame 0xfffffe01ce4a4ba0
  --- trap 0xc, rip = 0xffffffff80c2df03, rsp = 0xfffffe01ce4a4c70, rbp = 0xfffffe01ce4a4c70 ---
  copyout_nosmap_std() at 0xffffffff80c2df03 = copyout_nosmap_std+0x63/frame 0xfffffe01ce4a4c70
  uiomove_faultflag() at 0xffffffff8095f0d5 = uiomove_faultflag+0xe5/frame 0xfffffe01ce4a4cb0
  uiomove() at 0xffffffff8095efeb = uiomove+0xb/frame 0xfffffe01ce4a4cc0
  pipe_read() at 0xffffffff80968860 = pipe_read+0x230/frame 0xfffffe01ce4a4d30
  dofileread() at 0xffffffff809653cb = dofileread+0x8b/frame 0xfffffe01ce4a4d80
  sys_read() at 0xffffffff80964fa0 = sys_read+0xc0/frame 0xfffffe01ce4a4df0
  amd64_syscall() at 0xffffffff80c3221a = amd64_syscall+0x18a/frame 0xfffffe01ce4a4f30
  fast_syscall_common() at 0xffffffff80c088eb = fast_syscall_common+0xf8/frame 0xfffffe01ce4a4f30
  --- syscall (3, FreeBSD ELF64, read), rip = 0x11ece41cfaa, rsp = 0x11ecbec4908, rbp = 0x11ecbec4920 ---
  Uptime: 41s

And another one:

  Fatal trap 12: page fault while in kernel mode
  cpuid = 4; apic id = 04
  fault virtual address   = 0x800a22000
  fault code              = supervisor write data, page not present
  instruction pointer     = 0x20:0xffffffff80b2c7ca
  stack pointer           = 0x28:0xfffffe01c55b5480
  frame pointer           = 0x28:0xfffffe01c55b5480
  code segment            = base 0x0, limit 0xfffff, type 0x1b
                          = DPL 0, pres 1, long 1, def32 0, gran 1
  processor eflags        = interrupt enabled, resume, IOPL = 0
  current process         = 68418 (pfctl)
  trap number             = 12
  panic: page fault
  cpuid = 4
  time = 1625184463
  KDB: stack backtrace:
  db_trace_self_wrapper() at 0xffffffff805c1e8b = db_trace_self_wrapper+0x2b/frame 0xfffffe01c55b5040
  kdb_backtrace() at 0xffffffff808874b7 = kdb_backtrace+0x37/frame 0xfffffe01c55b50f0
  vpanic() at 0xffffffff808449d8 = vpanic+0x188/frame 0xfffffe01c55b5150
  panic() at 0xffffffff808445f3 = panic+0x43/frame 0xfffffe01c55b51b0
  trap_fatal() at 0xffffffff80b300a5 = trap_fatal+0x375/frame 0xfffffe01c55b5210
  trap_pfault() at 0xffffffff80b30180 = trap_pfault+0x80/frame 0xfffffe01c55b5280
  trap() at 0xffffffff80b2f729 = trap+0x289/frame 0xfffffe01c55b5390
  trap_check() at 0xffffffff80b304d9 = trap_check+0x29/frame 0xfffffe01c55b53b0
  calltrap() at 0xffffffff80b0bb28 = calltrap+0x8/frame 0xfffffe01c55b53b0
  --- trap 0xc, rip = 0xffffffff80b2c7ca, rsp = 0xfffffe01c55b5480, rbp = 0xfffffe01c55b5480 ---
  copyout_nosmap_std() at 0xffffffff80b2c7ca = copyout_nosmap_std+0x15a/frame 0xfffffe01c55b5480
  pfioctl() at 0xffffffff85539358 = pfioctl+0x4d28/frame 0xfffffe01c55b5940
  devfs_ioctl() at 0xffffffff807176cf = devfs_ioctl+0xcf/frame 0xfffffe01c55b59a0
  VOP_IOCTL_APV() at 0xffffffff80bb26e2 = VOP_IOCTL_APV+0x92/frame 0xfffffe01c55b59c0
  VOP_IOCTL() at 0xffffffff80928014 = VOP_IOCTL+0x34/frame 0xfffffe01c55b5a10
  vn_ioctl() at 0xffffffff80923330 = vn_ioctl+0xc0/frame 0xfffffe01c55b5b00
  devfs_ioctl_f() at 0xffffffff80717bbe = devfs_ioctl_f+0x1e/frame 0xfffffe01c55b5b20
  fo_ioctl() at 0xffffffff808abc6b = fo_ioctl+0xb/frame 0xfffffe01c55b5b30
  kern_ioctl() at 0xffffffff808abc01 = kern_ioctl+0x1d1/frame 0xfffffe01c55b5b80
  sys_ioctl() at 0xffffffff808ab982 = sys_ioctl+0x132/frame 0xfffffe01c55b5c50
  syscallenter() at 0xffffffff80b30cc9 = syscallenter+0x159/frame 0xfffffe01c55b5ca0
  amd64_syscall() at 0xffffffff80b309a5 = amd64_syscall+0x15/frame 0xfffffe01c55b5d30
  fast_syscall_common() at 0xffffffff80b0c44e = fast_syscall_common+0xf8/frame 0xfffffe01c55b5d30

PR: 276426
Reviewed by: kib, markj
Approved by: re (cperciva)

(cherry picked from commit 486b265a8fb6b2aad37f2819fa04feacf8184d53)

2 months agovtnet: Avoid ifdefs based on __NO_STRICT_ALIGNMENT
Warner Losh [Mon, 5 Feb 2024 05:43:49 +0000 (22:43 -0700)]
vtnet: Avoid ifdefs based on __NO_STRICT_ALIGNMENT

Some platforms require an adjustment of the ethernet hearders. Rather
than make this be on __NO_STRICT_ALIGNMENT being defined, define
VTNET_ETHER_ALIGN to be either 0 or ETHER_ALIGN (aka 2). Add a test to
the if statements to only do them when != 0. This eliminates the #ifdef
sprinkled in the code, still communicates the intent and gives the same
compiled results.

Sponsored by: Netflix
Reviewed by: bz, bryanv
Differential Revision: https://reviews.freebsd.org/D43654

(cherry picked from commit 0ea4b4084845bfeedc8c692e4d34252023b78cb3)
(cherry picked from commit 9ae56ea964c89284a998a501e6cf1b57d000d968)

Approved-by: re (cperciva)
2 months agovtnet: Account for the padding when selecting allocation size
Warner Losh [Mon, 5 Feb 2024 05:43:39 +0000 (22:43 -0700)]
vtnet: Account for the padding when selecting allocation size

While we account for the padding in the length of the mbuf we use, we do
not account for it when we 'guess' the size of the mbuf to allocate
based in the MTU of the device. This leads to a situation where we might
fail if the mtu is close to a bucket size (say 2018) such that the added
padding would push us over the edge for a full-sized packet. mtu of 2018
is super rare (2016 and 2020 would both work), but fix it none-the-less.
It's a shame we can't just set VTNET_RX_HEADER_PAD to 2 in this case. The 4
seems hard-coded somewhere I've not found documented (I think it's in the
protocol given the comments about VIRTIO_F_ANY_LAYOUT).

Sponsored by: Netflix
Reviewed by: bz
Differential Revision: https://reviews.freebsd.org/D43656

(cherry picked from commit d9e0e42627613b56abf0f8fa1ad601e5690d775c)
(cherry picked from commit 1dc264a126b13e0e20b13bbcd69451c5d4b63f7c)

Approved-by: re (cperciva)
2 months agovtnet: Adjust for ethernet alignment.
Warner Losh [Mon, 29 Jan 2024 05:08:55 +0000 (22:08 -0700)]
vtnet: Adjust for ethernet alignment.

If the header that we add to the packet's size is 0 % 4 and we're
strictly aligning, then we need to adjust where we store the header so
the packet that follows will have it's struct ip header properly
aligned.  We do this on allocation (and when we check the length of the
mbufs in the lro_nomrg case). We can't just adjust the clustersz in the
softc, because it's also used to allocate the mbufs and it needs to be
the proper size for that. Since we otherwise use the size of the mbuf
(or sometimes the smaller size of the received packet) to compute how
much we can buffer, this ensures no overflows. The 2 byte adjustment
also does not affect how many packets we can receive in the lro_nomrg
case.

PR: 271288
Sponsored by: Netflix
Reviewed by: bryanv
Differential Revision: https://reviews.freebsd.org/D43224

(cherry picked from commit 3be59adbb5a2ae7600d46432d3bc82286e507e95)
(cherry picked from commit 778eb6e1f6668864a6eddd2f6f9bcc2aa26344f3)

Approved-by: re (cperciva)
2 months agosmartpqi: Drop spinlock before freeing memory
John F. Carr [Thu, 19 Oct 2023 03:02:42 +0000 (21:02 -0600)]
smartpqi: Drop spinlock before freeing memory

pqisrc_free_device frees the device softc with the os spinlock
held. This causes crashes when devices are removed because the memory
free might sleep (which is prohibited with spin locks held). Drop the
spinlock before releasing the memory.

MFC After: 2 days
PR: 273289
Reviewed by: imp

This is the alternate fix from the box.

(this is not a cherry pick of b064a4c9eed5b1dd2a40fc4fd2cb7e738b681547)

(cherry picked from commit 898e02d740741d13a8948cbad4e0d969a768fd30)

Approved-by: re (cperciva)
2 months agounbound: Vendor import 1.19.1
Cy Schubert [Mon, 13 Nov 2023 19:44:16 +0000 (11:44 -0800)]
unbound: Vendor import 1.19.1

Release notes at
    https://www.nlnetlabs.nl/news/2024/Feb/13/unbound-1.19.1-released/

Security: CVE-2023-50387, CVE-2023-50868
Approved by: re (cperciva)

(cherry picked from commit b76ef9a7cb8a7c62d10ae8101f41014f34819174)
(cherry picked from commit abe4ced2b9de0a3dd44d7e2068cfd7fa2b428c16)

2 months agograid: MFC: unbreak Promise RAID1 with 4+ providers
Eugene Grosbein [Mon, 12 Feb 2024 07:24:28 +0000 (14:24 +0700)]
graid: MFC: unbreak Promise RAID1 with 4+ providers

Fix a problem in graid implementation of Promise RAID1 created with 4+ disks.
Such an array generally works fine until reboot only due to a bug
in metadata writing code. Before the fix, next taste erronously created
RAID1E (kind of RAID10) instead of RAID1, hence graid used wrong offsets
for I/O operations.

The bug did not affect Promise RAID1 arrays with 2 or 3 disks only.

Reviewed by: mav
Approved-by: re (cperciva)

(cherry picked from commit 81092e92ea5184c4eeedad58044d72cfef72dd24)
(cherry picked from commit 77814c95994aab102be0e327de788dc1c00c023d)

2 months ago13.3: update to BETA3
Colin Percival [Thu, 15 Feb 2024 23:51:17 +0000 (15:51 -0800)]
13.3: update to BETA3

Approved by:    re (implicit)
Sponsored by:   https://www.patreon.com/cperciva

2 months agolld: work around elftoolchain bug which causes bloated RISCV binaries
Dimitry Andric [Wed, 14 Feb 2024 19:41:09 +0000 (20:41 +0100)]
lld: work around elftoolchain bug which causes bloated RISCV binaries

The elftoolchain strip(1) command appears to have trouble with the new
.riscv.attributes sections being added by lld 17 to RISCV binaries. This
causes huge 'holes' in the files, making them larger than necessary.

Since nothing in the base system uses the new section yet, patch lld to
leave it out for now.

Direct commit to stable/13, since this intended to go into the 13.3
release, while the elftoolchain bug is being investigated.

Reported by: karels
Submitted by: jrtc27
Approved by: re (cperciva)

(cherry picked from commit 42ceb92e6a544fa0956eb660b3c16e38189acf20)

2 months agoleapseconds: Update to the canonical place.
Warner Losh [Tue, 6 Feb 2024 23:11:38 +0000 (16:11 -0700)]
leapseconds: Update to the canonical place.

IERS is the source of truth for leap seconds. Their leapsecond file is
updated most quickly and is always right (unlike the IANA one which
often lags). IERS operates this public service for the express purpose
of random people downloading it. Their terms of service are compatible
with open source (we could include this in our release). Rather than
fighting with questions around this because the IANA one changed
locations or the auto update script broken, just use this.

This is in preference to the NIST ftp copy. NIST is in the process of
retiring their FTP services.

Sponsored by: Netflix
Reviewed by: philip, delphij, cy
Approved by: re (cperciva)
Differential Revision: https://reviews.freebsd.org/D43752

(cherry picked from commit 11da791920ba285f0832f09cb504ac81e35ff8d1)
(cherry picked from commit 0eea8292ae8c8e9119520ce54aa82cae491d83b9)

2 months agosched_setscheduler(2): Change realtime privilege check
Florian Walpen [Wed, 14 Feb 2024 13:50:44 +0000 (14:50 +0100)]
sched_setscheduler(2): Change realtime privilege check

Check for privilege PRIV_SCHED_SETPOLICY instead of PRIV_SCHED_SET, to
at least make it coherent with what is done at thread creation when
a realtime policy is requested, and have users authorized by
mac_priority(4) pass it.

This change is good enough in practice since it only allows 'root' (as
before) and mac_priority(4)'s authorized users in (the point of this
change), without other side effects.  More changes in this area, to
generally ensure that all privilege checks are consistent, are going to
come as olce's priority revamp project lands.

(olce: Expanded the explanations.)

PR:                     276962
Reported by:            jbeich
Reviewed by:            olce
Approved by:            emaste (mentor)
MFC after:              3 days
Differential Revision:  https://reviews.freebsd.org/D43835

(cherry picked from commit 2198221bd9df0ceb69945120bc477309a5729241)
(cherry picked from commit 8ff01d01f2e8894bbac9f179f1ab0e83a8160384)

Approved by:            emaste (mentor)
Approved by:            re (cperciva)

2 months agoMerge sendmail 8.18.1 from stable/13 to releng/13.3
Gregory Neil Shapiro [Wed, 31 Jan 2024 23:53:48 +0000 (23:53 +0000)]
Merge sendmail 8.18.1 from stable/13 to releng/13.3

Merge commit '850ef5ae11d69ea3381bd310f564f025fc8caea3'

Merge vendor sendmail 8.18.1 into HEAD

(cherry picked from commit d39bd2c1388b520fcba9abed1932acacead60fba)

Add new source file for sendmail 8.18.1

(cherry picked from commit 19d4fb85bf17579780e8f0c3cbae8a5e92a6922e)

New sendmail 8.18.1 cf file

(cherry picked from commit 1b6a5580c1f999fb1ba5f9860cf63a8aefc55b3c)

Minor change to update these files so new freebsd*.cf files are
generated

(cherry picked from commit 2c191ba6b0b5d1b3729a5ac428d51cfc5d5f3d2e)

Belatedly update version and date for sendmail 8.18.1 upgrade

(cherry picked from commit 31fbc98c949bfca30ab55afef04b4396a61b7e92)

Add a note about sendmail 8.18.1's stricter SMTP protocol enforcement
(akin to commit 21c1f1deb6a3ac6a60e4516261e5264a28e0b7a6 in main)

Update import date for stable/14

Relnotes: Yes
Security: CVE-2023-51765
Approved-by: re (cperciva)
(cherry picked from commit a64caf2cb2dc3ddd6f325e323c281d1463a80ccf)

2 months agocaroot: routine update
Kyle Evans [Sun, 11 Feb 2024 06:33:12 +0000 (00:33 -0600)]
caroot: routine update

Changes:
- One (1) modified
- Eight (8) added
- One (1) expired, now untrusted

Approved by: re (cperciva)
MFC after: 3 days

(cherry picked from commit 0d3b2bdbf719ac6b5719a47387558ca9c34a4b2c)
(cherry picked from commit 9b7611d9c7b48e68f017c43ec67d4182a4bc11c4)

2 months agofusefs: fix invalid value for st_birthtime.tv_nsec
Alan Somers [Thu, 25 Jan 2024 15:19:37 +0000 (08:19 -0700)]
fusefs: fix invalid value for st_birthtime.tv_nsec

If a file system's on-disk format does not support st_birthtime, it
isn't clear what value it should return in stat(2).  Neither our man
page nor the OpenGroup specifies.  But our convention for UFS and
msdosfs is to return { .tv_sec = -1, .tv_nsec = 0 }.  fusefs is
different.  It returns { .tv_sec = -1, .tv_nsec = -1 }.  It's done that
ever since the initial import in SVN r241519.

Most software apparently handles this just fine.  It must, because we've
had no complaints.  But the Rust standard library will panic when
reading such a timestamp during std::fs::metadata, even if the caller
doesn't care about that particular value.  That's a separate bug, and
should be fixed.

Change our invalid value to match msdosfs and ufs, pacifying the Rust
standard library.

PR: 276602
Sponsored by: Axcient
Reviewed by: emaste
Approved by: re (cperciva)
Differential Revision: https://reviews.freebsd.org/D43590

(cherry picked from commit 65e25e4a614a99243e7419279b294e399991dfff)

2 months agoinpcb: Restore some NULL checks of credential pointers
Mark Johnston [Wed, 7 Feb 2024 14:43:25 +0000 (09:43 -0500)]
inpcb: Restore some NULL checks of credential pointers

At least one out-of-tree port (net-mgmt/ng_ipacct) depends on being able
to call in_pcblookup_local() with cred == NULL, so the MFC of commit
ac1750dd143e ("inpcb: Remove NULL checks of credential references")
broke compatibility.

Restore a subset of the NULL checks to avoid breaking the module in the
13.3 release.  This is a direct commit to stable/13.

PR: 276868
Approved by: re (cperciva)

(cherry picked from commit fe8df7ed1aae444a09361c080d52bfcb6aaae64f)

2 months ago13.3: update to BETA2
Colin Percival [Fri, 9 Feb 2024 00:00:43 +0000 (16:00 -0800)]
13.3: update to BETA2

Approved by:    re (implicit)
Sponsored by:   https://www.patreon.com/cperciva

2 months agokern: tty: fix ttyinq_read_uio assertion
Kyle Evans [Tue, 16 Jan 2024 02:55:58 +0000 (20:55 -0600)]
kern: tty: fix ttyinq_read_uio assertion

It's clear from later context that `rlen` was always expected to include
`flen`, as we'll trim `flen` bytes from the end of the read.  Relax our
initial assertion to only require the total size less trimmed bytes to
lie within the out buffer size.

While we're here, I note that if we have to read more than one block and
we're trimming from the end then we'll do the wrong thing and omit
`flen` bytes from every block, rather than just the end.  Add an
assertion to make sure we're not doing that, but the only caller that
specifies a non-zero `flen` today will only really be doing so if rlen
is entirely within a single buffer.

Approved by: re (cperciva)
Reviewed by: cy, imp

(cherry picked from commit 09a43b8790bdeb97fbecd3ea767c2f599eb4a4d3)
(cherry picked from commit 81ef0de636ff8ba0b8057ced593f2ab92597b1a6)

2 months agocontrib/tzdata: import tzdata 2024a
Philip Paeps [Fri, 2 Feb 2024 02:01:39 +0000 (10:01 +0800)]
contrib/tzdata: import tzdata 2024a

Changes: https://github.com/eggert/tz/blob/2024a/NEWS

(cherry picked from commit 2723c7ffb7f729a1d3f7c59e7db48b0edf3d30a6)
(cherry picked from commit f4256acec1c980b7d08e9e526be6d2a7c4751f0b)

Approved by: re (karels)

2 months ago13.3: create releng/13.3 branch
Colin Percival [Fri, 2 Feb 2024 00:05:47 +0000 (16:05 -0800)]
13.3: create releng/13.3 branch

Update from PRERELEASE to BETA1
Switch pkg(8) configuration to use the quarterly repository
Bump __FreeBSD_version

Approved by:    re (implicit)
Sponsored by:   https://www.patreon.com/cperciva

2 months agosys/mount.h: use __inline
Konstantin Belousov [Tue, 30 Jan 2024 22:14:25 +0000 (00:14 +0200)]
sys/mount.h: use __inline

(cherry picked from commit f76cb7bd08e02d868e640b3442b2bc45edf8f56a)

2 months agologin_cap.h: Remove LOGIN_DEFPRI
Olivier Certner [Thu, 25 Jan 2024 22:25:10 +0000 (23:25 +0100)]
login_cap.h: Remove LOGIN_DEFPRI

This is an implementation detail which is likely to become irrelevant in
the future, as we move to not resetting the priority if the
corresponding capability is not present in the configuration file
('/etc/login.conf').

GitHub's code search and Google show no use of this public constant, and
it doesn't exist in OpenBSD and NetBSD.

So, remove this definition and its sole use in-tree.

PR:                     276570 (exp-run)
Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D43609

(cherry picked from commit c7e645269f1c7e9872a7ccf6b72f045c55a66793)

Approved by:            markj (mentor)

2 months agologin_cap.h: Remove LOGIN_DEFUMASK
Olivier Certner [Thu, 25 Jan 2024 22:10:40 +0000 (23:10 +0100)]
login_cap.h: Remove LOGIN_DEFUMASK

This public constant has not been used in-tree since 1997 (this was
noticed while working on previous commit "setusercontext(): umask: Set
it only once (in the common case)").

Since it was an implementation detail and GitHub's code search and
Google show no use of this symbol today, simply remove it.

PR:                     276570 (exp-run)
Reviewed by:            emaste, kib (earlier version, then part of D40344)
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D43608

(cherry picked from commit e3a396eb2a029e5dc9161469735aa3f7f16845d1)

Approved by:            markj (mentor)

2 months agosetusercontext(): Set priority from '~/.login_conf' as well
Olivier Certner [Tue, 30 May 2023 15:14:50 +0000 (17:14 +0200)]
setusercontext(): Set priority from '~/.login_conf' as well

Setting the process priority is done only when the current process'
effective UID corresponds to that for which context is to be set.
Consequently, setting priority is done with appropriate credentials and
will fail if the target user tries to raise it unduly via his
'~/.login_conf'.

PR:                     271751
Reviewed by:            kib, Andrew Gierth <andrew_tao173.riddles.org.uk>
Approved by:            emaste (mentor)
MFC after:              3 days
Relnotes:               yes
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40352

(cherry picked from commit f2a0277d3e51a6a839151eef17f466d0db2b7300)

Approved by:            markj (mentor)

2 months agologin.conf(5): Document priority's special value 'inherit'
Olivier Certner [Wed, 21 Jun 2023 08:39:47 +0000 (10:39 +0200)]
login.conf(5): Document priority's special value 'inherit'

Reviewed by:            emaste, yuripv (older version)
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40691

(cherry picked from commit 33d4ce5496efe96bbaa7663e298876395b1db62c)

Approved by:            markj (mentor)

2 months agosetclasspriority(): New possible value 'inherit'
Olivier Certner [Wed, 21 Jun 2023 08:53:37 +0000 (10:53 +0200)]
setclasspriority(): New possible value 'inherit'

It indicates to the login.conf machinery (setusercontext() /
setclasscontext()) to leave priority alone, effectively inheriting it
from the parent process.

PR:                     271749
Reviewed by:            emaste, yuripv
Approved by:            emaste (mentor)
MFC after:              3 days
Relnotes:               yes
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40690

(cherry picked from commit d162d7e2ad327ceada4102c5d6779f9ecd809502)

Approved by:            markj (mentor)

2 months agosetusercontext(): Move priority setting in new setclasspriority()
Olivier Certner [Mon, 29 May 2023 17:09:36 +0000 (19:09 +0200)]
setusercontext(): Move priority setting in new setclasspriority()

In preparation for setting priorities from '~/.login_conf' and to ease
reading of setusercontext().

No functional change.

Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40350

(cherry picked from commit 7b94ec550ef6e7b75d608e125e9b78478197d4e7)

Approved by:            markj (mentor)

2 months agologin.conf(5): Document priority's default and possible values
Olivier Certner [Wed, 21 Jun 2023 08:39:15 +0000 (10:39 +0200)]
login.conf(5): Document priority's default and possible values

Priority is reset to 0 if not explicitly specified.

While here, be more explicit about what "Initial priority (nice) level"
means and document that it is possible to set real-time or idle class'
priorities with this capability.

Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40689

(cherry picked from commit aa96945e71b0f724e6ce673194d23f58d2d637d3)

Approved by:            markj (mentor)

2 months agosetusercontext(): Better error messages when priority is not set correctly
Olivier Certner [Mon, 29 May 2023 16:39:04 +0000 (18:39 +0200)]
setusercontext(): Better error messages when priority is not set correctly

Polish the syslog messages to contain readily useful information.

Behavior of capability 'priority' is inconsistent with what is done for
all other contexts: 'umask', 'cpumask', resource limits, etc., where an
absence of capability means to inherit the value.  It is currently
preserved for compatibility, but is subject to change on a future major
release.

Reviewed by:            emaste, kib (older version)
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40349

(cherry picked from commit d988621b0c25209866ed5a98b1a8b20269935761)

Approved by:            markj (mentor)

2 months agologin.conf(5): Default values: Rename column, elaborate on absence of such
Olivier Certner [Mon, 29 May 2023 14:06:37 +0000 (16:06 +0200)]
login.conf(5): Default values: Rename column, elaborate on absence of such

Column "Notes" in fact only contains default values for capabilities, so
make this clear by renaming it to "Default".

Add a small introductory text mentioning it, and what an absence of
default value means (inheritance).

PR:                     271748
Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40347

(cherry picked from commit 92b2c4358f57ef84f161efd8370ba4832bd9261a)

Approved by:            markj (mentor)

2 months agosetlogincontext(): Comply to style(9)
Olivier Certner [Thu, 25 May 2023 14:29:22 +0000 (16:29 +0200)]
setlogincontext(): Comply to style(9)

Remove indentation by inverting the big 'if (lc)' and using 'return'.
Use explicit binary operators to produce booleans.

Reviewed by:            emaste, kib, dchagin
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40346

(cherry picked from commit 771d5c93ab5a3fb1701d9706df2ce87d6a9da6f3)

Approved by:            markj (mentor)

2 months agologin.conf(5): Document umask's special value 'inherit'
Olivier Certner [Wed, 21 Jun 2023 08:42:44 +0000 (10:42 +0200)]
login.conf(5): Document umask's special value 'inherit'

Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40688

(cherry picked from commit ea9bd448102b938ccb8d4b484684a6ba2d934931)

Approved by:            markj (mentor)

2 months agosetclassumask(): Accept 'inherit' as a value
Olivier Certner [Tue, 20 Jun 2023 19:41:04 +0000 (21:41 +0200)]
setclassumask(): Accept 'inherit' as a value

'inherit' explicitly indicates that the umask should not be changed.

Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Relnotes:               yes
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40687

(cherry picked from commit c328e6c6ccaa4cdf921c16d68a2f2c5992dd3b72)

Approved by:            markj (mentor)

2 months agosetusercontext(): Set umask in a separate function, setclassumask()
Olivier Certner [Tue, 20 Jun 2023 16:46:31 +0000 (18:46 +0200)]
setusercontext(): Set umask in a separate function, setclassumask()

Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40686

(cherry picked from commit 0dd1705f584947625892988afe59e4cedb5cdd09)

Approved by:            markj (mentor)

2 months agologin_cap(3): Document login_getcapenum()
Olivier Certner [Tue, 20 Jun 2023 20:09:57 +0000 (22:09 +0200)]
login_cap(3): Document login_getcapenum()

Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40685

(cherry picked from commit 97256feb7a65cccac51a03846c5308894a2cb445)

Approved by:            markj (mentor)

2 months agoNew login_getcapenum(): Allows to read named enum values
Olivier Certner [Tue, 20 Jun 2023 16:41:32 +0000 (18:41 +0200)]
New login_getcapenum(): Allows to read named enum values

Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40684

(cherry picked from commit 90e914cd5ac1c8ecbf1ea88e9a65e7fa866c17a9)

Approved by:            markj (mentor)

2 months agologin.conf(5): umask has no default value
Olivier Certner [Thu, 25 May 2023 12:41:03 +0000 (14:41 +0200)]
login.conf(5): umask has no default value

The umask is simply left unchanged if no explicit value is specified in
the login class capabilities database.

PR:                     271747
Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40345

(cherry picked from commit 0d1fe948d97d2d6e3708349b74cf438f9604a8d1)

Approved by:            markj (mentor)

2 months agosetusercontext(): umask: Set it only once (in the common case)
Olivier Certner [Thu, 25 May 2023 12:18:45 +0000 (14:18 +0200)]
setusercontext(): umask: Set it only once (in the common case)

Simplify the code and make it more coherent (umask was the only context
setting not modified by setlogincontext() directly).

Preserve the current behavior of not changing the umask if none is
specified in the login class capabilities database, but without the
superfluous umask() dance.  (The only exception to this is that
a special value no user is likely to input in the database now stands
for no specification.)

If some user has a 'umask' override in its '~/.login_conf', the umask
will still be set twice as before (as is the case for all other context
settings overriden in '~/.login_conf').

Log a warning in case of an invalid umask specification.

This change makes it apparent that the value of LOGIN_DEFUMASK doesn't
matter.  It will be removed in a subsequent commit.

PR:                     271747
Reviewed by:            emaste, kib (earlier version)
Approved by:            emaste
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40344

(cherry picked from commit e99c28e93bd4d04ff877459734e9ce06ad2335a7)

Approved by:            markj (mentor)

2 months agostand: Add 1440p to the list of known resolutions.
Dag-Erling Smørgrav [Tue, 23 Jan 2024 14:20:27 +0000 (15:20 +0100)]
stand: Add 1440p to the list of known resolutions.

MFC after: 1 week
Reviewed by: manu, kevans, imp
Differential Revision: https://reviews.freebsd.org/D43391

(cherry picked from commit 7edbf69b79c13debff251e6edfee1f57eeac3a6b)

2 months agoAdd kenv .Xr in kldload(8) and loader.conf(5)
Warner Losh [Thu, 21 Dec 2023 04:15:42 +0000 (21:15 -0700)]
Add kenv .Xr in kldload(8) and loader.conf(5)

Sponsored by: Netflix

(cherry picked from commit 64db9a0f82863d212ac0bcd49bc0254ccb9dd1ac)

3 months agoopen(2): describe *at behavior for dirfd opened without O_SEARCH
Konstantin Belousov [Mon, 29 Jan 2024 17:54:32 +0000 (19:54 +0200)]
open(2): describe *at behavior for dirfd opened without O_SEARCH

(cherry picked from commit a570fe4d0dd979ce099374259ffc45d56ae4e471)

3 months agompsutil: Clean up libutil deps
Mark Johnston [Wed, 24 Jan 2024 19:47:56 +0000 (14:47 -0500)]
mpsutil: Clean up libutil deps

mpsutil doesn't use libutil, so doesn't need to include libutil.h.  See
commit 76103694a051335bec1da318f9c6e3a676dc0145.

No functional change intended.

MFC after: 1 week

(cherry picked from commit d56ce5915c41517ccc7de2510daec200e100ef68)

3 months agojoin(1): Fix ordering in case of missing fields
Tijl Coosemans [Mon, 22 Jan 2024 10:35:31 +0000 (11:35 +0100)]
join(1): Fix ordering in case of missing fields

The comparison function had the ordering reversed causing join(1) to
miss some matching lines.

PR: 232405
Submitted by: Martijn van Duren <martijn@openbsd.org>

(cherry picked from commit 95bf75895ddcf17402b1f69dce26cb821c922476)

3 months agostable/13: bump __FreeBSD_version for kern_openatfp(9)
Konstantin Belousov [Wed, 31 Jan 2024 00:49:54 +0000 (02:49 +0200)]
stable/13: bump __FreeBSD_version for kern_openatfp(9)

Sponsored by: The FreeBSD Foundation

3 months agoAdd kern_openatfp(9)
Konstantin Belousov [Sat, 20 Jan 2024 20:34:46 +0000 (22:34 +0200)]
Add kern_openatfp(9)

(cherry picked from commit c662306e19ce60d0f5e5e32a22ddcd5c79a90849)

3 months agokern_openat(): minor style fixes
Konstantin Belousov [Sat, 20 Jan 2024 21:42:39 +0000 (23:42 +0200)]
kern_openat(): minor style fixes

(cherry picked from commit 3d59b93b207e5008ea0b79b38268243abf225546)

3 months agokern_openat(): rename fd argument to dirfd
Konstantin Belousov [Sat, 20 Jan 2024 21:41:12 +0000 (23:41 +0200)]
kern_openat(): rename fd argument to dirfd

(cherry picked from commit 2a284076ecb4d22928b78249070efa46153666ff)

3 months agoinet(3): clarify syntax accepted by inet_pton
Mike Karels [Sat, 27 Jan 2024 15:40:07 +0000 (09:40 -0600)]
inet(3): clarify syntax accepted by inet_pton

The section INTERNET ADDRESSES describes the acceptance of dotted
values with varying number of parts in multiple bases.  This applies
to inet_aton and inet_addr, but not to inet_pton.  Clarify this
section by listing the functions to which this applies.  Move the
description of what inet_pton accepts into this section from STANDARDS,
where it is easily missed.  Rename the section to clarify that it
applies only to IPv4.  (inet_pton also works with IPv6.)

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D43537

(cherry picked from commit 9231c42127bf8e47588169ecc395f57cae0e15fb)

3 months agoarm64/RPI: enable powerd by default on arm64-aarch64-RPI images
Mike Karels [Fri, 5 Jan 2024 19:41:24 +0000 (13:41 -0600)]
arm64/RPI: enable powerd by default on arm64-aarch64-RPI images

Most 64-bit Raspberry Pi models have a variable processor clock
speed that defaults to a slow speed (e.g. 600 MHz for a nominal
1.5 GHz clock).  This results in everything running slowly unless
or until powerd is started, and FreeBSD is then thought to be slow.
Enable powerd by default in /etc/rc.conf on the arm64-aarch64-RPI
images.  Tested on Raspberry Pi 3B+ and 4B so far.

PR: 256836
Reviewed by: rgrimes
Differential Revision: https://reviews.freebsd.org/D43296

(cherry picked from commit 4347ef60501f2a55ad31f7532ad903b81f3af18f)

3 months agoAdd libllvm and liblldb source files to enable WITH_ASAN build
Dimitry Andric [Sat, 27 Jan 2024 21:51:08 +0000 (22:51 +0100)]
Add libllvm and liblldb source files to enable WITH_ASAN build

This is another part of fixing the WITH_ASAN build. Some additional
source files had to be added to libllvm and liblldb, since the ASan
instrumentation causes symbols in those files to be referenced.

Reported by: markj
PR: 276597
MFC after: 3 days

(cherry picked from commit 5c38ea60a04199dae2c6e5db82461e7275c7def6)

3 months agomsun: remove fabs from Symbol.map, and adjust comment
Dimitry Andric [Sat, 27 Jan 2024 21:24:38 +0000 (22:24 +0100)]
msun: remove fabs from Symbol.map, and adjust comment

We have s_fabs.c, but fabs(3) is already provided by libc due to
historical reasons, so it is not compiled into libm. When the linker
does not use --undefined-version, this leads to a complaint about the
symbol being nonexistent, so remove it from Symbol.map.

While here, adjust the comment about some functions being supplied by
libc: while it is true that all these are indeed in libc, libm still
includes its own versions of frexp(3), isnan(3), isnanf(3), and
isnanl(3).

Reported by: Steve Kargl <sgk@troutmask.apl.washington.edu>
MFC after: 3 days

(cherry picked from commit d04e03c19a8d7660ea36f62720eef9bc96b69889)

3 months agoMerge commit 16a1ef86cbc5 from llvm-project (by David CARLIER):
Dimitry Andric [Sat, 27 Jan 2024 21:48:58 +0000 (22:48 +0100)]
Merge commit 16a1ef86cbc5 from llvm-project (by David CARLIER):

  [compiler-rt] remove hexdump interception. (#79378)

  a freebsd dev member reported a symbol conflict and intercepting this
  had little value anyway.

This is one part of fixing the WITH_ASAN build. Some executables in the
base system define their own hexdump() symbol, which would otherwise
conflict with the ASan-intercepted one.

Reported by: markj
PR: 276597
MFC after: 3 days

(cherry picked from commit 31aedef26fc0613f5d61204c624451d57e716ed9)

3 months agokern: tty: recanonicalize the buffer on ICANON/VEOF/VEOL changes
Kyle Evans [Tue, 16 Jan 2024 02:55:59 +0000 (20:55 -0600)]
kern: tty: recanonicalize the buffer on ICANON/VEOF/VEOL changes

Before this change, we would canonicalize any partial input if the new
local mode is not ICANON, but that's about it.  If we were switching
from -ICANON -> ICANON, or if VEOF/VEOL changes, then our internal canon
accounting would be wrong.

The main consequence of this is that in ICANON mode, we would
potentially hang a read(2) longer if the new VEOF/VEOL appears later in
the buffer, and FIONREAD would be similarly wrong as a result.

Reviewed by: kib

(cherry picked from commit 522083ffbd1ab9b485861750e889d606dc75ed0a)
(cherry picked from commit 5738d741fb796c1f0a6b5c2157af7de58104ac97)

3 months agokern: pts: do not special case closed slave side
Kyle Evans [Tue, 16 Jan 2024 02:55:59 +0000 (20:55 -0600)]
kern: pts: do not special case closed slave side

This would previously return 1 if the slave side of the pts was closed
to force an application to read() from it and observe the EOF, but it's
not clear why and this is inconsistent both with how we handle devices
with similar mechanics (like pipes) and also with other kernels, such as
OpenBSD/NetBSD and Linux.

PR:             239604
Reviewed by: kib

(cherry picked from commit 30189156d325fbcc9d1997d791daedc9fa3bed20)

3 months agokern: tty: fix EOF handling for canonical reads
Kyle Evans [Tue, 16 Jan 2024 02:55:58 +0000 (20:55 -0600)]
kern: tty: fix EOF handling for canonical reads

If the read(2) buffer is one byte short of an EOF, then we'll end up
reading the line into the buffer, then re-entering and seeing an EOF at
the beginning of the inq, assuming it's a zero-length line.

Fix this corner-case by searching one more byte than we have available
for an EOF.  If we found it, then we'll trim it here; otherwise, we'll
limit our read to just the space we have in the out buffer and the next
read(2) will (potentially) read the remainder of the line.

Fix FIONREAD while we're here to match what an application can expect
read(2) to return -- scan for the first break character in the part of
the input that's been canonicalized, we'll never return more than that.

PR: 276220
Reviewed by: cy, imp (both previous version), kib

(cherry picked from commit d51dac5f1370bdca1ea20c6b48cdea463f6f5dda)

3 months agoamdsmn(4), amdtemp(4): add support for Zen 4
Akio Morita [Tue, 1 Aug 2023 20:32:12 +0000 (22:32 +0200)]
amdsmn(4), amdtemp(4): add support for Zen 4

Zen 4 support, tested on Ryzen 9 7900

Reviewed by: imp (previous version), mhorne
Approved by: mhorne
Obtained from: http://jyurai.ddo.jp/~amorita/diary/?date=20221102#p01
Differential Revision: https://reviews.freebsd.org/D41049

(cherry picked from commit 323a94afb6236bcec3a07721566aec6f2ea2b209)

3 months agobhyve: Avoid underflows when handling remote commands
Mark Johnston [Tue, 23 Jan 2024 16:40:40 +0000 (11:40 -0500)]
bhyve: Avoid underflows when handling remote commands

Reviewed by: corvink, jhb
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D43480

(cherry picked from commit cfa2c78aee859bfc6549951bb6a36085fdd374e8)

3 months agoperiodic: Make daily diff(1) output as small is possible
Michael Osipov [Fri, 24 Nov 2023 09:26:41 +0000 (10:26 +0100)]
periodic: Make daily diff(1) output as small is possible

Make, by default, daily diff(1) ignore whitespace changes and the unified output
a context of zero (0) lines. This reduces output of unrelated lines in e-mails
delivered to root.

PR: 270266
Approved by: jrm (mentor), karels
MFC after: 1 month
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D42762

(cherry picked from commit e2f6bafc3887c7752986526f3758525d24701fce)

3 months agoperiodic: Make daily diff(1) flags configurable with daily_diff_flags
Michael Osipov [Fri, 24 Nov 2023 09:26:41 +0000 (10:26 +0100)]
periodic: Make daily diff(1) flags configurable with daily_diff_flags

PR: 270266
Approved by: jrm (mentor), karels
MFC after: 1 month
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D42900

(cherry picked from commit 15e35d058cff847d1a7bc671fcf48b99f5d2f73b)

3 months agoperiodic: Make security diff(1) output as small is possible
Michael Osipov [Fri, 24 Nov 2023 09:26:41 +0000 (10:26 +0100)]
periodic: Make security diff(1) output as small is possible

Make, by default, security diff(1) produce a unified output with a context of
zero (0) lines. This reduces output of unrelated lines in e-mails delivered
to root.

PR: 270266
Approved by: jrm (mentor), karels
MFC after: 1 month
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D43071

(cherry picked from commit 3aa71ea7c231a4e60a7e1b9b677e379e17432fc8)

3 months agoreleng-gce: Advertise the availability of UEFI support in GCE images.
Xin LI [Sat, 27 Jan 2024 03:09:39 +0000 (19:09 -0800)]
releng-gce: Advertise the availability of UEFI support in GCE images.

The amd64 and arm64 images supported UEFI, mark it as so users can take
advantage of UEFI boot on GCE.  This is already done on FreeBSD
14.0-RELEASE but never codified into the release tools (and should).

PR: conf/276532
Reviewed by: lwhsu
Differential Revision: https://reviews.freebsd.org/D43557

(cherry picked from commit 72dd306e44bc531fa723f4cdb631cb63cc5f09cb)

3 months agowg: detach bpf upon destroy as well
Aaron LI [Mon, 22 Jan 2024 16:18:56 +0000 (10:18 -0600)]
wg: detach bpf upon destroy as well

bpfattach() is called in wg_clone_create(), but the bpfdetach() is
missing from wg_close_destroy().  Add the missing bpfdetach() to avoid
leaking both the associated bpf bits as well as the ifnet that bpf will
hold a reference to.

PR: 276526

(cherry picked from commit 43be2d7aaf25b719aec8f49aab110c0061f1edec)

3 months agoif_wg: fix access to noise_local->l_has_identity and l_private
Aaron LI [Wed, 17 Jan 2024 23:29:23 +0000 (23:29 +0000)]
if_wg: fix access to noise_local->l_has_identity and l_private

These members are protected by the identity lock, so rlock it in
noise_remote_alloc() and then assert that we have it held to some extent
in noise_precompute_ss().

PR: 276392

(cherry picked from commit 7a4d1d1df0b2e369adcb32aea9ef8c180f885751)

3 months agoif_wg: fix erroneous calculation in calculate_padding() for p_mtu == 0
Aaron LI [Wed, 17 Jan 2024 23:29:23 +0000 (23:29 +0000)]
if_wg: fix erroneous calculation in calculate_padding() for p_mtu == 0

In practice this is harmless; only keepalive packets may realistically have
p_mtu == 0, and they'll also have no payload so the math works out the same
either way.  Still, let's prefer technical accuracy and calculate the amount
of padding needed rather than the padded length...

PR: 276363

(cherry picked from commit b891f61ef538a4e9b4658b4b756635c8036a5788)

3 months agocondvar: Fix a user-after-free in _cv_wait() when ktrace is enabled
Mark Johnston [Mon, 15 Jan 2024 17:29:02 +0000 (12:29 -0500)]
condvar: Fix a user-after-free in _cv_wait() when ktrace is enabled

When a thread wakes up after sleeping on a CV, it must not dereference
the CV structure, as it may already have been freed.  At least ZFS
relies on this invariant, see commit
c636f94bd2ff15be5b904939872b4bce31456c18 for example.

Thus, when logging context-switch events, copy the wmesg into a stack
buffer while it is still safe to do so, and log that after waking up.

While here, move the initial ktrcsw() call later, after assertions and
the SCHEDULER_STOPPED_TD() condition are checked.

Reported by: syzkaller
Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D43450

(cherry picked from commit a5ef95cd228e43bcc459a5c8a9911e57888ba5fd)

3 months agocondvar: Clean up condvar.h a bit
Mark Johnston [Mon, 15 Jan 2024 17:27:11 +0000 (12:27 -0500)]
condvar: Clean up condvar.h a bit

- Remove a typedef that has been unused for a long time.
- Remove a LOCORE guard.  MI headers like condvar.h don't need such a
  guard in general.
- Move a forward declaration into the _KERNEL block.
- Add a types.h include to make the file self-contained.

Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D43449

(cherry picked from commit 61b0092be751b8241b65cc14e4167d431f1e5ad8)

3 months agorc.d/kdc: Support start of MIT krb5kdc
Cy Schubert [Sat, 20 Jan 2024 13:52:35 +0000 (05:52 -0800)]
rc.d/kdc: Support start of MIT krb5kdc

Some users wishing to use the MIT krb5kdc have discovered the
kdc script workaround applied to the MIT krb5 ports is insufficient.
Let's build into this rc script the smarts to determine whether
base or ports Hiemdal kdc is being invoked or the MIT krb5kdc.

While at it, remove kdc_start_precmd(). This will simplify a future
jail patch.

Suggested by: netchild
Original patch: netchild
Reviewed by: emaste, netchild
Differential Revision: https://reviews.freebsd.org/D43523

(cherry picked from commit 91f78c32befa08bf4010db7afd4407277a3e585f)

3 months agobhyve nvme: Add NQN value
Chuck Tuffli [Thu, 12 Oct 2023 22:04:17 +0000 (15:04 -0700)]
bhyve nvme: Add NQN value

Add a NVMe Qualified Name (NQN) to the Controller Data structure using
the "first format" (i.e., "... used by any organization that owns a
domain name" Section 7.9 NVM-Express 1.4c 2021.06.28 Ratified).

This avoids a Linux kernel warning about a missing or invalid NQN.

(cherry picked from commit 32557d16e2c3c24c04eccfafd895e1514dc65b35)

3 months agoFix issue with Linux guest XHCI tablet probing.
Peter Grehan [Sun, 14 Jan 2024 11:27:12 +0000 (21:27 +1000)]
Fix issue with Linux guest XHCI tablet probing.

The USB3 spec mandates that the device-descriptor max packet size
be 512 bytes, which requires a field size of 9 since it is a
power-of-2.

Linux kernels recently started validating this field, resulting in
the table not being probed and the cursor not working in bhyve VNC.

PR: 275760

(cherry picked from commit 0c243cd4a3671bf728f33378ac593c08d8367bc2)

3 months agohv_kbd: Fix build with EVDEV_SUPPORT kernel option disabled.
Vladimir Kondratyev [Thu, 22 Apr 2021 22:13:25 +0000 (01:13 +0300)]
hv_kbd: Fix build with EVDEV_SUPPORT kernel option disabled.

Reported by: olivier
PR: 268653

(cherry picked from commit 55eb41bb1fb69429330ea415fb463735ae08da64)