Commit graph

293733 commits

Author SHA1 Message Date
Mark Johnston
c673940a3d amd64/conf: Remove a config committed by accident
Approved by:	so
Reported by:	kib, kp
Fixes:		350ba9672a ("unix: Set O_RESOLVE_BENEATH on fds transferred between jails")

(cherry picked from commit 3ef39f58e5)
(cherry picked from commit 302120bcb934ea150555362326c812353fb72eaa)
2026-02-24 19:22:13 +01:00
Mark Johnston
3f73e4146d unix/tests: Add a regression test for fd transfer across jails
Approved by:	so
MFC after:	3 weeks

(cherry picked from commit 5843b8ee02)
(cherry picked from commit ac2279ea57b72d688cf0af5a6fa7f5dbd1d4521b)
2026-02-24 19:22:12 +01:00
Mark Johnston
6d73cae873 unix: Set O_RESOLVE_BENEATH on fds transferred between jails
If a pair of jails with different filesystem roots is able to exchange
SCM_RIGHTS messages (e.g., using a unix socket in a shared nullfs
mount), a process in one jail can open a directory outside of the root
of the second jail and then pass the fd to that second jail, allowing
the receiving process to escape the jail chroot.

Address this using the new FD_RESOLVE_BENEATH flag.  When externalizing
an SCM_RIGHTS message into the receiving process, automatically set this
flag on all new fds where a jail boundary is crossed.  This ensures that
the receiver cannot do more than access files underneath the directory;
in particular, the received fd cannot be used to access vnodes not
accessible by the sender.

Approved by:	so
Security:	FreeBSD-SA-26:04.jail
Security:	CVE-2025-15576
PR:		262179
Reviewed by:	kib
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D50371

(cherry picked from commit 350ba9672a)
(cherry picked from commit 3ad3ab5f9b6e91efc923bae9799697a823eb7227)
2026-02-24 19:22:11 +01:00
Mark Johnston
9a9303e4b9 file: Fix the !CAPABILITIES build
Approved by:	so
Reported by:	Ian FREISLICH <ianfreislich@gmail.com>
Fixes:	f35525ff20 ("file: Add a fd flag with O_RESOLVE_BENEATH semantics")

(cherry picked from commit 6783dfb106)
(cherry picked from commit 8f6769b82a2a071cf07080b6d77639e919efbbcf)
2026-02-24 19:22:10 +01:00
Mark Johnston
f77dc4d27a file: Add a fd flag with O_RESOLVE_BENEATH semantics
The O_RESOLVE_BENEATH openat(2) flag restricts name lookups such that
they remain under the directory referenced by the dirfd.  This commit
introduces an implicit version of the flag, FD_RESOLVE_BENEATH, stored
in the file descriptor entry.  When the flag is set, any lookup relative
to that fd automatically has O_RESOLVE_BENEATH semantics.  Furthermore,
the flag is sticky, meaning that it cannot be cleared, and it is copied
by dup() and openat().

File descriptors with FD_RESOLVE_BENEATH set may not be passed to
fchdir(2) or fchroot(2).  Various fd lookup routines are modified to
return fd flags to the caller.

This flag will be used to address a case where jails with different root
directories and the ability to pass SCM_RIGHTS messages across the jail
boundary can transfer directory fds in such as way as to allow a
filesystem escape.

Approved by:	so
PR:		262180
Reviewed by:	kib
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D50371

(cherry picked from commit f35525ff20)
(cherry picked from commit 10b3f2138573da952b4db29f88f6d67cfc3300cd)
2026-02-24 19:22:09 +01:00
Mark Johnston
fd926d0f57 file: Qualify pointers to capsicum rights as const
File descriptor lookup routines typically take a set of capsicum rights
as input to the lookup, so that the fd's rights can be atomically
checked.  This set should be qualified with const.

No functional change intended.

Approved by:	so
Reviewed by:	olce, oshogbo, brooks, kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D50419

(cherry picked from commit 5319cb2161)
(cherry picked from commit 2060337c0937f08d9960d629eb59ce737339640c)
2026-02-24 19:22:07 +01:00
John Baldwin
d871609f2a atf: Switch from std::auto_ptr<> to std::unique_ptr<>
This mirrors upstream commit f053ab687f6e27aa264f599ecbfc5ef27ad4e2d3.

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

(cherry picked from commit 5e6befdaca)
2026-02-24 13:25:29 +01:00
John Baldwin
64311997dd lutok: Switch from std::auto_ptr<> to std::unique_ptr<>
This mirrors upstream commit bd5904144c9778a07685f3e4efa6ef011a5480ec.

Reviewed by:	igoro, imp, emaste
Differential Revision:	https://reviews.freebsd.org/D49788

(cherry picked from commit 25f2634a1f)
2026-02-24 13:25:07 +01:00
Timo Völker
4d43ea1319 icmp6: clear csum_flags on mbuf reuse
When icmp6 sends an ICMPv6 message, it reuses the mbuf of the packet
that triggered the ICMPv6 message and prepends an IPv6 and ICMPv6
header. For a locally generated packet with checksum offloading, the
mbuf still has csum_flags set indicating that a SCTP/TCP/UDP checksum
has to be computed and inserted. Since this not the case anymore,
csum_flags need to be cleared.

PR:			293227
Reviewed by:		kp, zlei, tuexen
MFC after:		3 days
Differential Revision:	https://reviews.freebsd.org/D55367

(cherry picked from commit ada4dc77577f7162353e8c2916ba5c258b6210f0)
2026-02-24 10:11:30 +01:00
Zhenlei Huang
2e22159dcc pf: Use proper prototype for SYSINIT functions
MFC after:	1 week

(cherry picked from commit 0ce8c20fcd44c1595b42fcb540913d3802edd438)
(cherry picked from commit 34462748d7)
2026-02-18 13:14:34 +01:00
Zhenlei Huang
2c6944f6f6 ipfw: Use proper prototype for SYSINIT functions
The only possible return value of function ipfw_init() is 0. Make it
return void to match the prototype of SYSINIT.

MFC after:	1 week

(cherry picked from commit 1bba2194c8a960235f8eae36e7d3e96f347ce779)
(cherry picked from commit 745b6ca4ed)
2026-02-18 13:14:03 +01:00
Alexander Ziaee
77d00703b2 bsdinstall.8: Minor maintenance
Replace CD-ROMs with "discs, USBs, or network boot environments"
to both modernize aesthetic and also nudge youths to think at scale.
Since I'm disrupting the flow of these lines anyway, expand the VM
acronym because I think this is one of the first manuals people will
be looking at.

Reset list alignment to seven characters. It was at 19 characters,
and that was not enough to align them all, wasting many extra lines
by crunching all the words over. Seven actually bought us some lines
from six due to avg item size. Tag SPDX.

MFC after:	3 days
Discussed with:	ivy, zi

(cherry picked from commit 81d9e08a4df42079d5e163b5991d5d6f3a28d4f0)
2026-02-18 13:13:17 +01:00
Zhenlei Huang
89058b937f netipsec: Use proper prototype for SYSINIT functions
MFC after:	1 week

(cherry picked from commit 360bb45690d918fac5bae78ab44f45d11327067a)
(cherry picked from commit a32ee2897f)
2026-02-18 13:12:52 +01:00
Mark Johnston
9d3a11c90a ip6_mroute: Fix the UPCALL_TIMING build
MFC after:	2 weeks
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.

(cherry picked from commit 5bb953b095461b488b102ab3025f42cd2ef61f9d)
2026-02-18 13:12:12 +01:00
Mark Johnston
b2d3c64f88 ip6_mroute: Remove an unhelpful comment
ifnets already track if_allmulti() calls in the if_amcount field.  That
field is older than the comment, so I'm not exactly sure what the intent
was; let's just remove it.

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

(cherry picked from commit a45fb94801dffd414bdb1981def0e977ef0c774f)
2026-02-18 13:12:06 +01:00
Mark Johnston
366c3d71ba ip6_mroute: Make MF6CFIND a regular function
This is more natural and corresponds more closely to the v4 multicast
routing code.  No functional change intended.

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

(cherry picked from commit b370fcc716b9cfd4d08e291f0009f02452c84d64)
2026-02-18 13:11:57 +01:00
Mark Johnston
9d4eb1ac12 ip6_mroute: Remove an unused constant
No functional change intended.

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

(cherry picked from commit b320e89e6909c0c3f29542976df0381990866988)
2026-02-18 13:11:25 +01:00
Mark Johnston
07c0d547ee ip6_mroute: Mark functions as static
No functional change intended.

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

(cherry picked from commit a03eabfebbce15d8ce028168969812d3ca2be206)
(cherry picked from commit ebc9a98c1b)
2026-02-18 13:11:18 +01:00
Zhenlei Huang
f5f369f684 netinet6: Use proper prototype for SYSINIT functions
MFC after:	1 week

(cherry picked from commit d4a80fa271b148b269869e5ca34e1861d9fcdfb0)
(cherry picked from commit cfc237162c)
2026-02-18 13:10:37 +01:00
Richard Scheffenegger
5ee3f733dc siftr: refactor batch log processing
Refactoring to perform the batch processing of
log messaged in two phases. First cycling through a limited
number of collected packets, and only thereafter freeing
the processed packets. This prevents any chance of calling
free while in a critical / spinlocked section.

Reviewed By:           tuexen
Sponsored by:          NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D42949

(cherry picked from commit a95cd6e487)
2026-02-18 13:09:31 +01:00
Cheng Cui
b83e38491a siftr: flush pkt_nodes to the log file in batch
Reviewed by: rscheff, tuexen
Differential Revision: https://reviews.freebsd.org/D41175

(cherry picked from commit fafb03ab42)
2026-02-18 13:09:20 +01:00
Mark Johnston
5a6ee6a59b ip_mroute: Make privilege checking more consistent
- The v6 socket option and ioctl handlers had no privilege checks at
  all.  The socket options, I believe, can only be reached via a raw
  socket, but a jailed root user with a raw socket shouldn't be able to
  configure multicast routing in a non-VNET jail.  The ioctls can only
  be used to fetch stats.
- Delete a bogus comment in X_mrt_ioctl(), one can issue multicast
  routing ioctls against any socket.  Note that the call path is
  soo_ioctl()->rtioctl_fib()->mrt_ioctl().

I think all of the mroute privilege checks should be done within the
ip(6)_mroute code, but let's first make the v4 and v6 modules
consistent.

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

(cherry picked from commit 74839871be363c5c2ac7ccd3396f36bdb58d19de)
2026-02-18 13:08:13 +01:00
Mark Johnston
9ad99a2cb8 ip_mroute: Convert to using a regular mutex
The multicast routing code was using spin mutexes for packet counting,
but there is no reason to use them instead of regular mutexes, given
that none of this code runs in an interrupt context.  Convert to using
default mutexes.

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

(cherry picked from commit a265c8b4a5a7c8fdd33e27b8f74bd2a514f82c70)
2026-02-18 13:08:04 +01:00
Mark Johnston
5c48d7b815 ip_mroute: EVENTHANDLER_REGISTER does not fail
No functional change intended.

MFC after:	1 week
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.

(cherry picked from commit 0f1e1350704af555a4b30136f5f3d16db6f2dc51)
2026-02-18 13:07:46 +01:00
Zhenlei Huang
4b02370497 netinet: Use proper prototype for SYSINIT functions
MFC after:	1 week

(cherry picked from commit 6613b6ad1ecc5384c119018b9b27c18bd7516e3f)
(cherry picked from commit 5b41be5cc0)
2026-02-18 13:06:52 +01:00
Zhenlei Huang
71611d3ab3 net80211: Use proper prototype for SYSINIT functions
MFC after:	1 week

(cherry picked from commit 7449e59110b8abbb3d647c3565ca3de1d21b2c84)
(cherry picked from commit 0270d3dfa7)
2026-02-18 13:06:21 +01:00
Zhenlei Huang
3bf7558be1 net: Use proper prototype for SYSINIT functions
MFC after:	1 week

(cherry picked from commit 6f8259eae61981d7e5d049be7eed9235f0e8172e)
(cherry picked from commit fa80382b99)
2026-02-18 13:05:35 +01:00
Zhenlei Huang
c760cc40f2 p9fs: Use proper prototype for SYSINIT functions
MFC after:	1 week

(cherry picked from commit 11cfa861e3ff83649c54e5781b541166dc73e80b)
(cherry picked from commit 618c7cffeb)
2026-02-18 13:04:52 +01:00
Kirill Kochnev
0b3951a74a sys/net/sff8436.h: Fix the register address of link length of copper or active cable
The register address of link length of copper or active cable is 146 as
per the SFF-8436 specification [1].

[1] 7.6.2 Upper Memory Map Page 00h SFF-8436 Specification (pdf): https://members.snia.org/document/dl/25896

Reviewed by:	imp, zlei
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1885
Closes:		https://github.com/freebsd/freebsd-src/pull/1885

(cherry picked from commit a537694b49f719d84e3a69a2b8a3098f603da7d7)
(cherry picked from commit fdd23fc3d0)
2026-02-18 13:04:26 +01:00
Kristof Provost
78c3994ec7 if_ovpn: add interface counters
Count input/output packets and bytes on the interface as well, not just
in openvpn-specific counters.

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

(cherry picked from commit 21d666a19331f31fb6dfa1e370de5a84a1a5cb46)
2026-02-18 13:03:31 +01:00
Michael Tuexen
ba5ad8b2b9 vtnet: improve consistency
Use sbuf_new_for_sysctl() instead of sbuf_new_auto() when exposing
the flags via sysctl.

(cherry picked from commit 8da838ac31692e381adfc63d83ea49f2adabbf23)
2026-02-18 13:02:17 +01:00
Michael Tuexen
eddf2a14c7 vtnet: expose features via sysctl tree
Right now the 64-bit flags field needs to be casted to a 32-bit field,
because clang warns if more than 32-bits are used.
Once clang is fixed, this restriction will be removed and more bits
will be added.

Reviewed by:		markj, Timo Völker
Differential Revision:	https://reviews.freebsd.org/D54288

(cherry picked from commit 634d9c0d111b630c3d63a1cf25d15c32a37afab8)
2026-02-18 13:02:07 +01:00
Michael Tuexen
60b7f984ef vtnet.4: put each sentence on its own line
Reported by:	ziaee
Fixes:		e3a0571ad74d ("vtnet: expose flags via sysctl tree")

(cherry picked from commit f6e183301851e3e826d53a29e76cfc9bc7626477)
2026-02-18 13:02:04 +01:00
Michael Tuexen
89de4d0ff7 vtnet: expose flags via sysctl tree
Provide the flags used for a vtnet interface via the sysctl tree.
This is mostly used for debugging purposes.

Reviewed by:		Timo Völker
Differential Revision:	https://reviews.freebsd.org/D54283

(cherry picked from commit e3a0571ad74d8429a95fcae9efc1d91cc109a337)
2026-02-18 13:01:23 +01:00
Michael Tuexen
102341143d vtnet: define flags in a consistent way
This allows adding flags in the upper 32 bits in a consistent way.
No functional change intended.

(cherry picked from commit e0c6c4ecfc755b78ac9135033053d2f15c62bf04)
2026-02-18 13:01:16 +01:00
Yogesh Bhosale
2348f23f85 ice(4): Handle allmulti flag in ice_if_promisc_set function
In the ice_if_promisc_set function, the driver currently disables the
IFF_ALLMULTI flag, thereby preventing the activation of multicast mode.
To address this issue, implement appropriate handling to ensure the
flag is managed correctly.

Signed-off-by: Yogesh Bhosale <yogesh.bhosale@intel.com>

Tested by:	Gowthamkumar K S <gowtham.kumar.ks@intel.com>
Differential Revision:	https://reviews.freebsd.org/D54186

(cherry picked from commit 98bdf63f6e94be42a1787de73608de15bcb3419a)
2026-02-18 13:00:12 +01:00
Zhenlei Huang
b7143cdd85 e1000: Fix setting the promiscuous mode
The variable reg_rctl stores the value read from reg E1000_RCTL. It
may contain bits E1000_RCTL_VFE and E1000_RCTL_CFIEN which control
VLAN hardware filter feature. The promiscuous mode implies all tagged
or untagged packets should be accepted, so the VLAN hardware filter
feature should be disabled when enabling the promiscuous mode.
Calling em_if_vlan_filter_disable() did the task, but later writing
the value of reg_rctl back to the reg E1000_RCTL may restore the
feature.

Move the calling of em_if_vlan_filter_disable() after writing the reg
to fix that.

PR:		292759
Reviewed by:	kbowling
Tested by:	vova@zote.me
Fixes:		2796f7cab1 e1000: Fix up HW vlan ops
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D54973

(cherry picked from commit e63ee5fedb8dab51f1bd6d24cc650b68d9663db5)
(cherry picked from commit 8880678b7a)
2026-02-18 12:59:37 +01:00
Kristof Provost
8c02f3f9ae pfctl: allow new page character (^L) in pf.conf
PF configuration files can contains many things.

Using the new page characters (i.e. ^L, \014) to mark the beginning
of parts is useful because many editors such as emacs and vim has
facilities to jump next/previous ones.

PR:		86635
MFC after:	2 weeks
Submitted by:	MOROHOSHI Akihiko <moro@remus.dti.ne.jp>
Submitted by:	Simon Wollwage <rootnode+freebsd@wollwage.com>
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit fc353e5e61fadd6ef618948f417f96381c08239c)
2026-02-18 12:55:25 +01:00
Mark Johnston
4bc309c96f ifconfig: Exit with a non-zero status when SIOCSIFFIB fails
Previously, setting an interface FIB to some invalid value would result
in a warning being printed, but the ifconfig command would exit with
status 0, but this is wrong.

Add a little regression test.

Reviewed by:	pouria, zlei, melifaro
MFC after:	2 weeks
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D54918

(cherry picked from commit 2ea85a622bcba92a7b58901d6a6e945df3022c4e)
2026-02-18 12:53:20 +01:00
William Carrel
7f8deebafb ifconfig.8: Mention max name length
PR:		289113
MFC after:	3 days

(cherry picked from commit 832cd05905980d0f6547bf02745b054c1f4af1eb)
2026-02-18 12:53:12 +01:00
Kristof Provost
2e4a4c096a ifconfig: fix removing IPv6 addresses
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit da50f49977)
2026-02-18 12:52:56 +01:00
Gleb Smirnoff
e334c34ef4 ifconfig: fix 'ifconfig -l link'
The rtnetlink(4) RTM_GETADDR does not list link level addresses, thus
the correct match for interfaces that have a link level address should
be based on what was returned by RTM_GETLINK.

Reviewed by:		melifaro
Differential Revision:	https://reviews.freebsd.org/D41586

(cherry picked from commit 6f3947be2a)
2026-02-18 12:52:47 +01:00
Gleb Smirnoff
ffbae2e48b ifconfig: fix 'ifconfig -l ether'
When matching interfaces for being Ethernet, use same trick that
the link module does - pass if_type through convert_iftype().
That restores historicaly behaviour of listing lagg(4) ports.

Reviewed by:		melifaro
Differential Revision:	https://reviews.freebsd.org/D41585

(cherry picked from commit 31016aa0be)
2026-02-18 12:52:38 +01:00
Gleb Smirnoff
9186bb10c1 ifconfig: fix logical error in interface matching for '-l ether'
This affects only ifconfig(8) compiled WITHOUT_NETLINK_SUPPORT, which
is not the default.

Reviewed by:		melifaro
Differential Revision:	https://reviews.freebsd.org/D41584
Fixes:			d1cd0344f7

(cherry picked from commit 24a81a968d)
2026-02-18 12:52:25 +01:00
Pouria Mousavizadeh Tehrani
97196b9630 ifconfig: fix gre(4) status
Set `ifr->ifr_name` to display gre options
for the interface.

Reviewed by: glebius, zlei
Approved by: glebius (mentor)
MFC after: 1 day
Differential Revision: https://reviews.freebsd.org/D55099

(cherry picked from commit c2ba906fa63982d7aa799466d83716d39fe91d2b)
2026-02-18 12:52:13 +01:00
John Baldwin
64e6ae4815 kyua: Don't pass NULL to std::unique_ptr<>::reset()
No functional change, this is simply more idiomatic.

Reviewed by:	olce, emaste
Differential Revision:	https://reviews.freebsd.org/D50091

(cherry picked from commit d61c8bca86)
2026-02-18 12:51:36 +01:00
John Baldwin
6b14f938e7 kyua: Don't pass NULL to unique_ptr constructors
This is ambiguous when NULL is defined to an integral constant.
Instead, use the more iodiomatic pattern of {} to construct a default
pointer.

Reviewed by:	olce
Differential Revision:	https://reviews.freebsd.org/D50090

(cherry picked from commit 26d4ac7a27)
2026-02-18 12:51:28 +01:00
John Baldwin
5099f46d99 kyua: Switch from std::auto_ptr<> to std::unique_ptr<>
A few places were assigning auto_ptr<>s depending on the ownership
handoff.  These now use an explicit std::move() as required by
unique_ptr<>.

Reviewed by:	ngie, emaste
Differential Revision:	https://reviews.freebsd.org/D49790

(cherry picked from commit b392a90ba4)
2026-02-18 12:51:18 +01:00
Konstantin Belousov
45516d9dae cross-build: fix after the recent sqlite3 import
Stop adding contrib/sqlite3 into the include path for usr.bin/kyua, take
headers from the install sysroot env.  sqilte3 now has the VERSION file,
which clashes with c++ include <version>.

Submitted by:	jrtc27 (see https://reviews.freebsd.org/D51217)
Tested by:	kib
Fixes:	17f0f75308 ("sqlite3: Vendor import of sqlite3 3.50.2")

(cherry picked from commit 09d28419c6)
2026-02-18 12:50:39 +01:00
Michael Tuexen
424e564a24 sctp: support bridge interfaces
Reported by:	Timo Völker
Tested by:	Timo Völker

(cherry picked from commit 8d82dafa568baf7be46e5e443dd7310986a28aa9)
2026-02-18 12:45:42 +01:00