Commit graph

288184 commits

Author SHA1 Message Date
Kristof Provost c2e0b604a3 netinet tests: test that we send IGMP join/leave packets as expected
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-12-19 17:47:41 +01:00
Kristof Provost ec6682ed6c atf.test: fix installation of python test scripts
Python test scripts get processed (to add the `#! /usr/libexec/
atf_pytest_wrapper` shebang line), into a .xtmp file, and installed from
there. However, as there was no dependency of this .xtmp file on the
original file we kept reinstalling the .xtmp file, even if the original
had been edited already.

This could cause great confusion when debugging python test scripts.

Reviewed by:	markj
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43118
2023-12-19 17:23:54 +01:00
Mike Karels 636592343c tmpfs: increase memory reserve to a percent of available memory + swap
The tmpfs memory reserve defaulted to 4 MB, and other than that,
all of available memory + swap could be allocated to tmpfs files.
This was dangerous, as the page daemon attempts to keep some memory
free, using up swap, and then resulting in processes being killed.
Increase the reserve to a fraction of available memory + swap at
file system startup time.  The limit is expressed as a percentage
of available memory + swap that can be used, and defaults to 95%.
The percentage can be changed via the vfs.tmpfs.memory_percent sysctl,
recomputing the reserve with the new percentage but the initial
available memory + swap.  Note that the reserve can also be set
directly with an existing sysctl, ignoring the percentage.  The
previous behavior can be specified by setting vfs.tmpfs.memory_percent
to 100.

Add sysctl for vfs.tmpfs.memory_percent and the pre-existing
vfs.tmpfs.memory_reserved to tmpfs(5).

PR:		275436
MFC after:	1 month
Reviewed by:	rgrimes
Differential Revision:	https://reviews.freebsd.org/D43011
2023-12-19 09:33:33 -06:00
Mike Karels ed19c0989f tmpfs: enforce size limit on writes when file system size is default
tmpfs enforced the file system size limit on writes for file systems
with a specified size, but not when the size was the default.  Add
enforcement when the size is default: do not allocate additional
pages if the available memory + swap falls to the reserve level.
Note, enforcement is also done when attempting to create a file,
both with and without an explicit file system size.

PR:		275436
MFC after:	1 month
Reviewed by:	cy
Differential Revision:	https://reviews.freebsd.org/D43010
2023-12-19 09:32:58 -06:00
Peter Holm 2134b35e0f stress2: Fix "-Wunused-but-set-variable" warnings. Style fixes, while here 2023-12-19 10:36:41 +01:00
Olivier Certner a540e5ee07 committers-src: Add olce@ with mentors emaste@ and markj@
Approved by:        emaste (mentor)
2023-12-19 09:43:45 +01:00
Mark Johnston d760d74dbe ieee80211: Check for copyout() errors in the SIOCG80211STATS handler
In preparation for annotating copyin() and related functions with
__result_use_check.

Reviewed by:	bz, emaste
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43095
2023-12-18 22:44:54 -05:00
Bjoern A. Zeeb eac3646fcd 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.

Sponsored by:	The FreeBSD Foundation
PR:		274178, 275710
Tested by:	cc
MFC after:	3 days
2023-12-19 00:50:49 +00:00
Robert Wing acd5638e26 tty: delete knotes when TTY is revoked
Do not clear knotes from the TTY until it gets dealloc'ed, unless the
TTY is being revoked, in that case delete the knotes when closed is
called on the TTY.

When knotes are cleared from a knlist, those knotes become detached from
the knlist. And when an event is triggered on a detached knote there
isn't an associated knlist and therefore no lock will be taken when the
event is triggered.

This becomes a problem when a detached knote is triggered on a TTY since
the mutex for a TTY is also used as the lock for its knlists. This
scenario ends up calling the TTY event handlers without the TTY lock
being held and tripping on asserts in the event handlers.

PR:             272151
Reviewed by:	kib, markj
Differential Revision:	https://reviews.freebsd.org/D41605
2023-12-18 15:40:46 -09:00
Mark Johnston d9b7301bb7 nvme: Initialize HMB entries before loading them into the controller
struct nvme_hmb_desc contains a pad field which was not getting
initialized before being synced.  This doesn't have much consequence but
triggers a report from KMSAN, which verifies that host-filled DMA memory
is initialized before it is made visible to the device.  So, let's just
initialize it properly.

Reported by:	KMSAN
Reviewed by:	mav, imp
MFC after:	1 week
Sponsored by:	Klara, Inc.
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D43090
2023-12-18 17:45:24 -05:00
Brooks Davis 8a1b84f861 arm/SYS.h: align with other arches
Rename SYSTRAP() macro to _SYSCALL() and add _SYSCALL_BODY() which invokes
the syscall via _SYCALL() and then calls cerror as required.  Use to
implement PSEUDO() and RSYSCALL() removing _SYSCALL_NOERROR().

Reviewed by:	imp
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43061
2023-12-18 22:28:42 +00:00
Brooks Davis d444ef5393 arm/SYS.h: remove unused CURBRK macro
The last use was removed in 2018 as part of a reimplementation of brk()
and sbrk() in commit 9d9fd255d6.

Reviewed by:	imp
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43060
2023-12-18 22:28:42 +00:00
Brooks Davis 8f465f509b {amd64,i386}/SYS.h: add _SYSCALL and _SYSCALL_BODY
Add a _SYSCALL(name) which calls the SYS_name syscall.  Use it to add a
_SYSCALL_BODY() macro which invokes the syscall and calls cerror as
required.  Use the latter to implement PSEUDO() and RSYSCALL().

Reviewed by:	imp, markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43059
2023-12-18 22:28:42 +00:00
Brooks Davis 300bbb3a43 riscv/SYS.h: implement _SYSCALL_BODY() macro
Add _SYSCALL_BODY() macro which invokes the syscall via _SYCALL() and
calls cerror as required.  Use to implement PSEUDO() and RSYSCALL().

Reviewed by:	imp, markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43057
2023-12-18 22:28:42 +00:00
Mark Johnston 604de40a02 kqueue.9: Update the description of knlist_clear()
knlist_clear() does not free knotes and so does not call fdrop(), so
remove the bit of the function description which claims otherwise.  (The
knote will be dropped by the next queue scan, and it is at that point
that the fd reference will be dropped.)

MFC after:	1 week
2023-12-18 13:16:48 -05:00
Mark Johnston ccf8e1bb38 arm64: Remove an unused global variable
No functional change intended.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Sponsored by:	Juniper Networks, Inc.
2023-12-18 13:13:43 -05:00
Warner Losh e02bee0b3e efibootmgr: Report the path to the device
Report the entire path to the device, rather than the the bit after /dev/
for the --esp command. Nothing in the tree depends on the output
format: Only bsdinstall's bootconfig script calls efibootmgr, and it
doesn't use the --esp/-E flag.

Sponsored by:		Netflix
2023-12-18 10:09:13 -07:00
Warner Losh 6aa1b4332f efibootmgr: Document -e command line switch
-e env will include `env` in the boot loader. Document that the boot
loader appends the `env` to the BootXXXX variable, and will parse it as
a series of a=b values to set in the boot loader's environment.  These
assignments are separated by spaces. The env arg needs to be quoted if
more than one env var is to be set (we parse only the next argument on
the command line).

Sponsored by:		Netflix
2023-12-18 10:01:38 -07:00
Gordon Tetlow 92f58c69a1
Implement "strict key exchange" in ssh and sshd.
This adds a protocol extension to improve the integrity of the SSH
transport protocol, particular in and around the initial key exchange
(KEX) phase.

Full details of the extension are in the PROTOCOL file.

OpenBSD-Commit-ID: 2a66ac962f0a630d7945fee54004ed9e9c439f14

Approved by:	so (implicit)
Obtained from:	https://anongit.mindrot.org/openssh.git/patch/?id=1edb00c58f8a6875fad6a497aa2bacf37f9e6cd5
Security:	CVE-2023-48795
2023-12-18 08:22:22 -08:00
Alan Somers 18e2c4175f Remove _POSIX_PRIORITIZED_IO references from man pages
We don't support it, so there's no need to tell readers what would
happen if we did.  Also, don't remind the user that a certain field is
ignored by aio_read.  Mentioning every ignored field would make the man
pages too verbose.

MFC after:	1 week
Sponsored by:	Axcient
Reviewed by:	Pau Amma <pauamma@gundo.com>
Differential Revision: https://reviews.freebsd.org/D42622
2023-12-18 08:06:55 -07:00
Igor Ostapenko 66d77e0f73 netlink: fix debug text typo in message parser
Signed-off-by: Igor Ostapenko <pm@igoro.pro>
Pull-request: https://github.com/freebsd/freebsd-src/pull/942
2023-12-18 08:34:55 -05:00
Richard Scheffenegger e3b9058e5c tcp: properly unroll sack transmission on tx error with LRD
Reviewed By:           tuexen, #transport
MFC after:             1 week
Sponsored by:          NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D43085
2023-12-18 13:02:22 +01:00
Ram Kishore Vegesna a9504d76cc ocs_fc: Use xpt_path_sbuf() to copy the path to sbuf.
Reported by:	imp
 MFC after:	1 week
2023-12-18 14:22:06 +05:30
Kyle Evans 0a82cd4f10 calendar: correct the search order for files
Include files that don't begin with a '/' are documented to search the
current directory, then /usr/share/calendar.  This hasn't been accurate
for years, since e061f95e7b ("Rework calendar(1) parser") rewrote a
lot of this.

Stash off the cwd before we do any chdir()ing around and use that to
honor the same order we'll follow for the -f flag.  This may result in
an extra lookup that will fail for the initial calendar file, but I
don't think it's worth the complexity to avoid it.

While we're here, fix the documentation to just reference the order
described in FILES so that we only need to keep it up to date in one
place.

Reviewed by:	bapt
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D42278
2023-12-17 23:53:51 -06:00
Peter Eriksson 7aa375dcc6 libc: correct some memory leaks in acl_to_text(3) and acl_to_text_np(3)
PR:	275232
MFC after:	1 week
2023-12-18 00:06:03 +02:00
Richard Scheffenegger 31cf66d755 dummynet: add simple gilbert-elliott channel model
Have a simple Gilbert-Elliott channel model in
dummynet to mimick correlated loss behavior of
realistic environments. This allows simpler testing
of burst-loss environments.

Reviewed By:           tuexen, kp, pauamma_gundo.com, #manpages
Sponsored by:          NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D42980
2023-12-17 13:20:45 +01:00
Gordon Bergling 4fb5eda649 tcp: Remove the documented dependency of TCPHPTS for RACK and BBR
Since TCPHPTS is now included in the GENERIC kernel, remove the
documented dependency of it from the tcp_rack(4) and tcp_bbr(4)
manual pages.

Reviewed by:	tuexen
Differential Revision:	https://reviews.freebsd.org/D43084
2023-12-17 19:31:16 +01:00
Gordon Bergling ada4cd3f77 qat: Fix two typos in source code comments
- s/parmeters/parameters/

MFC after:	3 days
2023-12-17 15:18:57 +01:00
Yu-Hsun Chen 452c3e9514
mt(1): Fix typo
This is from the Advanced UNIX Programming Course (Fall’23) at NTHU.

MFC after:	3 days
Pull Request:	https://github.com/freebsd/freebsd-src/pull/931
2023-12-17 18:49:42 +08:00
Yu-Hsun Chen 1a35ead682
mkimg(1): Fix typo
This is from the Advanced UNIX Programming Course (Fall’23) at NTHU.

MFC after:	3 days
Pull Request:	https://github.com/freebsd/freebsd-src/pull/930
2023-12-17 18:49:28 +08:00
Yu-Hsun Chen 0ba51e3b63
fstat(1): Fix typo
This is from the Advanced UNIX Programming Course (Fall’23) at NTHU.

MFC after:	3 days
Pull Request:	https://github.com/freebsd/freebsd-src/pull/929
2023-12-17 18:41:53 +08:00
Yu-Hsun Chen a2ee3070d8
awk(1): Fix typo
This is from the Advanced UNIX Programming Course (Fall’23) at NTHU.

MFC after:	3 days
Pull Request:	https://github.com/freebsd/freebsd-src/pull/928
2023-12-17 18:40:29 +08:00
Pawel Jakub Dawidek 6f3e9bac4d vm: Plug umtx shm object leak.
Reviewed by:	kib
Approved by:	oshogbo
MFC after:	1 week
Sponsored by:	Fudo Security
Differential Revision:	https://reviews.freebsd.org/D43073
2023-12-16 05:18:36 -08:00
Konstantin Belousov ca39f23347 ufs: do not leave around empty buffers shadowing disk content
If the ffs_write() operation specified to overwrite the whole buffer,
ffs tries to save the read by not validating allocated buffer. Then
uiommove() might fail with EFAULT, in which case pages are left zeroed
and marked valid but not read from the disk. Then vn_io_fault() logic
retries the write after holding the user pages to avoid EFAULTs. In
erronous case of really faulty buffer, or in contrived case of writing
from file to itself, we are left with zeroed buffer instead of valid
content written back to disk.

Handle the situation by releasing non-cached buffer on fault, instead
of clearing it. Note that buffers with alive dependencies cannot be
released, but also either they cannot have valid content on the disk
because dependency on data buffer means that it was not yet written, or
they were reallocated by fragment extension or ffs_reallocbks(), and are
already fully valid.

Reported by:	kevans
Discussed with:	mav
In collaboration with:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-12-16 00:06:10 +02:00
Brad Davis 863975b684 release/Makefile.vm: Add cloudware overrides
Allow the cloudware *_FLAVOURS and *_FSLIST values to be overridden
at the command line, to assist users who want to e.g. build only one
of the many EC2 AMIs available.
2023-12-15 10:08:50 -08:00
Elliott Mitchell 4c9e6ad320 xen: add atomic #defines to accomodate differing xen_ulong_t sizes
Alas, ARM declared xen_ulong_t to be 64-bits long, unlike i386 where
it matches the word size.  As a result, compatibility wrappers are
needed for Xen atomic operations.

Reviewed by: royger
2023-12-15 14:59:26 +01:00
Elliott Mitchell ed917e0fae xen/intr: correct type of evtchn_enabled
evtchn_enabled needs to match the type of Xen's evtchn_mask.  As Xen's
headers have a type for this, use Xen's type.

Reviewed by: royger
2023-12-15 14:59:25 +01:00
Elliott Mitchell ea9a9b122d sys/conf: make xen_acpi_cpu.c depend on acpi
Since Xen can function on systems without ACPI, make sure this key
dependency is handled.

Reviewed by: royger
2023-12-15 14:59:25 +01:00
Elliott Mitchell 40e1d9d45f xen: add SPDX license tags to Xen headers
These are in fact GPLv2 when distributed with the Linux kernel, but the
license also allows MIT if distributed separately.  Add the markers to
avoid interference by automated tools.

Differential Revision: https://reviews.freebsd.org/D32796
Reviewed by: royger
2023-12-15 14:59:25 +01:00
Cheng Cui 93b7818226
libexec/rc/rc.initdiskless: make tar's path flexible
Summary:
PR:		274977
Reviewed by: rgrimes,imp
Approved by: rgrimes
MFC after:      1 month
2023-12-15 03:46:44 -05:00
Martin Matuska 5fb307d29b zfs: merge openzfs/zfs@86e115e21
Notable upstream pull request merges:
 #15643 a9b937e06 For db_marker inherit the db pointer for AVL comparision
 #15644 e53e60c0b DMU: Fix lock leak on dbuf_hold() error
 #15653 86063d903 dbuf: Handle arcbuf assignment after block cloning
 #15656 86e115e21 dbuf: Set dr_data when unoverriding after clone

Obtained from:	OpenZFS
OpenZFS commit:	86e115e21e
2023-12-15 14:18:07 +01:00
Kristof Provost c2e340452c mcast: fix leaked igmp packets on multicast cleanup
When we release a multicast address (e.g. on interface shutdown) we may
still have packets queued in inm_scq. We have to free those, or we'll
leak memory.

Reviewed by:	glebius
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43033
2023-12-14 22:06:01 +01:00
Kristof Provost c196e43243 Revert "mcast: fix memory leak in imf_purge()"
This reverts commit fa03d37432.

This commit caused us to not send IGMP leave messages if the inpcb went
away. In other words: we freed pending packets whenever the socket
closed rather than when the interface (or address) goes away.

Reviewed by:	glebius
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43032
2023-12-14 22:05:34 +01:00
Kristof Provost 0bc82e4fbb ip_mroute: allow MRT_DEL_MFC even if there are pending upcalls
In del_mfc() we try to find the forwarding entry, but that fails to find
the entry if mfc_stall_ring is not empty.

We should find the entry anyway, and destroy it (and any pending
messages) on delete.

Reviewed by:	glebius
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43031
2023-12-14 22:04:43 +01:00
Jessica Clarke 2a622f14e8 kldxref: Reduce divergence between per-architecture files
Note that relbase is always 0 for DSOs so its omission for __KLD_SHARED
architectures was not a bug in practice.

Whilst here, also parenthesise the dest offset for where to avoid
transiently creating an out-of-bounds pointer, which is UB (though even
on CHERI architectures, where capability bounds compression can result
in that creating invalid capabilities that will trap on dereference,
optimisation will reassociate to the correct form in practice and thus
work just fine).
2023-12-14 20:17:20 +00:00
Jessica Clarke aaba1490ec kldxref: Implement aarch64 R_AARCH64_AB64 relocation
Doing nothing seems to be sufficient but is strange, inconsistent with
other architectures, and not necessary when it's easy to support
properly.
2023-12-14 20:17:20 +00:00
Jessica Clarke ae7925cafe kldxref: Fix MIPS Elf_Rel addend computation
Fixes:	0299afdff1 ("kldxref: Make use of libelf to be a portable cross tool")
2023-12-14 20:17:19 +00:00
Kenneth D. Merry 264610a86e mpr, mps: Establish busdma boundaries for memory pools
Most all of the memory used by the cards in the mpr(4) and mps(4)
drivers is required, according to the specs and Broadcom developers,
to be within a 4GB segment of memory.

This includes:

System Request Message Frames pool
Reply Free Queues pool
ReplyDescriptorPost Queues pool
Chain Segments pool
Sense Buffers pool
SystemReply message pool

We got a bug report from Dwight Engen, who ran into data corruption
in the BAE port of FreeBSD:

> We have a port of the FreeBSD mpr driver to our kernel and recently
> I found an issue under heavy load where a DMA may go to the wrong
> address. The test system is a Supermicro X10SRH-CLN4F with the
> onboard SAS3008 controller setup with 2 enterprise Micron SSDs in
> RAID 0 (striped). I have debugged the issue and narrowed down that
> the errant DMA is one that has a segment that crosses a 4GB
> physical boundary.  There are more details I can provide if you'd
> like, but with the attached patch in place I can no longer
> re-create the issue.

> I'm not sure if this is a known limit of the card (have not found a
> datasheet/programming docs for the chip) or our system is just
> doing something a bit different. Any helpful info or insight would
> be welcome.

> Anyway, just thought this might be helpful info if you want to
> apply a similar fix to FreeBSD. You can ignore/discard the commit
> message as it is my internal commit (blkio is our own tool we use
> to write/read every block of a device with CRC verification which
> is how I found the problem).

The commit message was:

> [PATCH 8/9] mpr: fix memory corrupting DMA when sg segment crosses
> 4GB boundary

> Test case was two SSD's in RAID 0 (stripe). The logical disk was
> then partitioned into two partitions. One partition had lots of
> filesystem I/O and the other was initially filled using blkio with
> CRCable data and then read back with blkio CRC verify in a loop.
> Eventually blkio would report a bad CRC block because the physical
> page being read-ahead into didn't contain the right data. If the
> physical address in the arq/segs was for example 0x500003000 the
> data would actually be DMAed to 0x400003000.

The original patch was against mpr(4) before busdma templates were
introduced, and only affected the buffer pool (sc->buffer_dmat) in
the mpr(4) driver. After some discussion with Dwight and the
LSI/Broadcom developers and looking through the driver, it looks
like most of the queues in the driver are ok, because they limit
the memory used to memory below 4GB. The buffer queue and the chain
frames seem to be the exceptions.

This is pretty much the same between the mpr(4) and mps(4) drivers.

So, apply a 4GB boundary limitation for the buffer and chain frame pools
in the mpr(4) and mps(4) drivers.

Reported by:	Dwight Engen <dwight.engen@gmail.com>
Reviewed by:	imp
Obtained from:	Dwight Engen <dwight.engen@gmail.com>
Differential Revision:	<https://reviews.freebsd.org/D43008>
2023-12-14 15:05:17 -05:00
Dag-Erling Smørgrav 53fc8e1902 cp: Move the -N flag in the manual page.
This accidentally got left out of 0f4467ce44.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans, allanjude
Differential Revision:	https://reviews.freebsd.org/D43067
2023-12-14 21:02:06 +01:00
Jessica Clarke 3812c653b1 Revert "Don't try and run kldxref for arm kernels"
Now that kldxref supports arm this should not be needed.

This reverts commit 0840bdbf2a.
2023-12-14 18:27:09 +00:00