Commit graph

277398 commits

Author SHA1 Message Date
Zhenlei Huang d77e45e29f ng_socket: Treat EEXIST from kern_kldload() as success
EEXIST is possible in a race condition.

Inspired by:	ffc72591b1 (Don't worry if a module is already loaded ...)
Reviewed by:	glebius
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D44633

(cherry picked from commit f6f67f58c1)
(cherry picked from commit 2e8d60c685)
2024-04-16 12:36:16 +08:00
Zhenlei Huang 41e4389a3d debugnet: Fix logging of frame length
MFC after:	1 week

(cherry picked from commit 6fe4d8395b)
(cherry picked from commit 800bd7da4c)
2024-04-15 12:03:06 +08:00
Zhenlei Huang 65212656f8 ethernet: Fix logging of frame length
Both the mbuf length and the total packet length are signed.

While here, update a stall comment to reflect the current practice.

Reviewed by:	kp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D42390

(cherry picked from commit e7102929bf)
(cherry picked from commit 4d65728d55)
2024-04-15 12:02:57 +08:00
Rick Macklem c39938ddd3 exports.5: Add RFC number for NFS over TLS
This is a content change.

(cherry picked from commit 401c0f8aa1)
2024-04-13 18:15:46 -07:00
Alexander Motin 330954bdb8
Unify arc_prune_async() code, fix excessive ARC pruning
There is no sense to have separate implementations for FreeBSD and Linux.  Make
Linux code shared as more functional and just register FreeBSD-specific prune
callback with arc_add_prune_callback() API.

Aside of code cleanup this fixes excessive pruning on FreeBSD.

[olce: This code comes from the OpenZFS pull request:
https://github.com/openzfs/zfs/pull/16083, vendor-merged into our tree.  Its
commit message has been slightly adapted to the present context.  The upstream
pull request has been reviewed and merged into 'zfs-2.1.16-staging' as
5b81b1bf5e6d6aeb8a87175dcb12b529185cac2f, which should come into our tree at the
next vendor import.  This is the same code that was merged into stable/14 and
main as part of vendor merges, and released as an EN (FreeBSD-EN-23:18.openzfs)
over releng/14.0 by markj@.]

PR:             275594, 274698
Reported by:    Seigo Tanimura <seigo.tanimura@gmail.com>, markj, and others
Tested by:      olce
Approved by:    emaste (mentor)
Obtained from:  OpenZFS
Sponsored by:   iXsystems, Inc.
Sponsored by:   The FreeBSD Foundation
Signed-off-by:  Alexander Motin <mav@FreeBSD.org>
2024-04-12 15:00:11 +02:00
Zhenlei Huang f0edd08b27 LinuxKPI: Remove the temporary variable fileid from the macro request_module
The variable fileid stores the result from kern_kldload() but never gets
used. Since the third parameter `*fileid` of kern_kldload() can be NULL,
this unused variable can be safely removed.

No functional change intended.

Reviewed by:	emaste, bz, #linuxkpi
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D44583

(cherry picked from commit 317cc829ee)
(cherry picked from commit d4d5aed66a)
2024-04-12 19:27:13 +08:00
Gordon Bergling 15ce8a1cc1 mem.4: Correct the HISTORY section
The history section (added in CSRG) claimed both first appeared in v6.
Looking at the manuals in the TUHS archive, /dev/mem was in v1
and /dev/kmem was introduced in v5.

Reviewed by:	imp
Obtained from:	OpenBSD
Differential Revision:	https://reviews.freebsd.org/D44486

(cherry picked from commit 8a56ef8d75)
2024-04-11 14:10:53 +02:00
Mikael Urankar 54030e8a5d dma.conf: Fix typo
Pull Request: https://github.com/freebsd/freebsd-src/pull/1150

(cherry picked from commit c92400a6f6)
(cherry picked from commit bedc8daace)
2024-04-09 09:37:28 -04:00
a-biardi c525951492 freebsd-update: Fix typo in comment
s/patchname expansion/pathname expansion/

Signed-off-by: a.biardi@tiscali.it
Pull-request: https://github.com/freebsd/freebsd-src/pull/1152
(cherry picked from commit 9181171162)
(cherry picked from commit 507e18dfc3)
2024-04-09 09:37:28 -04:00
Ed Maste 8e8d76571f ccdconfig: reference gpart rather than fdisk and disklabel
fdisk and disklabel are legacy tools for legacy disk partitioning
schemes.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D43564

(cherry picked from commit 8669e516f0)
(cherry picked from commit 7ced571062)
2024-04-09 09:37:28 -04:00
Ed Maste da7a435018 ccdconfig: remove obsolete references to BSD disklabels
ccd(4) previoulsy had knowledge of BSD disklabels, and relied on their
use on the underlying disks, but this hasn't been the case since 2003
(commit 0f76d6d822).

Remove disklabel references from the man page.

Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D43574

(cherry picked from commit a3ed434a69)
(cherry picked from commit b5ae8f2171)
2024-04-09 09:37:28 -04:00
Eugene Grosbein 1879f7affb MFC: if_bridge: change MTU for new members
Rather than reject new bridge members because they have the wrong MTU
change it to match the bridge. If that fails, reject the new interface.

PR:	264883
Different Revision:	https://reviews.freebsd.org/D35597

(cherry picked from commit 1865ebfb12)
2024-04-09 17:50:20 +07:00
Eugene Grosbein d3ce1a1b37 MFC: if_bridge: use IF_MINMTU
Replace incorrect constant 576 with IF_MINMTU to check for minimum MTU.
This unbreaks bridging tap interfaces with small mtu.

MFC after:	1 week
2024-04-09 17:22:38 +07:00
Zhenlei Huang a7b2c45550 kern linker: Do not touch userrefs of the kernel file
A nonzero `userrefs` of a linker file indicates that the file, either
loaded from kldload(2) or preloaded, can be unloaded via kldunload(2).
As for the kernel file, it can be unloaded by the loader but should not
be after initialization.

This change fixes regression from d9ce8a41ea which incidentally
increases `userrefs` of the kernel file.

Reviewed by:	dfr, dab, jhb
Fixes:	d9ce8a41ea kern_linker: Handle module-loading failures in preloaded .ko files
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D42530

(cherry picked from commit 39450eba8e)
(cherry picked from commit 7da45efb09)
2024-04-09 12:13:19 +08:00
Zhenlei Huang a2f5765662 kern linker: Do not unload a module if it has dependants
Despite the name, linker_file_unload() will drop a reference and return
success when the module file has dependants, i.e. it has more than one
reference. When user request to unload such modules then the kernel
should reject unambiguously and immediately.

PR:		274986
Reviewed by:	dfr, dab, jhb
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D42527

(cherry picked from commit f43ff3e15c)
(cherry picked from commit f1994d1eb2)
2024-04-09 12:13:08 +08:00
John Baldwin 092dd9545f ddp: Clear active DDP buffer members to NULL to pacify an assertion
Reviewed by:	np
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D43999

(cherry picked from commit 25429e2743)
2024-04-08 11:06:58 -07:00
John Baldwin 257f36a7db kldxref: Properly handle reading strings near the end of an ELF file
If a string is at or near the end of an input file and the amount of
remaining data in the file is smaller than the maximum string size,
the pread(2) system call would return a short read which is treated as
an error.  Instead, add a new helper function for reading a string
which permits short reads so long as the data read from the file
contains a terminated string.

Reported by:	jrtc27
Reviewed by:	jrtc27
Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D44419

(cherry picked from commit 785600d0fb)
2024-04-08 11:06:41 -07:00
John Baldwin c0ee9e5e41 arm busdma: Fix parameter types to exclusion_bounce_check
These are bus addresses not CPU virtual addresses.

Reviewed by:	andrew
Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D44343

(cherry picked from commit 66658b0f27)
2024-04-08 11:05:34 -07:00
John Baldwin dcedc7b7f2 .github: Switch to v4 of actions/checkout
GitHub is emitting a warning that v3 is deprecated due to using
Node.js 16.

(cherry picked from commit e6dccf0050)
2024-04-08 11:03:08 -07:00
John Baldwin 661e3d4f15 nvmecontrol: Update the test for a valid firmare revision slot
Reported by:	Coverity Scan
CID:		1539214
Fixes:		7485926e09 nvme: Firmware revisions in the firmware slot info logpage are ASCII strings

(cherry picked from commit 1b38f851d8)
2024-04-08 11:01:32 -07:00
John Baldwin 4329e6ccfa nvme: Firmware revisions in the firmware slot info logpage are ASCII strings
In particular, don't try to byteswap the values as 64-bit integers and
always print a non-empty version as a string.

Reviewed by:	chuck, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44121

(cherry picked from commit 7485926e09)
2024-04-08 11:01:07 -07:00
Alfredo Mazzinghi b7419f5b5e arm64: Fix typo in pagetable_l0_ttbr0_bootstrap symbol name
Obtained from:	CheriBSD

(cherry picked from commit c6a6ec85a7)
2024-04-08 11:00:12 -07:00
Karim Fodil-Lemelin 3798c6487a ipfw: Skip to the start of the loop when following a keep-state rule
When a packet matches an existing dynamic rule for a keep-state rule,
the matching engine advances the "instruction pointer" to the action
portion of the rule skipping over the match conditions.  However, the
code was merely breaking out of the switch statement rather than doing
a continue, so the remainder of the loop body after the switch was
still executed.  If the first action opcode contains an F_NOT but not
an F_OR (such as an "untag" action), then match is toggled to 0, and
the code exits the inner loop via a break which aborts processing of
the actions.

To fix, just use a continue instead of a break.

PR:		276732
Reviewed by:	jhb, ae
MFC after:	2 weeks

(cherry picked from commit 62b1faa3b7)
2024-04-08 10:57:57 -07:00
John Baldwin 9922625114 vmd: Use bus_read/write_* instead of bus_space_read/write_*
Using an explicit bus space tag and handle is deprecated.

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

(cherry picked from commit 76c6786886)
2024-04-08 10:57:29 -07:00
John Baldwin af5f73700c riscv: Add missing includes for DDB
The #ifdef DDB code in parse_metadata was dead code without opt_ddb.h.
While here, update the call to db_fetch_ksymtab for changes in commit
02bc014a20.

Reviewed by:	mhorne
Obtained from:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D43919

(cherry picked from commit 962b0bcbd9)
2024-04-08 10:57:06 -07:00
John Baldwin 7204a656fc acpi: Don't assume a resource is reserved in acpi_delete_resource
This fixes a panic if a driver uses bus_set_resource to add a resource
that fails to reserve and then deletes the resource via
bus_delete_resource.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D43891

(cherry picked from commit e05436d577)
2024-04-08 10:56:03 -07:00
John Baldwin 55c2c62f10 acpi: Allow child drivers to use bus_set_resource for more resources
acpi_set_resource excludes certain types of resources for certain
devices.  The intention of this is to avoid adding resource entries
for bogus resources enumerated via _CRS.  However, this also prevents
drivers from adding those resources explicitly if needed.  To fix
this, move the logic to exclude these resources into an ignore hook
used when parsing _CRS to create the initial set of resources for each
device.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D43892

(cherry picked from commit 055c1fe230)
2024-04-08 10:54:40 -07:00
John Baldwin 9fc9358559 cam: Check if cam_simq_alloc fails for the xpt bus during module init
This is very unlikely to fail (and if it does, CAM isn't going to work
regardless), but fail with an error rather than a gauranteed panic via
NULL pointer dereference.

PR:		276770
Reported by:	Qiushi <w290680224@gmail.com>

(cherry picked from commit eb86c6c5b4)
2024-04-08 10:53:54 -07:00
John Baldwin 1910a6ca6e acpi: Use bus_generic_alloc_resource instead of duplicating it
No functional change, but it is cleaner to use the existing generic
wrappers rather than KOBJ methods directly.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D43686

(cherry picked from commit 1fb5445206)
2024-04-08 10:53:29 -07:00
John Baldwin b61c645163 pcib: Make various bus methods private to pci_pci.c
These functions are not used by pcib subclasses so do not need to
be exposed in pcib_private.h.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D43688

(cherry picked from commit 03719c6514)
2024-04-08 10:52:54 -07:00
John Baldwin db522f6bd0 arm: pmap_extract() returns a PA not a boolean value
Assume a PA of 0 indicates an invalid virtual address.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D43694

(cherry picked from commit afb1a3e30c)
2024-04-08 10:50:38 -07:00
John Baldwin d50a1d0ace cxgbe: Add counters for POSIX async I/O requests handled by the driver
Reviewed by:	np
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D43668

(cherry picked from commit c3d4aea6c5)
2024-04-08 10:39:21 -07:00
John Baldwin dff5ad1361 syscallsubr.h: Sort kern_membarrier prototype alphabetically
(cherry picked from commit 14505c92bc)
2024-04-08 10:38:50 -07:00
Alexander Ziaee 975afd9c44 newfs_msdos.8: example for specific cluster size
The usual use case in 2024 for newfs_msdosfs is creating filesystems on SD cards
for older hardware. In most tutorials, they call the cluster size "allocation
size". Therefore, add a small note next to cluster size that it is also called
allocation size, and add an example for how to do this.

Reviewed by:	jhb
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1045

(cherry picked from commit c8bf9f09ee)
2024-04-08 10:38:02 -07:00
Lexi Winter c680577ec9 netlink.h: s/typeof/__typeof
typeof() does not exist in -std=c99 mode and the relevant #define is
only for _KERNEL, so use __typeof here instead.

Reviewed by:	jhb
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1070

(cherry picked from commit 4261507a5e)
2024-04-08 10:37:49 -07:00
Ricardo Branco aed5216e95 find: Add -readable, -writable & -executable options
Reviewed by:	jhb, Mina Galić
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1080

(cherry picked from commit e4b646ce16)
2024-04-08 10:34:21 -07:00
Ricardo Branco 77afa8bc52 find: Allow '/' to be used with -perm for GNU compatibility
In 2005, Gnu find deprecated '+' as the leading character for the -perm
argument, instead preferring '/' with the same meaning. Implement that
behavior here, and document it in the man page.

Reviewed by: imp, emaste
Pull Request: https://github.com/freebsd/freebsd-src/pull/1060

(cherry picked from commit 2a121b97e9)
2024-04-08 10:33:29 -07:00
Minsoo Choo 2bc1e37e1d Stop using expressions in _Alignof()
_Alignof(expression) is a non-standard extension.  This is not allowed
in gnu11 and gnu17 which follow the C11 standard _Alignof(type).

Reviewed by:	arichardson, imp, jhb
Fixes:		4a9cd9fc22 amd64 db_trace: Reject unaligned frame pointers
Fixes:		7ccaf76a27 riscv db_trace: Ensure trapframe pointer is suitably aligned.
Fixes:		638c68897f arm64 db_trace: Ensure trapframe pointer is suitably aligned.
Differential Revision:	https://reviews.freebsd.org/D43409

(cherry picked from commit 03d04bf494)
2024-04-08 10:30:09 -07:00
John Baldwin 402c6c331d riscv db_trace: Ensure trapframe pointer is suitably aligned.
Suggested by:	jrtc27
Reviewed by:	jrtc27
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D41534

(cherry picked from commit 7ccaf76a27)
2024-04-08 10:29:34 -07:00
Ricardo Branco 470de7a717 cd9660: Add support for mask,dirmask,uid,gid options
Reviewed by:	jhb
Pull Request:	https://github.com/freebsd/freebsd-src/pull/982

(cherry picked from commit 82f2275b73)
2024-04-08 10:29:11 -07:00
Dag-Erling Smørgrav dc0087a3aa ln: Improve link(1) variant of ln(1).
* Give link(1) its own usage message.
* Use getprogname(3) instead of rolling our own.
* Verify that the target file does not already exist.
* Add tests specific to link(1).

MFC after:	3 days
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D44635

(cherry picked from commit bee7cf9e97)
2024-04-08 12:10:15 +02:00
Dag-Erling Smørgrav 39d543db53 cp: Improved conformance when copying directories.
* When copying a directory, if the destination exists and is not a
  directory, we would previously emit an error message and exit.  The
  correct behavior according to POSIX is to emit an error message and
  continue without descending further into the source directory.

* When copying a directory, if the destination does not exist and we
  fail to create it, we would previously emit an error message and
  exit.  The correct behavior according to POSIX is to emit an error
  message and continue.  Whether to descend further into the source
  directory is explicitly left unspecified; GNU cp does not, which
  seems to me to be the safer and less surprising option, so let's not
  either.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D44577

(cherry picked from commit dd286b0dc1)

cp: Correct the list of non-portable flags.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D44576

(cherry picked from commit aaa1806f68)
2024-04-08 12:10:14 +02:00
Dimitry Andric 17e32453b8 Merge commit eb8f379567e8 from llvm-project (by Florian Hahn):
[DSE] Remove malloc from EarliestEscapeInfo before removing. (#84157)

  Not removing the malloc from earliest escape info leaves stale entries
  in the cache.

  Fixes https://github.com/llvm/llvm-project/issues/84051.

  PR: https://github.com/llvm/llvm-project/pull/84157

This fixes a crash in clang (usually a bus error, but can also be
another memory error) when compiling the science/siconos port.

PR:		278174
Reported by:	yuri
MFC after:	3 days

(cherry picked from commit aaabed1dea)
2024-04-08 09:42:20 +02:00
Xin LI 728293e74c Backport export of lzma_mt_block_size symbol.
This restores binary compatibility against liblzma 5.6.0 library.

PR:		278127

(cherry picked from commit 5ffb19ac36)
2024-04-07 21:06:13 -07:00
Xin LI 6b55e41b3f Revert "MFV: xz 5.6.0"
This commit reverts 8db56defa7,
rolling back the vendor import of xz 5.6.0 and restoring the
package to version 5.4.5.

The revert was not directly due to the attack (CVE-2024-3094):
our import process have removed the test cases and build scripts
that would have enabled the attack. However, reverting would
help to reduce potential confusion and false positives from
security scanners that assess risk based solely on version
numbers.

Another commit will follow to restore binary compatibility with
the liblzma 5.6.0 library by making the previously private
symbol (lzma_mt_block_size) public.

PR:		278127

(cherry picked from commit 2f9cd13d6c)
2024-04-07 21:06:12 -07:00
Ed Maste 9031978083 rights.4: add note about rights not being simple bitmasks
PR:		277057
Reviewed by:	oshogbo, asomers
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D44473

(cherry picked from commit 537bdafbc2)
(cherry picked from commit 6ac10e8a72)
2024-04-07 12:58:50 -04:00
Ed Maste a2ce5a2dc9 tar: make error reporting more robust and use correct errno
Apply upstream pull request 2101.

(cherry picked from commit d68c68693e)
(cherry picked from commit bade279b81)
2024-04-07 12:58:50 -04:00
Olivier Cochard 1fd6ef0cb2 OptionalObsoleteFiles: add missed cuda wrappers include files
Files introduced since clang 17.0.2.

Approved by:	dim
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D44597

(cherry picked from commit a927571469)
2024-04-06 18:38:08 +02:00
Dag-Erling Smørgrav b9e32d8c8f Clean up botched merge.
Fixes:		6895133fe2
2024-04-04 14:07:00 +02:00
Dag-Erling Smørgrav 6895133fe2 lorder: Clean up and improve robustness.
* Properly parse (no) command-line options.

* Ensure that errors go to stderr and result in a non-zero exit.

* Drop the special-case code for a single argument, as it will produce
  the wrong outcome if the file does not exist or is corrupted.

* Don't print anything until after we've collected all the data.

* Always create all temporary files before setting the trap.  This
  ensures that the trap can safely fire at any moment, regardless of any
  previous definition of `T`.

* Use a temporary file rather than a pipe between `nm` and `sed` to
  ensure proper termination if `nm` fails due to a missing or invalid
  input.

* The check for self-referential entries was conditional on testing our
  argument list against a regex looking for archives.  This was a
  needless and unreliable optimization; make the check unconditional.

* Document that lorder will not work properly if any of its inputs have
  spaces in their name.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D44133

(cherry picked from commit 5c7b986c21)

lorder: Add unit tests.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D44134

(cherry picked from commit 96da41b6db)

lorder: Undeprecate.

While lorder is not required by our current toolchain (or any toolchain
we've used in the past decade or two), it still occasionally shows up
in build systems of third party software, including The Open Group's
UNIX conformance test suite, and the maintenance cost is negligible.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	imp, allanjude, emaste
Differential Revision:	https://reviews.freebsd.org/D44135

(cherry picked from commit cf4d9bf8b3)

lorder: Don't rely on legacy syntax.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D44155

(cherry picked from commit aedb37dc49)

lorder: Tweak invalid file test.

Different implementations of `nm` have different ways of telling you
that your file is not a valid object or library, but they all seem to
have “not recognized” as a common substring.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D44154

(cherry picked from commit aa80cfadff)

usr.bin: Make lorder conditional on MK_TOOLCHAIN.

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

(cherry picked from commit 125c4560bc)
2024-04-04 11:55:25 +02:00