291170 Commits

Author SHA1 Message Date
Mark Johnston
b83465493a socket: Move SO_SETFIB handling to protocol layers
In particular, we store a FIB number in both struct socket and in struct
inpcb.  When updating the FIB number with setsockopt(SO_SETFIB), make
the update atomic.  This is required to support the new bind_all_fibs
mode, since in that mode changing the FIB of a bound socket is not
permitted.

This requires a bit more code, but avoids a layering violation in
sosetopt(), where we hard-code the list of protocol families that
implement SO_SETFIB.

Reviewed by:	glebius
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D48666

(cherry picked from commit caccbaef8e263b1d769e7bcac1c4617bdc12d484)
2025-05-09 10:59:59 +02:00
Mark Johnston
f1d89386bc rawip: Take the inpcb lock when appropriate in rip_ctloutput()
Reviewed by:	glebius
MFC after:	1 week
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D48344

(cherry picked from commit fd94571ccf0c9c6521063c08a72a760873e87897)
2025-05-09 10:59:55 +02:00
Gleb Smirnoff
a47d77f946 netlink/route: validate family attribute
PR:			283818
(cherry picked from commit cdacb12065e4d85416655743da5bc6b17a9d9119)
2025-05-09 10:53:21 +02:00
Gleb Smirnoff
5add872c4e netlink/route: fix fib number validation in old Linux compat mode
The value passed via old field also needs to be validated.

PR:			283848
Fixes:			f34aca55adef1e28cd68b2e6705a0cac03f0238e
(cherry picked from commit 031fbf8dc962ca8d458b217ba2b4a9e637b7e932)
2025-05-09 10:53:20 +02:00
Gleb Smirnoff
4cd043bb63 netlink/route: fix nlattr_get_multipath() to check length
of supplied nexthop sub-attributes.  While here, use unsigned types for
length calculations and improve style(9).

PR:			283860
(cherry picked from commit 49a6e213416b5c0c9eccdff0af1c6b01f34c3693)
2025-05-09 10:53:08 +02:00
Bjoern A. Zeeb
96eb3eda54 rtw89: make wow.c compile
So far we have not compiled wow.c given we do not enable CONFIG_PM
yet.
Make the necessary file local adjustments to make the file compile
once further changes in LinuxKPI 802.11 code are comitted.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 848fdcae0326db5b7c3edd2e8c264d25254abe1d)
2025-05-09 10:50:56 +02:00
Bjoern A. Zeeb
75a6ccfd21 rtw89: merge Realtek's rtw89 driver based on Linux v6.14
This version is based on
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
38fec10eb60d687e30c8c6b5420d86e8149f7557 ( tag: v6.14 ).

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit df279a26d3315e7abc9e6f0744137959a4c2fb86)
2025-05-09 10:50:16 +02:00
Bjoern A. Zeeb
53e30a7797 rtw88: merge Realtek's rtw88 driver based on Linux v6.14
This version is based on
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
38fec10eb60d687e30c8c6b5420d86e8149f7557 ( tag: v6.14 ).

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit a0ccc12f6882a886d89ae279c541b2c2b62c6aca)
2025-05-09 10:49:54 +02:00
Bjoern A. Zeeb
664a23a948 fwget / mt76: update script to extra firmware and update fget(8)
Update the script to support all the sub-drivers we compile now.
Some minor polishing as well.

Update fwget(8) as more IDs were added.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 91f53f4e062715d869f2cb7e957707255390b704)
2025-05-09 10:49:08 +02:00
Bjoern A. Zeeb
ffb647ace6 iwlwififw: remove Intel iwlwifi firmware from src.git
Following the example of rtw88 and rtw89 only ship iwlwifi firmware
from ports/packages.  Users are asked to run fwget(8) to install the
firmware needed for their system or build it from ports
(see also UPDATING).

This is the end of a long story adding wireless support to fwget(8),
migrating the firmware for multiple branches into ports, splitting them
up into flavors, and updating some install media and the installer to
provide firmware.

The overall amount for new firmware amongst all drivers would have
added more than 100M of binary blobs to src.git for the first import,
ignoring future updates which (along with some duplication between
multiple drivers) was considered too much.

While maintenance within the src tree certainly would have been
easier in the longer term this seems to be the better solution and
I would like to thank everyone who helped along the path to get there.

The iwlwififw.4 man page is to stay (for now) and will likely point
at the appropriate firmware package flavor in the future as well
so people may find it easier to transition.  In the long term this
information is likely not needed anymore.

Sponsored by:	The FreeBSD Foundation
Requested by:	core (Oct 2022)
Reviewed by:	thj, jrm (earlier)
Differential Revision: https://reviews.freebsd.org/D49713

(cherry picked from commit 558d638896239f9cd25b9d825ecfce62ec54681e)
(cherry picked from commit 918783b75aacb051f2f83dd0198ef68bc9fa5326)
2025-05-09 10:48:34 +02:00
Bjoern A. Zeeb
ffea740fa3 LinuxKPI: 802.11: updates to headers for driver update
Move some structs into the appropriate header to be visible.
Add new fields to structs and enums.

Remove arguments from two functions (one function currently unused
by drivers in the tree, for the other the argument was unused).
Adjust the iwlwifi accordingly.  This is in preparation for new
driver versions to allow a smooth transition.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit e6010da63903cc6d9aac0077ab861cfd6bae2aa7)
2025-05-09 10:46:30 +02:00
Bjoern A. Zeeb
0e403fb365 iwlwifi: make mvm/d3.c compile again
Given we currently do not ompile the file by default make it compile
again after the last vendor import.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 52a43041d2a864961f0a1a109a7a7c4c6ebed918)
2025-05-09 10:46:19 +02:00
Bjoern A. Zeeb
538b8e3a0c iwlwifi: fix iwl_uefi_get_uats_table() if not compiled with ACPI
Apply a temporary fix to FreeBSD only to allow AX101 to proceed
further.  While this fix results in a debug error message if
firmware debugging is on we currently take this for the version
we have.  A proper fix will eventually show up in future versions
of iwlwifi.

Sponsored by:	The FreeBSD Foundation
Reported by:	bapt
Tested by:	bapt

(cherry picked from commit 97ddb6371b7206c622de40745927e98f0dfd2e85)
2025-05-09 10:46:18 +02:00
Lexi Winter
d9cbfa3794 sys/net: add DOT1Q_VID_{MIN,MAX}
add a new typedef in if_vlan_var.h to represent the lowest (1) and
highest (4095) valid VLAN IDs in a .1q tag.

change if_vlan to use DOT1Q_VID_MAX instead of a magic number.

Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D49837

(cherry picked from commit c59492025073bd57c7dc3bb5bd843ab0a1391c7a)
2025-05-09 10:32:22 +02:00
Lexi Winter
7b4478faed net/if_dl.h: make self-contained
include <sys/_types.h> for u_char and u_short.

to avoid including <sys/types.h>, remove the caddr_t cast from LLADDR.
we are trying to get rid of caddr_t anyway, and since sdl_data is
already an array of char, the cast is unnecessary.  this also makes
LLADDR const-correct, i.e. passing a const sockaddr_dl will return a
const pointer.

Reviewed by:	des
Approved by:	des (mentor)
Differential Revision:	https://reviews.freebsd.org/D50065

(cherry picked from commit 70b5c918571b6c79459ee6de66ceb4c83974d542)
2025-05-09 10:32:04 +02:00
Lexi Winter
8f5c1ee027 net/if_dl.h: put kernel decls behind _KERNEL
Reviewed by:	des
Approved by:	des (mentor)
Differential Revision:	https://reviews.freebsd.org/D50063

(cherry picked from commit a5ba03f6e4f003022968b50161abac24c7ec1d38)
2025-05-09 10:31:50 +02:00
Lexi Winter
508527ece9 bridge: define VLANTAGOF correctly
to avoid strange precedence errors, enclose the macro body in
parentheses.  this fixes constructs like: if (VLANTAGOF(m) == i)

Reviewed by:	kp

(cherry picked from commit f36292f010fcc6391605182f2973fdc12a3bd15f)
2025-05-09 10:31:41 +02:00
Michael Tuexen
5a77dc8816 tcp: improve KASSERT in limited retransmit
When doing a limited retransmit, allow up to 2 * MSS - 1 if the
Nagle algorithm has been disabled.

PR:			282605
Reviewed by:		cc, Peter Lei
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D49922

(cherry picked from commit 934caaec3afc43638c2a1da8fbe3b672566db4fe)
2025-05-09 10:31:26 +02:00
Mark Johnston
c765383ae0 bpf: Make bpf.h self-contained
PR:		286539
MFC after:	3 days

(cherry picked from commit 981af1192cfa5ecd7bee9fe47386ed9d45397828)
2025-05-09 10:30:09 +02:00
Konstantin Belousov
198e364789 net/sff8472.h: add double-include protection
(cherry picked from commit 6cb5f1629e6f89a468e34625fd4a35ce4585500f)
2025-05-09 10:29:33 +02:00
Philip Paeps
0381600e81 Add UPDATING entries and bump version
Approved by:	so
25.1.6
2025-05-06 17:20:25 +02:00
Michael Osipov
562f14a40a caroot: update the root bundle
Summary:
- Seven (7) new roots
- Four (4) distrusted roots
- Fifteen (15) removed (expired) roots

Approved by:	so
Security:	FreeBSD-EN-25:08.caroot
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D49294

(cherry picked from commit 0100da4deb96e15acf72d7655127c6faafa4148f)
(cherry picked from commit 7577dae4d67216c602dc11e2388d190a2c9dc9ff)
2025-05-06 17:20:23 +02:00
Enji Cooper
f2178c2250 openssl: Import OpenSSL 3.0.16
This release incorporates the following bug fixes and mitigations:
- [CVE-2024-13176](https://www.openssl.org/news/vulnerabilities.html#CVE-2024-13176
- [CVE-2024-9143](https://www.openssl.org/news/vulnerabilities.html#CVE-2024-9143)

Release notes can be found at:
https://openssl-library.org/news/openssl-3.0-notes/index.html

Approved by:	so
Security:	FreeBSD-EN-25:07.openssl
Differential Revision:  https://reviews.freebsd.org/D49296
Differential Revision:	https://reviews.freebsd.org/D49297

(cherry picked from commit 0d0c8621fd181e507f0fb50ffcca606faf66a8c2)
(cherry picked from commit cb29db243bd09d16604435639ae43ef7af0ea254)
(cherry picked from commit d2a55e6a9348bb55038dbc6b727ab041085f22db)
(cherry picked from commit 0d61082e3c64a43f52ec5f1bf3d85671d97d9514)
2025-05-06 17:20:21 +02:00
Kyle Evans
bc11b3952e daemon: stop rebuilding the kqueue every restart of the child
We populate the kqueue with all of four kevents: three signal handlers and
one for read of the child pipe.  Every time we start the child, we rebuild
this kqueue from scratch for the child and tear it down before we exit and
check if we need to restart the child.  As a consequence, we effectively
drop any of the signals we're interested in between restarts.

Push the kqueue out into the daemon state to avoid losing any signal events
in the process, and reimplement the restart timer in terms of kqueue timers.
The pipe read event will be automatically deleted upon last close, which
leaves us with only the signal events that really get retained between
restarts of the child.

Approved by:	so
Security:	FreeBSD-EN-25:06.daemon
PR:		277959
Reviewed by:	des, markj

(cherry picked from commit bc1dfc316a2bba97773a14b96f5e976a52524be4)
(cherry picked from commit 7ea2874eadf901b1187772670169b6fc3a44d917)
2025-05-06 17:20:20 +02:00
Philip Paeps
e90c35f8f7 contrib/expat: update libexpat from 2.6.0 to 2.7.1
Changes: https://github.com/libexpat/libexpat/blob/R_2_7_1/expat/Changes

Note that libbsdxml(3) is only intended to used by utilities in the
FreeBSD base system.  None of the vulnerabilities addressed by expat
releases 2.6.1 - 2.7.1 is exploitable on FreeBSD as supported by the
security-officer@ team.

Approved by:	so
Security:	FreeBSD-EN-25:05.expat
Security:	CVE-2024-8176
Security:	CVE-2024-50602
Security:	CVE-2024-45490, CVE-2024-45491, CVE-2024-45492
Security:	CVE-2024-28757

(cherry picked from commit ffd294a1f4c23863c3e515d16dce31d5509bcb01)
(cherry picked from commit 7fcc9d60956fc482d14acd579786390b989a5057)
(cherry picked from commit ba23ab2168ffabc2c5e647a1a37ab9a8fb482bb8)
(cherry picked from commit 8c7e4d11fef6ba9d5fc26571f72b8d877b0c1efb)
(cherry picked from commit 908f215e80fa482aa953c39afa6bb516f561fc00)
(cherry picked from commit 78ab4c182b9faa09688a040b252ba111952e5e17)
(cherry picked from commit fe9278888fd4414abe2d922e469cf608005f4c65)
(cherry picked from commit 6f7ee9ac036ebd210d70cb177eba0c3c5bc930e3)
(cherry picked from commit 03a1992591b0ae85b6b250255fe56e17f6d919c6)
(cherry picked from commit 50c58014795c63813c508bce59c97895ae2ca3c7)
(cherry picked from commit 00c8538e87c61f1fd57ccd9e02a6d435b68d9a73)
(cherry picked from commit fd4592006b1306e1d63a542612fd66a8374d181f)
2025-05-06 17:20:18 +02:00
Philip Paeps
3ec3c20633 contrib/tzdata: import tzdata 2025b
Changes: https://github.com/eggert/tz/blob/2025b/NEWS

Approved by:	so
Security:	FreeBSD-EN-25:04.tzdata

(cherry picked from commit d2cccdef30376b7de5643caae1ef035f8e6932f0)
(cherry picked from commit 475082194ac811a925bf4a8109ef5e4f4f485dad)
2025-05-06 17:20:17 +02:00
Kristof Provost
fbc370fe5e pfctl: also remove incorrect counter print for rule anchors
Just as for nat anchors we can't print counters for rule anchors. Remove the
incorrect print call.

MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 0fc3c29fb3dd6ab6436a78c502544ebf2cf63ee2)
2025-05-06 14:04:37 +02:00
Kristof Provost
ec7fc9e700 pfctl: fix crash on "pfctl -a '*' -vvsr"
When printing a nat anchor we don't have rule information, or rule
counters. Do not attempt to print them. The information is nonsensical
anyway, and this can cause a crash converting the timestamp to a string,
as years in the very distant future use more digits, and we exceed the
30 byte buffer allocated for this.

MFC after:	2 weeks
Sponsored by:	Orange Business Services

(cherry picked from commit 168d873ae41fd8bd40555322a79c9f215cb4cb9c)
2025-05-06 14:04:25 +02:00
Navdeep Parhar
52f8e7b2ef libifconfig: Fix nits in the descriptions of active 100G cables.
This is a cosmetic change affecting the "plugged: ..." line in the
output of ifconfig -v.  Both the 100G active cables were missing a
closing parenthesis.

Sponsored by:	Chelsio Communications

(cherry picked from commit 6460c327f6f3fdf2d1cd4db648baf6cb7d74828e)
2025-05-06 13:59:31 +02:00
Mark Johnston
f2c1486767 netinet: Make ip.h self-contained
In general we are working towards making public headers self-contained.

cdefs.h is included for __packed; just assume that types.h includes
cdefs.h as that's a very common assumption.

PR:		285924
Reviewed by:	emaste
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D49735

(cherry picked from commit 31d3a94bdda4a9ca4c4d7d4e8e8a0ba1b05c7f18)
2025-05-06 13:58:54 +02:00
Aaron LI
dd8a02d0ba wg: Improve wg_peer_alloc() to simplify the calling
Move the necessary extra logics (i.e., noise_remote_enable() and
TAILQ_INSERT_TAIL()) from wg_ioctl_set() to wg_peer_alloc(), and thus
make it easier to be called.  Actually, the updated version is more
asymmetric to wg_peer_destroy() and thus less likely to be misused.
Meanwhile, rename it to wg_peer_create() to look more consistent with
wg_peer_destroy().

Reviewed by:	aly_aaronly.me (diff), markj
Obtained from:	DragonflyBSD 902964ab24ba (with some changes)

(cherry picked from commit 7121e9414f294d116caeadd07ebd969136d3a631)
2025-05-06 13:58:41 +02:00
Zhenlei Huang
3b44f6fb78 bnxt_en: Retrieve maximum of 128 APP TLVs
It appears that the maximum number of APP TLVs supported by the hardware
is 128 according to D45005. Well Daniel Porsch reported an issue PR284073
which shows that the number can exceed the limit, causing out of bound
write to on-stack allocated variable app[128] and the kernel panics.

Limit to 128 while retrieving APP TLVs.

PR:		284073
Reviewed by:	markj
Tested by:	Daniel Porsch <daniel.porsch@loopia.se>
Fixes:	35b53f8c989f bnxt_en: Add PFC, ETS & App TLVs protocols support
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D48589

(cherry picked from commit 3de231b4d956f7b9c22e31f75805030a417f7bf3)
2025-04-28 14:33:37 +02:00
Franco Fichtner
52bb0884e6 Revert "amd64 GENERIC: Switch uart hints from "isa" to "acpi""
This reverts commit 74b9fc7adcf4afb1c3039267e338c3cfdf022957.
2025-04-22 13:36:11 +02:00
Kristof Provost
3e87bbe233 pfctl: fix recursive printing of NAT rules
pfctl_show_nat() is called recursively to print nat anchors. This passes the
anchor path, but this path was modified by pfctl_show_nat(), leading to issues
printing the anchors.

Make a copy of the path ('npath') before we modify it. Ensure we do this
correctly by sprinking in 'const', and add a test case to verify that we do now
print things correctly.

Reported by:	Thomas Pasqualini <thomas.pasqualini@orange.com>
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 58164dcb55d62ca73b5e550b8344bf61e2d8a47a)
2025-04-17 10:05:28 +02:00
Mark Johnston
8c6ca73918 pf: Use a macro to get the hash row in pf_find_state_byid()
This seems a bit preferable to open-coding it.  No functional change
intended.

Reviewed by:	kp, glebius
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D49518

(cherry picked from commit 27f70efebf1d9424462f291e9d04e62272083aa7)
2025-04-16 15:03:19 +02:00
Franco Fichtner
5afe2ee090 netinet6: work around synchronization issue in dying netgraph device #207 2025-04-15 15:12:26 +02:00
Kristof Provost
d27208952e pf tests: test table information export via snmp_pf
Event:		Tokyo Hackathon 202503
(cherry picked from commit 36586800803d24f1137d861bbaf487a6bde16a09)
25.1.5
2025-04-10 08:31:21 +02:00
Kristof Provost
2fa7d46dde pf tests: add a basic snmp_pf test case
Event:		Tokyo Hackathon 202503
(cherry picked from commit c849f533326026501c28cb2c344b16723862551a)
2025-04-10 08:31:12 +02:00
Ahmad Khalifa
04f6aed434 Copy the new ia32 loader
This handles copying in install-boot.sh and bsdinstall's bootconfig.

install-boot.sh:
make_esp_file now optionally takes extra arguments so it can copy
multiple files. This is used by the amd64 release scripts.
make_esp_device also takes an extra optional argument for efibootname.
This is currently unused, but it can be used in the future to do
something like:
make_esp_device loader.efi bootx64
make_esp_device loader_ia32.efi bootia32

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1098

(cherry picked from commit 599273f942b8dc6f957487bb28f36694dab9dad2)
2025-04-10 08:30:30 +02:00
Kristof Provost
41e3b49d2f pf: improve pf_state_key_attach() error handling
If we fail to attach the stack key that means we've already attached the wire
key. That means the state could be found by other cores, and given that we then
free it, be used after free.
Fix this by not releasing the ID hashrow lock and key locks until after we've
removed the inserted key again, ensuring the state cannot be found by other
cores.

Reported by:	markj
Submitted by:	glebius
Reviewed by:	glebius, markj
MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D49550
2025-04-07 17:53:27 +02:00
Mark Johnston
801c84ae95 netinet: Fix getcred sysctl handlers to do nothing if no input is given
These routines were all assuming that the sysctl handler has some new
value, but this is not the case.  SYSCTL_IN() returns 0 in this
scenario, so they were all operating on an uninitialized address.  This
is mostly harmless, but trips KMSAN checks, so let's fix them.

Reviewed by:	zlei, rrs, glebius
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D49348

(cherry picked from commit 3ff865c6a7948b2cfc01d7056c619145b696700a)
2025-04-07 17:50:57 +02:00
Michael Tuexen
e0b3614769 tcp: remove struct tcp_log_rack
struct tcp_log_rack is not used, therefore remove it.

Reviewed by: 		Peter Lei
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D49669

(cherry picked from commit b1c62081feec535a4f2eeb4f8deb58913d9e281c)
2025-04-07 17:50:36 +02:00
Peter Lei
8b88f44f84 tcp: clear sendfile logging struct
The sendfile black box logging struct is much smaller than the
encompassing stack specific logging union. Be sure to clear the
trailing unused memory when logging.

Reviewed by:	tuexen
Sponsored by:	Netflix, Inc.

(cherry picked from commit 3bd1e85fc13cb90853046300dcaa31d63b45ee21)
2025-04-07 17:50:25 +02:00
Michael Tuexen
4d2ba6d834 sctp: fix double unlock in case adding a remote address fails
Thanks to glebius@ for pointing to the problem.

Reported by:	syzbot+1d5c164f1c10de84ad8a@syzkaller.appspotmail.com
Fixes:		2d5c48eccd9f ("sctp: Tighten up locking around sctp_aloc_assoc()")

(cherry picked from commit e8623834ca29b562687db945bdd12a3e2fe4aeb1)
2025-04-07 17:50:13 +02:00
Norbert Ciosek
0f962476d4 ixgbe: fix mailbox ack handling
Check if CTS bit is set in the mailbox message before waiting for ACK.
Otherwise ACK will never be received causing the function to timeout. Add
a note for ixgbe_write_mbx that it should be called while holding a lock.

Fixes: 6d243d2 ("net/ixgbe/base: introduce new mailbox API")
Cc: stable@dpdk.org

Signed-off-by: Norbert Ciosek <norbertx.ciosek@intel.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Obtained from:	DPDK (1f119e4)

(cherry picked from commit 1580f8d9c1740e0c54554e6c185573d34f2dcf76)
2025-04-07 17:50:03 +02:00
Eric Joyner
6f33f12a25 igc(4): Fix attach for I226-K and LMVP devices
Summary:
The device IDs for these were in the driver's list of PCI ids to attach
to, but igc_set_mac_type() had never been setup to set the correct mac
type for these devices. Fix this by adding these IDs to the switch block
in order for them to be recognized by the driver instead of returning an
error.

This fixes the igc(4) attach for the I226-K LOM on the ASRock Z790
PG-ITX/TB4 motherboard, allowing it to be recognized and used.

Signed-off-by: Eric Joyner <erj@FreeBSD.org>

Reviewed by:	kbowling@
Relnotes:	yes
Differential Revision: https://reviews.freebsd.org/D49147

(cherry picked from commit 7ee310c80ea7b336972f53cc48b8c3d03029941e)
2025-04-07 17:46:05 +02:00
Kristof Provost
f93d01fa41 if_ovpn: fix use-after-free of mbuf
m_unshare() can return a new mbuf pointer. We update the 'm' pointer in
ovpn_udp_input(), but if we decide to pass on the packet (e.g. because it's for
an unknown peer) the caller (udp_append()) continues with the old 'm' pointer,
eventually resulting in a use-after-free.

Re-order operations in ovpn_udp_input() so that we don't modify the 'm' pointer
until we're committed to keeping the packet.

PR:		283426
Test case by:	takahiro.kurosawa@gmail.com
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-04-07 17:42:44 +02:00
Franco Fichtner
d61f5e3dd9 Revert "pf: do a lock dance in pf_unlink_state()"
This reverts commit fd23892d390fe9c60cc1ae34e04153080d9e9e1b.

Issue appears to sit a bit deeper.
2025-03-24 09:09:19 +01:00
Franco Fichtner
fd23892d39 pf: do a lock dance in pf_unlink_state()
Both pf_test() and pf_test6() can end up in a panic while
executing PF_UNLOCK_STATE which points to the state being
removed while it is in use.

The PF_LOCK_STATE in the removal subroutine makes sure
that pf_test/pf_test6 are no longer holding the state
and we can safely test and set PFTM_UNLINK.

The other bits of the OpenBSD commit probably apply as well
but for now make sure that this particular panic comes to
and end.

Based on: https://github.com/openbsd/src/commit/9d9f4dc6c83
2025-03-21 10:12:11 +01:00
Mark Johnston
8bc2fd13e9 inpcb: Move the definition of struct inpcblbgroup to in_pcb_var.h
It's only needed for in_pcb.c and in6_pcb.c, so can go to the private
header.

No functional change intended.

Reported by:	glebius
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield

(cherry picked from commit ca94f92c23fd09b28ac3398657ae2ae9367bcdf5)
2025-03-21 09:31:11 +01:00