Commit Graph

283876 Commits

Author SHA1 Message Date
Kristof Provost
2d9d97e66e ifconfig: improve error checking for carp peer6
getaddrinfo() returns 0 if it succeeded, but it's not guaranteed to
return 1 on error. Check for success rather than for one specific error.

Without this fix commands such as `ifconfig bnxt1 inet6 add vhid 1 peer6
2001:db8::1/64` would segfault ifconfig.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-05-18 17:47:03 +02:00
Bjoern A. Zeeb
2e6756b752 ifconfig: improve trimming off interface number at end
When trying to auto-load a module, we trim the interface number off
the end.  Currently we stop at the first digit.  For interfaces which
have numbers in the driver name this does not work well.
In the current example ifconfig ath10k0 would load ath(4) instead of
ath10k(4).  For module/interface names like rtw88[0] we never guess
correctly.
To improve for the case we can, start trimming off digits from the
end rather than the front.

Sponsored by:	The FreeBSD Foundation
Reported by:	thierry
MFC after:	20 days
Reviewed by:	melifaro, thierry
Differential Revision: https://reviews.freebsd.org/D40137
2023-05-18 15:22:53 +00:00
Colin Percival
dc5361ea16 rc.d/netif: Don't DAD if lo0 is the only IPv6 IF
The code in rc.d/netif waiting for IPv6 Duplicate Address Detection if
any network interfaces support IPv6.  Unfortunately, since lo0 *always*
has IPv6 enabled, this means unconditionally sleeping, even on systems
which have no external IPv6 interfaces.

Since we presume that there is little risk of a duplicate address being
assigned on lo0, amend the test to wait only if there is an interface
*other than lo0* which supports IPv6.

Reviewed by:	bz
Differential Revision:	https://reviews.freebsd.org/D40141
2023-05-18 08:20:15 -07:00
Dmitry Chagin
0f62290e7f linux(4): Check fd passed to unlockpt()
In our implementation, grantpt() and unlockpt() don't actually have
any use, because PTY's are created on the fly and already have proper
permissions upon creation.
Atleast check that a proper fd passed to unlockpt(). For grantpt()
Glibc calls TIOCGPTN ioctl which would fail if fd is not a master.

Differential Revision:	https://reviews.freebsd.org/D40100
MFC after:		1 week
2023-05-18 10:55:39 +03:00
Gleb Smirnoff
743516d51f ktls: don't try to unlock pcb if tcp_drop() already did
Reviewed by:	rrs, gallatin
2023-05-17 10:25:28 -07:00
Kajetan Staszkiewicz
8c23afdb57 pf: Standardize rtableid
Prepare for rtableid being included in struct pfsync_state where it will
be int32_t. Make variables which will be set to and from it the same
width.

Reviewed by:	kp
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D40013
2023-05-17 15:57:42 +02:00
Corvin Köhne
26d9f973d8
bhyve: error out if fwcfg user file isn't read completely
At the moment, fwcfg reads the file once at startup and passes these
data to the guest. Therefore, we should always read the whole file.
Otherwise we should error out.

Additionally, GCC12 complains that the comparison whether
fwcfg_file->size is lower than 0 is always false due to the limited
range of data type.

Reviewed by:		markj
Fixes:			ca14781c81 ("bhyve: add cmdline option for user defined fw_cfg items")
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D40076
2023-05-17 15:39:37 +02:00
Kristof Provost
bdd4717752 pf: release rules lock before passing the packet to dummynet
In the Ethernet rules we held the PF_RULES lock while we called
ip_dn_io_ptr() (i.e. dummynet). That meant that we could end up back in
pf while still holding the PF_RULES lock.
That's not immediately fatal, because that lock is recursive, but still
not ideal.

There also appear to be scenarios where this can actually trigger
deadlocks.

We don't need to hold the PF_RULES lock, as long as we make a local copy
of the data we need from the rule (in this case, the action and
bridge_to target). It's safe to keep the struct ifnet pointer around,
because we remain in NET_EPOCH.

See also:	https://redmine.pfsense.org/issues/14373
MFC after:	1 week
Reviewed by:	mjg
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D40067
2023-05-17 15:20:18 +02:00
Andrew Turner
37c1ef5ac0 Move the arm64 sigcode to .rodata
The kernel doesn't execute this code, it's only ever copied to
userspace. Move it to .rodata as we don't need to modify it.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D39399
2023-05-17 12:28:45 +01:00
Bjoern A. Zeeb
71fde8e507 LinuxKPI: add ns_to_timespec64()
Add ns_to_timespec64() which does not seem to require anything from
us given timespec64 is aliases to timespec.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D40123
2023-05-17 10:22:07 +00:00
Piotr Kubaj
2e57f7bf20 ix(4): correct max MTU
The max MTU for the ix(4) is 9710.

Differential revision:	https://reviews.freebsd.org/D40003
Approved by:	erj, bcr
2023-05-17 12:16:22 +02:00
Piotr Kubaj
d0cdec7a20 em: sync platform detection with Linux
Switch 16 and 23 adapters from tgp to adp.

PR:	270929
Differential revision:	https://reviews.freebsd.org/D39977
Approved by:	erj, kbowling
2023-05-17 12:14:02 +02:00
Alexander V. Chernikov
b50e1465e8 routing: plug mbuf leak for the packets hitting IPv6 blackhole route
Reported by:	Dmitriy Smirnov <fox@sage.su>
Tested by:	Dmitriy Smirnov <fox@sage.su>
MFC after:	1 day
2023-05-17 09:06:04 +00:00
Alexander V. Chernikov
4c63ecf5c7 routing: fix panic triggered by the 'gr_idx != 0' assert in nhg code
Nexthop groups can be referenced by the external code. The reference
 can be released after the VNET destruction. Furthermore, nexthop
 groups use a single per-rib lock, which is destroyed during the
 VNET desctruction. To eliminate use-after-free problem, each nhg
 is marked as "unlinked" during the VNET destruction stage, leaving
 nhg_idx intact. Normally there should not be such nexthops, but if
 there are any, the kernel will panic on 'gr_idx != 0' when the
 last nhg reference is released.

Address this by using the assert checks only when the nexthop group
 is destroyed during "valid" VNET lifetime.

MFC after:	3 days
2023-05-17 08:40:29 +00:00
Konstantin Belousov
848d5bb1ab net/if_var.h: consistently use if_t over struct ifnet *
Reviewed by:	jhibbits
Sponsored by:	NVidia networking
Differential revision:	https://reviews.freebsd.org/D40125
2023-05-17 06:31:07 +03:00
Konstantin Belousov
616a6c9f66 net/if.h: fix style of if_t definition
Reviewed by:	jhibbits
Sponsored by:	NVidia networking
Differential revision:	https://reviews.freebsd.org/D40125
2023-05-17 06:30:59 +03:00
Kajetan Staszkiewicz
cdc231bd49 pfsync: Remove deletion of states using the full pfsync_state struct
State deletions are sent over pfsync using struct pfsync_del_c.

Remove the code for receiving state deletions using struct pfsync_state
as such deletions are never sent. Rename functions and constants so that
only the "compressed" versions remain.

Reviewed by:	kp
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D40004
2023-05-17 02:39:58 +02:00
Bjoern A. Zeeb
262c5e8193 LinuxKPI: skbuff.h: add skb_hwtstamps(), implement *mac_header()
Add a dummy skb_hwtstamps() function for now, and implement
skb_mac_header(), skb_reset_mac_header(), and skb_set_mac_header().

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2023-05-16 21:26:50 +00:00
Bjoern A. Zeeb
972bf40b62 LinuxKPI: add ptp_clock_kernel.h
Add the new ptp_clock_kernel.h with structs and dummy functions for
kernel ptp support.  This is needed for the next iwlwifi update.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2023-05-16 21:26:40 +00:00
Dmitry Chagin
0282f87530 ktrace: Simplify ae6ac587, drop the sa var declaration
Suggested by:		kib
MFC after:		5 days
2023-05-16 22:46:26 +03:00
Alexander V. Chernikov
4c91a5dfe4 ifconfig: make interface and address listing use Netlink as transport
Differential Revision: https://reviews.freebsd.org/D40044
2023-05-16 19:39:13 +00:00
Alexander V. Chernikov
10b94e4064 netlink: add support for adding/deleting interface addresses
Differential Revision: https://reviews.freebsd.org/D40103
MFC after:	2 weeks
2023-05-16 19:39:13 +00:00
Bjoern A. Zeeb
7232e6dcc8 net80211: Radiotap: update for newer standards (add EHT, U-SIG)
iwlwifi already uses suggested EHT and U-SIG bits as well as some
more TLV bits.  Update radiotap to know of those even if they might
get updated again in the future in order to get newer versions of
the driver to compile.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2023-05-16 16:05:55 +00:00
Alexander V. Chernikov
584ad4126c testing: improve vnet support in pytest
* Allow vnet object to be directly referenced
 (self.vnet1 vs self.vnet_map["vnet1"])
* Allow iface object to be directly reference
 (vnet.bridge vs vnet.iface_alias_map["bridge"])
* Allow arbitrary interface alias names insted of ifX
* Add wait_objects_any() method for waiting object from
 multiple vnets
* Add wait() method for indefinite sleep on vnet handlers

MFC after:	2 weeks
2023-05-16 15:00:45 +00:00
Jose Luis Duran
6e068d6bea passwd.5: Update man page after e0155c6989
MFC After:	3 days
2023-05-16 13:57:49 +02:00
Jose Luis Duran
d047a4e486 passwd.5: Remove .Tn (Trade Name) macros
To appease mandoc -T lint, remove .Tn macros.

MFC After:	3 days
2023-05-16 13:57:32 +02:00
pbuff
e0155c6989 pw: The pw_checkname function has added ';' checking.
The pw_checkname function forgot to include a ';'
when checking usernames, causing shell commands
to be executed when a username with a ';' is deleted.

PR:		271427
MFC After:	3 days
2023-05-16 08:48:08 +02:00
Jessica Clarke
816129210a tests: Don't recurse into sys/compat32
Stubbing out the whole file means it has no targets, so recursive makes
fail with "don't know how to make X". We could fix that, but because the
level above is adding it to TESTS_SUBDIRS it'll generate an include line
for the subdirectory in its Kyuafile, which won't work (the problem that
was previously seen on non-aarch64 in CI). Thus we really need to not
even add it to TESTS_SUBDIRS in the first place.

Reported by:	Dan Mack <mack@macktronics.com>
Fixes:		28f66935d4 ("tests: Disable sys/compat32 and sys/compat32/aarch64 tests")
2023-05-16 02:06:34 +01:00
Antonio Russo
e0d5007bcf
test-runner: pass kmemleak and kmsg to Cmd.run
test-runner.py orchestrates all of the ZTS executions. The `Cmd` object
manages these process, and its `run` method specifically invokes these
possibly long-running processes, possibly retrying in the event of a
timeout. Since its inception, memory leak detection using the kmemleak
infrastructure [1], and kernel logging [2] have been added to this run
mechanism.

However, the callback to cull a process beyond its timeout threshold,
`kill_cmd`, has evaded modernization by both of these changes. As a
result, this function fails to properly invoke `run`, leading to an
untrapped exception and unreported test failure.

This patch extends `kill_cmd` to receive these kernel devices through
the `options` parameter, and regularizes all the `.run` calls from
`Cmd`, and its subclasses, to accept that parameter.

[1] Commit a69765ea5b
[2] Commit fc2c0256c5

Reviewed-by: John Wren Kennedy <john.kennedy@delphix.com>
Signed-off-by: Antonio Russo <aerusso@aerusso.net>
Closes #14849
2023-05-15 16:11:33 -07:00
Jessica Clarke
28f66935d4 tests: Disable sys/compat32 and sys/compat32/aarch64 tests
The former has build system issues, with missing Kyuafiles, presumably
due to not using TESTS_SUBDIRS and bsd.test.mk (and possibly some issues
on top of that around TESTSDIR and related variables). The latter has
issues with GCC and cut-down LLVM builds.

Requested by:	kevans
Fixes:		ccb59683b9 ("arm64: add tests for swp/swpb emulation")
2023-05-15 23:16:40 +01:00
Alexander Motin
f409f11bc5 nvmecontrol: Fix power subcommand output.
The returned value consists of two fields.  Report them separately.

MFC after:	2 weeks
2023-05-15 16:48:50 -04:00
Simon J. Gerraty
92a4e8b348 dirdeps.mk allow for TARGET_SPEC_VARS.host
While *most* projects need only DEP_MACHINE for host, there is always
an exception.  So we allow for TARGET_SPEC_VARS.host to be a subset of
TARGET_SPEC_VARS.  The default will *just work* for most projects.

We set DEP_TARGET_SPEC_VARS and hence DEP_TARGET_SPEC based on
DEP_MACHINE.  Allow for M_dep_qual_fixes.host to be different too and
take care to apply the right set.
2023-05-15 13:25:10 -07:00
Kirk McKusick
0a6e34e950 Fix size differences between architectures of the UFS/FFS CGSIZE macro value.
The cylinder group header structure ended with `u_int8_t cg_space[1]'
representing the beginning of the inode bitmap array. Some architectures
like the i386 rounded this up to a 4-byte boundry while other
architectures like the amd64 rounded it up to an 8-byte boundry.
Thus sizeof(struct cg) was four bytes bigger on an amd64 machine
than on an i386 machine. If a filesystem created on an i386 machine
was moved to an amd64 machine, the size of the cylinder group
calculated by the CGSIZE macro would appear to grow by four bytes.
Filesystems whose cylinder groups were exactly equal to the block
size on an i386 machine would appear to have a cylinder group that
was four bytes too big when moved to an amd64 machine. Note that
although the structure appears to be too big, it in fact is fine.
It is just the calaculation of its size that is in error.

The fix is to remove the cg_space element from the cylinder-group
structure so that the calculated size of the structure is the same
size on all architectures.

Reported by:  Tijl Coosemans
Tested by:    Tijl Coosemans and Peter Holm
MFC after:    1 week
Sponsored by: The FreeBSD Foundation
2023-05-15 12:57:15 -07:00
Richard Yao
ee7b71dbc9 Fix undefined behavior in spa_sync_props()
8eae2d214c caused Coverity to begin
complaining about "Improper use of negative value" in two places in
spa_sync_props() because Coverity correctly inferred from `prop ==
ZPOOL_PROP_INVAL` that prop could be -1 while both zpool_prop_to_name()
and zpool_prop_get_type() use it an array index, which is undefined
behavior.

Assuming that the system does not panic from an attempt to read invalid
memory, the case statement for ZPOOL_PROP_INVAL will ensure that only
user properties will reach this code when prop is ZPOOL_PROP_INVAL, such
that execution will continue safely. However, if we are unlucky enough
to read invalid memory, then the system will panic.

This issue predates the patch that caused coverity to begin complaining.
Thankfully, our userland tools do not pass nonsense to us, so this bug
should not be triggered unless a future userland tool attempts to set a
property that we do not understand.

Reported-by: Coverity (CID-1561129)
Reported-by: Coverity (CID-1561130)
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Amanakis <gamanakis@gmail.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14860
2023-05-15 10:29:05 -07:00
Richard Yao
c87798d8ff Fix use after free regression in spa_remove_healed_errors()
6839ec6f10 placed code in
spa_remove_healed_errors() that uses a pointer after the kmem_free()
call that frees it.

Reported-by: Coverity (CID-1562375)
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Amanakis <gamanakis@gmail.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14860
2023-05-15 10:29:01 -07:00
Kyle Evans
b68588618b arm64: simplify expression
!a != !b -> a != b; this part was lifted from NetBSD, and I clearly did
not reconsider that these are bools (I'm guessing they were ints in an
earlier iteration of the NetBSD implementation).

while we're here, it should be easy to see that we've covered all of the
cases but let's add in an __assert_unreachable() to make it easier on
the eyes.

Reported by:	jrtc27
2023-05-15 10:54:15 -05:00
Kyle Evans
ccb59683b9 arm64: add tests for swp/swpb emulation
One test is suitable to be hooked up to the build, so I've done this
here.  The other test lives in tools/regression because failure is a
bit more subjective -- generally, one runs it for some unbounded amount
of time and observe if it eventually exits because two threads acquired
the same mutex.

Reviewed by:	imp, mmel
Sponsored by:   Stormshield
Sponsored by:   Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D39668
2023-05-15 10:42:16 -05:00
Kyle Evans
4b500174dd arm64: emulate swp/swpb instructions
Add another undefined instruction handler for compat32 and watch out for
SWP/SWPB instructions.

SWP/SWPB were deprecated in ARMv6 and declared obsolete in ARMv7, but
this implementation is motivated by some proprietary software that still
uses SWP/SWPB. Because it's deprecated, emulation is pushed back behind
a sysctl that defaults to OFF in GENERIC so that it doesn't potentially
adversely affect package builds; it's unknown whether software may test
for a functional swp/swpb instruction with the desire of using it later,
so we err on the side of caution to ensure we don't end up with swp/swpb
use in freebsd/arm packages (which are built on aarch64).

The EMUL_SWP config option may be used to enable emulation by default in
environments where emulation is desired and won't really be turned off.

Reviewed by:	andrew, mmel (both earlier version)
Sponsored by:   Stormshield
Sponsored by:   Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D39667
2023-05-15 10:42:10 -05:00
Alexander V. Chernikov
d1cd0344f7 ifconfig: split printing functions into smaller per-type chunks.
This change is a prerequisite for netlink conversion.
No functional changes intended.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D40033
MFC after: 2 weeks
2023-05-15 13:37:27 +00:00
Alexander V. Chernikov
d91f8db5f1 testing: rename IfattrType to IfaAttrType for consistency
All other attribute classes are named as 'type'AttrType and 'type'
 int this case is ifa (interface address).

MFC after:	2 weeks
2023-05-15 11:47:07 +00:00
Alexander V. Chernikov
3f6bf6a033 netlink: add an optional post-process hook to the message parsers.
It is primarily used for adding scopeid to the IPv6 link-local
 sockaddrs. Having proper sockaddrs after parsing minimises the
 possibility of human mistake when using the parsing.

MFC after: 2 weeks
2023-05-15 11:33:10 +00:00
Alexander V. Chernikov
97760572a0 testing: add public method for requiring module presense in pytest
MFC after:	2 weeks
2023-05-15 10:50:55 +00:00
Alexander V. Chernikov
f0ffe1ce0f testing: add support for handling Netlink carp messages
MFC after:	2 weeks
2023-05-15 10:48:45 +00:00
Alexander V. Chernikov
f3065e767d testing: add support for using custom interfaces in pytest framework.
MFC after:	2 weeks
2023-05-15 10:44:20 +00:00
Mariusz Zaborski
06db6a9dce geli: fix typo
PR:		271396
Reported by:	Tim Chase <freebsd@tim.thechases.com>
MFC after:	1 week
2023-05-15 10:44:17 +02:00
Michael Osipov
d2b4753f06 periodic: Use locale-agnostic (ISO 8601) timestamp format
Instead of reyling on locale-sensitive output which can be mangled when e-mailed
use consistently ISO 8601 format which contains the same information as '-T'.

PR:		271240
MFC After:	3 days
2023-05-15 09:26:48 +02:00
Peter Wright
d904b43ba3 dma: install a simple example for the auth.conf file
PR:		270088
MFC After:	3 days
2023-05-15 09:20:14 +02:00
Baptiste Daroussin
c7fdf87b09 pci_vendors: update to 2023-05-15
MFC After: 3 days
2023-05-15 09:09:32 +02:00
Baptiste Daroussin
ef7d0eb948 pw: do not call system()
Calling system makes pw(8) spawn a shell, which can then be abused.

MFC After:	3 days
2023-05-15 08:59:08 +02:00
Wolfram Schneider
b3087b63da remove stale portsinfo script 2023-05-15 06:34:20 +00:00