Commit graph

291060 commits

Author SHA1 Message Date
John Baldwin
d480a358cf lib80211: Consistently use item count as the first argument to calloc
Reported by:	GCC 14 -Wcalloc-transposed-args
Reviewed by:	rlibby, emaste
Differential Revision:	https://reviews.freebsd.org/D46008

(cherry picked from commit 8aadd10a65)
2024-11-30 08:55:57 -05:00
John Baldwin
360c47b956 elftoolchain: Consistently use item count as the first argument to calloc
Reported by:	GCC 14 -Wcalloc-transposed-args
Reviewed by:	rlibby, emaste
Differential Revision:	https://reviews.freebsd.org/D46007

(cherry picked from commit b73445a32f)
2024-11-30 08:55:57 -05:00
John Baldwin
a8c5babb35 libgeom: Consistently use item count as the first argument to calloc
Reported by:	GCC 14 -Wcalloc-transposed-args
Reviewed by:	rlibby, imp, emaste
Differential Revision:	https://reviews.freebsd.org/D46006

(cherry picked from commit bf3b889a5b)
2024-11-30 08:55:57 -05:00
John Baldwin
27c7ae36be libcasper: Consistently use item count as the first argument to calloc
Reported by:	GCC 14 -Wcalloc-transposed-args
Reviewed by:	rlibby, emaste
Differential Revision:	https://reviews.freebsd.org/D46005

(cherry picked from commit 5275d1ddb4)
2024-11-30 08:55:57 -05:00
John Baldwin
ef03c67b46 stdatomic: Only use clang atomics if __clang__ is defined
GCC 14 defines __has_extension(c_atomic) but does not support
__c11_atomic_*, so require __clang__ for the CLANG_ATOMICS case.

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

(cherry picked from commit 680f40f383)
2024-11-30 08:55:57 -05:00
John Baldwin
b4bbdf56a7 splash(4): Subject/verb agreement
(cherry picked from commit e5a18aa237)
2024-11-30 08:55:57 -05:00
John Baldwin
367fe30818 cxgbe: Remove most uses of sysctl_wire_old_buffer
Most of these sysctls don't call sbuf_* while holding any locks.  Of
the ones that do hold locks, all but one can be fixed to drop the lock
before calling sbuf_*.

Reviewed by:	np
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D45186

(cherry picked from commit 61089df814)
2024-11-30 08:55:57 -05:00
John Baldwin
8b664b8f0e cryptocheck: Don't treat OpenSSL errors as fatal
Abort the current test but keep running additional tests if OpenSSL
reports an error during a test.  This matches the behavior for other
tests such as an error from OCF.

Reviewed by:	markj
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D45279

(cherry picked from commit b0e7358bf8)
2024-11-30 08:55:57 -05:00
John Baldwin
5b0997fb61 cryptocheck: Don't test Chacha20-Poly1305 with an IV size of 8
OpenSSL 3.0+ doesn't support an IV size of 8 either for the Chacha20
stream cipher or the AEAD combination with Poly1305.  This did work
previously with OpenSSL 1.1.

Reviewed by:	markj
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D45280

(cherry picked from commit 4ebf794a08)
2024-11-30 08:55:57 -05:00
Austin Shafer
d95675349a linuxkpi: Provide a non-NULL value for THIS_MODULE
THIS_MODULE is used to differentiate modules on Linux. We currently
completely stub out any Linux struct module usage, but THIS_MODULE
is still used to populate the "owner" fields of various drivers.
Even though we don't actually dereference these "owner" fields they
are still used by drivers to check if devices/dmabufs/etc come
from different modules. For example, during DRM GEM import some
drivers check if the dmabuf's owner matches the dev's owner. If
they match because they are both NULL drivers may incorrectly think
two resources come from the same module.

This adds a general purpose __this_linker_file which will point to
the linker file of the module that uses it. We can then use that
pointer to have a valid value for THIS_MODULE.

Reviewed by:	bz, jhb
Differential Revision:	https://reviews.freebsd.org/D44306

(cherry picked from commit 28a59100b5)
2024-11-30 08:55:57 -05:00
John Baldwin
13e770f1f0 uio: Use switch statements when handling UIO_READ vs UIO_WRITE
This is mostly to reduce the diff with CheriBSD which adds additional
constants to enum uio_rw, but also matches the normal style used for
uio_segflg.

Reviewed by:	kib, emaste
Obtained from:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D45142

(cherry picked from commit 473c90ac04)
2024-11-30 08:55:57 -05:00
John Baldwin
1fd57c5735 md: Merge two switch statements in mdstart_vnode
While here, use bp->bio_cmd instead of auio.uio_rw to drive read vs
write behavior.

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

(cherry picked from commit f75764fea3)
2024-11-30 08:55:57 -05:00
John Baldwin
8bebcb2676 speaker: Use standard C bool
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D43717

(cherry picked from commit c83d83206a)
2024-11-30 08:55:57 -05:00
John Baldwin
35d8944bfc i386: Use bool for booleans in getmemsize
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D43716

(cherry picked from commit bf20896da4)
2024-11-30 08:55:56 -05:00
John Baldwin
5ced86e1e2 amd64: Use bool for booleans in getmemsize
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D43693

(cherry picked from commit 70539d5da6)
2024-11-30 08:55:56 -05:00
Ka Ho Ng
57a7f61b13 kerneldump: fix incorrect SETSIZE to BIT_COPY_STORE_REL when livedump
Also replace malloc/free with BITSET_ALLOC/BITSET_FREE macros.

Sponsored by:	Juniper Networks, Inc.
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D47708

(cherry picked from commit 9ad8116b54)
2024-11-30 06:53:49 +00:00
Ariel Ehrenberg
b0b932804b mlx5: Fix handling of port_module_event
(cherry picked from commit 253a1fa16b)
2024-11-30 02:34:54 +02:00
Christos Margiolis
0f6a6b2e42 sound: Remove unused CHN_F_SILENCE
No functional change intended.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch, markj, emaste
Differential Revision:	https://reviews.freebsd.org/D47664

(cherry picked from commit 6d77827b96)
2024-11-29 13:28:07 +01:00
Christos Margiolis
0ef520dca6 sound: Remove CHN_F_SLEEPING
The KASSERT in chn_sleep() can be triggered if more than one thread
wants to sleep on a given channel at the same time. While this is not
really a common scenario, tools such as stress2, which use fork() and
the child process(es) inherit the parent's FDs as a result, we can end
up triggering such scenarios.

Fix this by removing CHN_F_SLEEPING altogether, which is not very useful
in the first place:
- CHN_BROADCAST() checks cv_waiters already, so there is no need to
  check CHN_F_SLEEPING as well.
- We can check whether cv_waiters is 0 in pcm_killchans(), instead of
  whether CHN_F_SLEEPING is not set.

Reported by:	dougm, pho (stress2)
Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch, markj
Differential Revision:	https://reviews.freebsd.org/D47559

(cherry picked from commit 5317480967)
2024-11-29 13:28:07 +01:00
Christos Margiolis
3397443e50 sound: Remove PCM_DETACHING(), SD_F_DETACHING and SD_F_DYING
Since SD_F_REGISTERED is cleared at the same time SD_F_DETACHING and
SD_F_DYING are set, and since PCM_DETACHING() is always used in
conjuction with PCM_REGISTERED()/DSP_REGISTERED(), it is enough to just
check SD_F_REGISTERED.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch, markj
Differential Revision:	https://reviews.freebsd.org/D47463

(cherry picked from commit 6d4c59e261)
2024-11-29 13:28:06 +01:00
Christos Margiolis
1682d80337 sound: Fix hot-unload panics
This patch fixes multiple different panic scenarios occuring during
hot-unload:

1. The channel is unlocked in chn_read()/chn_write() for uiomove(9) and
   in the meantime we enter pcm_killchans() and free it. By the time we
   have returned from userland and try to lock it back, the channel will
   have been freed.
2. The parent channel has been freed in pcm_killchans(), but at the same
   time, some yet-unstopped vchan's chn_read()/chn_write() calls
   chn_start(), which eventually calls vchan_trigger(), which references
   the freed parent.
3. PCM_WAIT() panics because it references a freed PCM lock.

For scenarios 1 and 2, refactor pcm_killchans() to first make sure all
channels have been stopped, and then proceed to free them one by one, as
opposed to freeing the first free channel until all channels have been
freed. This change makes the code more robust, but might introduce some
performance overhead when many channels are allocated, since we
continuously loop through the channel list until all of them are
stopped, and then we loop one last time to free them.

For scenario 3, restructure the code so that we can use destroy_dev(9)
instead of destroy_dev_sched(9) in dsp_destroy_dev(). Because
destroy_dev(9) blocks until all references to the device have went away,
we ensure that the PCM cv and lock will be freed safely.

While here, move the delete_unrhdr(9) calls to pcm_killchans() and
re-order some lines.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D47462

(cherry picked from commit 2839ad58dd)
2024-11-29 13:28:06 +01:00
Christos Margiolis
950f0c86d3 sound: Fix chn_trigger() and vchan_trigger() races
Consider the following scenario:

1. CHN currently has its trigger set to PCMTRIG_STOP.
2. Thread A locks CHN, calls CHANNEL_TRIGGER(PCMTRIG_START), sets the
   trigger to PCMTRIG_START and unlocks.
3. Thread B picks up the lock, calls CHANNEL_TRIGGER(PCMTRIG_ABORT) and
   returns a non-zero value, so it returns from chn_trigger() as well.
4. Thread A picks up the lock and adds CHN to the list, which is
   _wrong_, because the last call to CHANNEL_TRIGGER() was with
   PCMTRIG_ABORT, meaning the channel is stopped, yet we are adding it
   to the list and marking it as started.

Another problematic scenario:

1. Thread A locks CHN, sets the trigger to PCMTRIG_ABORT, and unlocks
   CHN. It then locks PCM and _removes_ CHN from the list.
2. In the meantime, since thread A unlocked CHN, thread B has locked it,
   set the trigger to PCMTRIG_START, unlocked it, and is now blocking on
   PCM held by thread A.
3. At the same time, thread C locks CHN, sets the trigger back to
   PCMTRIG_ABORT, unlocks CHN, and is also blocking on PCM. However,
   once thread A unlocks PCM, because thread C is higher-priority than
   thread B, it picks up the PCM lock instead of thread B, and because
   CHN is already removed from the list, and thread B hasn't added it
   back yet, we take a page fault in CHN_REMOVE() by trying to remove a
   non-existent element.

To fix the former scenario, set the channel trigger before the call to
CHANNEL_TRIGGER() (could also come after, doesn't really matter) and
check if anything changed one we lock CHN back.

To fix the latter scenario, use the SAFE variants of CHN_INSERT_HEAD()
and CHN_REMOVE(). A similar scenario can occur in vchan_trigger(), so do
the trigger setting after we've locked the parent channel.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D47461

(cherry picked from commit 5ac39263d8)
2024-11-29 13:28:06 +01:00
Christos Margiolis
2d1cfa142c snd_dummy: Fix callout(9) races
Use callout_init_mtx(9) to associate the callback with the driver's
lock. Also make sure the callout is stopped properly during detach.

While here, introduce a dummy_active() function to know when it's
appropriate to stop or not reschedule the callout.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch, markj
Differential Revision:	https://reviews.freebsd.org/D47459

(cherry picked from commit 5bd08172b4)
2024-11-29 13:28:06 +01:00
K Rin
0dd21407bd
newsyslog.conf(5): Accept human unit suffix in the size filed
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1505

(cherry picked from commit 1f78bbb5c4)

newsyslog.conf(5): Remove duplicate word

Reported by:	jlduran
Fixes:	1f78bbb5c4 newsyslog.conf(5): Accept human unit suffix in the size filed

(cherry picked from commit af2015b01f)
2024-11-29 13:12:12 +08:00
Mark Johnston
a2f54460e3 netlink/route: Fix the argument list for rtnl_handle_iflink()
This function is registered as a ifnet_link_event and so should have the
corresponding argument list.

PR:		282870
Reported by:	nakayamakenjiro@gmail.com
MFC after:	1 week

(cherry picked from commit 0289db3259)
2024-11-28 14:41:52 +00:00
Mark Johnston
9917a1357c fibs_test: Run in a jail
These tests assume exclusive use of one or more FIBs and so can't be run
in parallel.  Running them in a VNET jail sidesteps this problem.

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

(cherry picked from commit a079f2b52a)
2024-11-28 14:38:17 +00:00
Mark Johnston
906d603eeb inpcb: Make some cosmetic improvements to in_pcbbind()
- Use the local var "laddr" instead of sin->sin_addr in one block.
- Use in_nullhost() instead of explicit comparisons with INADDR_ANY.
- Combine multiple socket options checks into one.
- Fix indentation.
- Remove some unhelpful comments.

This is in preparation for some simplification and bug-fixing.

No functional change intended.

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

(cherry picked from commit 45a77bf23f)
2024-11-28 14:38:17 +00:00
Mark Johnston
34182e597b swap_pager: Ensure that swapoff puts swapped-in pages in page queues
Readahead/behind pages are handled by the swap pager, but the get_pages
caller is responsible for putting fetched pages into queues (or wiring
them beforehand).

Note that the VM object lock prevents the newly queued page from being
immediately reclaimed in the window before it is marked dirty by
swap_pager_swapoff_object().

Reported by:	pho
Tested by:	pho
Reviewed by:	dougm, alc, kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D47526

(cherry picked from commit d11d407aee)
2024-11-28 14:38:17 +00:00
Mark Johnston
ee0c917eeb hwpmc: Fix whitespace in logging macros
MFC after:	1 week
Sponsored by:	Klara, Inc.

(cherry picked from commit 3c29734502)
2024-11-28 14:38:17 +00:00
Mark Johnston
e59a3bb028 vfs: Fix vop_stdis_text()
atomic(9) primitives are documented as operating on unsigned types.
Here, we need a cast to avoid a tautological comparison.

Add a regression test for access(2), which was affected by the bug.

Reported by:	NetApp
Reviewed by:	kib
Fixes:		e511bd1406 ("vfs: fully lockless v_writecount adjustment")
MFC after:	1 week
Sponsored by:	Klara, Inc.
Sponsored by:	NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D47672

(cherry picked from commit 4ff291ebe8)
2024-11-28 14:38:17 +00:00
Mark Johnston
c9f9f1a282 makefs.8: Clarify that makefs-generated zpools always have the same GUID
PR:		282832
MFC after:	1 week

(cherry picked from commit a20249443b)
2024-11-28 14:38:17 +00:00
Franco Fichtner
03fdd4f38d atf: Guard libexec/atf with WITH_TESTS_SUPPORT
Other atf components are guarded by WITH_TESTS_SUPPORT already.
WITH_TESTS is for actual tests.

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

(cherry picked from commit 43e045c173)
2024-11-28 14:38:16 +00:00
Konstantin Belousov
ab6a6a0928 kern___realpathat(): style
(cherry picked from commit 31784ee1e3)
2024-11-28 14:53:17 +02:00
Wolfram Schneider
7efa3a6028 fhreadlink.2: fix old typo in the manpage
PR: 282967

(cherry picked from commit fb4cdd5160)
2024-11-28 14:53:17 +02:00
Mark Johnston
1c65ea2884 efirt: Fix the TDP_EFIRT assertion
(cherry picked from commit 07593d13fa)
2024-11-28 14:53:17 +02:00
Konstantin Belousov
5f5b47e374 amd64 efi rt: handle #BP
PR:	282860

(cherry picked from commit e6ec41fa86)
2024-11-28 14:53:17 +02:00
Konstantin Belousov
617e683319 efirt: mark dynamic region executing the RT code with the TDP_EFIRT flag
For MFC purposes, the TDP_EFIRT flag is moved to td_pflags2.

(cherry picked from commit a03957a706)
2024-11-28 14:53:16 +02:00
Kristof Provost
93c80b79ad pf: fix potential state key leak
If we fail to attach the new state keys in pf_state_key_attach() we are
expected to free both keys. Do so.
Note that in some scenarios both key are the same, so check for that
before freeing.

MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D47495

(cherry picked from commit 371bd29d4b)
2024-11-27 14:19:53 +01:00
Konstantin Belousov
73cc71607d rtld: drop RTLD_INIT_PAGESIZES_EARLY
(cherry picked from commit 5bc24fd7a2)
2024-11-27 13:31:55 +02:00
Kevin Bowling
645c45e297 e1000: Try auto-negotiation for fixed 100 or 10 configuration
This is a retread of https://reviews.freebsd.org/D34449 which I think
will fix the issue for the remote side not supporting autoneg.  We now
attempt an autoneg, and if that fails fall back to the current code
that forces the link speed/duplex.

The original intent of this patch is to inform the remote switch of
duplex settings when we (the client) are specifying a fixed 10 or 100
speed.  Otherwise it may get the duplex setting wrong.

The tricky case is when the remote (switch) side is fixing its
speed AND duplex while disabling autoneg and we (client) need to do
the same, which still seems to be common enough at some ISPs.

Original commit message follows:
Currently if an e1000 interface is set to a fixed media configuration,
for gigabit, it will participate in auto-negotiation as required by
IEEE 802.3-2018 Clause 37. However, if set to fixed media configuration
for 100 or 10, it does NOT participate in auto-negotiation.

By my reading of Clauses 28 and 37, while auto-negotiation is optional
for 100 and 10, it is not prohibited and is, in fact, "highly
recommended".

This patch enables auto-negotiation for fixed 100 and 10 media
configuration, in a similar manner to that already performed for 1000.
I.e., the patch enables advertising of just the manually configured
settings with the goal of allowing the remote end to match the manually
configured settings if it has them available.

To be clear, this patch does NOT allow an em(4) interface that has been
manually configured with specific media settings to respond to
auto-negotiation by then configuring different parameters to those that
were manually configured. The intent of this patch is to fully comply
with the requirements of Clause 37, but for 100 and 10.

The need for this has arisen on an em(4) link where the other end is
under a different administrative control and is set to full
auto-negotiation. Due to the cable length GigE is not working well. It
is desired to set the em(4) end to "media 100baseTX mediatype
full-duplex" which does work when both ends are configured that way.
Currently, because em(4) does not participate in autoneg for this
setting, the remote defaults to half-duplex - i.e., there's a duplex
mismatch and things don't work. With this patch, em(4) would inform the
remote that it has only 100baseTX full, the remote would match that and
it will work.

Tested by:	Natalino Picone <natalino.picone@nozominetworks.com>
Tested by:	Franco Fichtner <franco@opnsense.org>
Tested by:	J.R. Oldroyd <fbsd@opal.com> (previous version)
Sponsored by:	Nozomi Networks
Sponsored by:	BBOX.io
Differential Revision:	https://reviews.freebsd.org/D47336

(cherry picked from commit bceec3d80a)
2024-11-26 21:13:34 -07:00
Konstantin Belousov
ed4b2d1594 _dl_iterate_phdr_locked(): fix libc and libdl
Add prototype.  Export from libdl.

Fixes:	1426fd6cff
Reviewed by:	kevans
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 209fd89a28)
2024-11-26 19:15:56 -06:00
Kyle Evans
708106fb80 rtld: implement _dl_iterate_phdr_locked
Some sanitizers need to be able to use dl_iterate_phdr() after stopping
the rest of the process, but it's very hard to do so reliably as a
non-participant in the main logic of the program.

Introduce _dl_iterate_phdr_locked to bypass the locking that's normally
required for dl_iterate_phdr() and slap some scary warning on it.  It
will remain undocumented and probably shouldn't be used for anything
else.

Reviewed by:	kib

(cherry picked from commit 1426fd6cff)
2024-11-26 19:15:56 -06:00
Kevin Bowling
9b7f8ee3a1 igc: disable hw.igc.sbp
Similar to 548d8a131d in e1000, disable this by default.

Sponsored by:	BBOX.io

(cherry picked from commit e80419da6c)
2024-11-26 17:28:44 -07:00
Kevin Bowling
e9d4e70774 e1000: Style txrx
Fix up indentation and reflow long lines.

Sponsored by:	BBOX.io

(cherry picked from commit 7390daf87c)
2024-11-26 17:28:32 -07:00
Kevin Bowling
cb9c9b0c35 igc: Style pass igc_txrx
Fix up indentation and reflow long lines.

Sponsored by:	BBOX.io

(cherry picked from commit c7fb7b5d9f)
2024-11-26 17:28:21 -07:00
Kevin Bowling
55ddb8f7f4 ixgbe: Style pass on FreeBSD part of driver
Fix up some indentation and reflow long lines

Sponsored by:	BBOX.io

(cherry picked from commit c58d34dd67)
2024-11-26 17:28:08 -07:00
Kevin Bowling
bfabd58a9b igc: Reflow long lines
Sponsored by:	BBOX.io

(cherry picked from commit 9efc7325f1)
2024-11-26 17:27:57 -07:00
Kevin Bowling
3d0f59024f e1000: Style pass on if_em
Fix up some indentation and reflow long lines

Sponsored by:	BBOX.io

(cherry picked from commit 6f14883066)
2024-11-26 17:27:45 -07:00
Kevin Bowling
23a4b5497a igc: Normalize indentation a bit
Sponsored by:	BBOX.io

(cherry picked from commit d1bb1a5011)
2024-11-26 17:27:32 -07:00
David Gilbert
435a5f94fb sbin/{ffsinfo,mount,newfs}: reference ffs(4) in man pages
With some copy-editing to account for the man page being in
section 7 on stable/14.

PR:		282867
MFC:		stable/14
Approved by:	mhorne (via IRC)

(cherry picked from commit 3a212cc66a)
2024-11-25 23:05:11 +01:00