Commit graph

25329 commits

Author SHA1 Message Date
ShengYi Hung
bca5df4565 libusb: replace LOG_LEVEL with DEBUG_LEVEL
The libusb set debug level by libusb_log_level instead of
libusb_debug_level. We switch to libusb_log_level for better
compatibility with the upstream libusb.

Additionally, The upstream libusb has an option allows user to override the log
function with a user-defined callback.
To support the callback function with a single string without va_arg, we
refactor the log facility as a function instead of a macro and parse all
va_args inside.

The legacy debug_level enum has been removed to enforce maintainer migrate from their
deprecated source code.

Reviewed by:    kevans
Approved by:    markj (mentor), lwhsu (mentor)
MFC after:      2 weeks
Sponsored by:   FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50680
2025-07-08 22:19:47 -04:00
Konstantin Belousov
8cc93cd668 fcntl.2: fix description of F_GETFD return value
Now we have three flags provided.

Sponsored by:	The FreeBSD Foundation
2025-07-09 00:48:58 +03:00
Kenny Levinsen
da9e73e5d4 wordexp(3): Handle ECHILD from waitpid
If the calling process has used SIG_IGN as handler or set the
SA_NOCLDWAIT flag for SIGCHLD, processes will be automatically reaped on
exit and calls to waitpid(3) will therefore fail with ECHILD.

We waitpid primarily to reap our child so that the caller does not have
to worry about it. ECHILD indicates that there is no child to reap, so
we can just treat that as a success and move on.

Signed-off-by: Kenny Levinsen <kl@kl.wtf>
Tested by: Jan Beich
Pull Request: https://github.com/freebsd/freebsd-src/pull/1675
2025-07-08 23:27:33 +02:00
Dag-Erling Smørgrav
c08e019c6c opendir, fdopendir: Add tests, clean up.
* Add test cases for opendir() and fdopendir().
* Drop O_NONBLOCK from opendir(); it was added a long time ago to avoid
  blocking if given a closed named pipe, but now we use O_DIRECTORY,
  which ensures that we get ENOTDIR in that case.
* While here, remove unused #includes left over from the split.

Sponsored by:	Klara, Inc.
Reviewed by:	kevans, markj
Differential Revision:	https://reviews.freebsd.org/D51126
2025-07-08 21:41:21 +02:00
Konstantin Belousov
72c848089f libc: only append exterr herald and text if exterr was recorded
__uexterr_format: return empty string on no error, instead of "No error"
err(): check for the first symbol of the exterr to decide if there is
anything to print.

Requested and reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D51204
2025-07-08 18:55:54 +03:00
Ricardo Branco
9911028f53 libc: mkostemp(3) should support O_CLOFORK
Reviewed by:	kib, markj
MFC after:	1 month
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1758
2025-07-08 15:43:39 +00:00
ShengYi Hung
f84a0da4e0 libusb: rename bNumDeviceCapabilities to bNumDeviceCaps for compatibility with libusb
THe member bNumDeviceCapabilities is referred to as bNumDeviceCaps in
the upstream libusb project.

To improve compatibility, we are renaming the member accordingly.

For backward compatibility, a mocro will be defined to map
bNumDeviceCapabilities to bNumDeviceCaps.

See: 02ebafc85d

Reviewed by:    kevans
Approved by:    markj (mentor)
MFC after:      2 weeks
Sponsored by:   FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50740
2025-07-08 11:11:41 -04:00
Siva Mahadevan
1e570722dc cap_dns/tests/dns_test: mark tests as needing network access
Signed-off-by: Siva Mahadevan <me@svmhdvn.name>

Reviewed by:	markj
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1738
2025-07-08 12:55:30 +00:00
Konstantin Belousov
01a679715f err(3): print extended error if available
Reviewed by:	asomers, brooks
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D51141
2025-07-07 21:44:22 +03:00
Konstantin Belousov
283c1bd8ce uexterr_format(): simplify output when ext error string is available
If the extended error string is provided by kernel, return only the
string, which is supposedly enough to identify exact cause of the error.
If the string is not provided, print the technically looking gibberish
which still allows to identify location with kernel sources.

Reviewed by:	asomers, brooks
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D51141
2025-07-07 21:44:14 +03:00
Bjoern A. Zeeb
07948e0508 net80211: regdomain: ETSI: add missing 11a and 11na entries
The frequency range 5745-5865 (channels 149-173) wrongly has a
VHT160 channel listed (going up to 5885/177 which is not avail in
ETSI) but no 11a, 11na listed.  Add the 11a and 11na in addition to
the 11ac 20/40 and 80.
Turns out the VHT40 entry for 5805-5845 was also missing. We already
had the neccessary setting for taiwan, so just adjust the freqband ref.

The problem is that without the 11a base channel ieee80211_find_channel()
in ieee80211_lookup_channel_rxstatus() will fail and sta_recv_mgmt() will
not get the correct channel but will use ic->ic_curchan (which is not
updated on scan offloading) and the scan result entry will be added as
channel 1.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	adrian (previous version)
Differential Revision: https://reviews.freebsd.org/D51163
2025-07-07 06:49:02 +00:00
Ricardo Branco
ea4042246d libsysdecode: Add O_CLOFORK flags to sysdecode
Reviewed by:	kib
MFC after:	1 month
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1698
2025-07-06 23:09:18 +00:00
Ricardo Branco
71a0af25a5 libopenbsd: Add recallocarray()
Reviewed by:	kib
MFC after:	1 month
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1698
2025-07-06 23:09:00 +00:00
Ricardo Branco
efadb5c2a9 Add manpages for O_CLOFORK flag and others
Reviewed by:	kib
MFC after:	1 month
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1698
2025-07-06 23:08:41 +00:00
Ricardo Branco
971f738679 kern: Make dup3() support O_CLOFORK
Reviewed by:	kib
MFC after:	1 month
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1698
2025-07-06 23:08:37 +00:00
Lexi Winter
d3c06bed2c clang: install clang-scan-deps
clang-scan-deps is used to generate dependency information from C++20
modules according to proposed standard ISO/IEC WG21 P1689R5[0].  It is
required by common build tools (e.g., CMake) to build C++ sources
that use modules.

Since this is a core build tool, install it by default, not gated
behind MK_CLANG_EXTRAS.

[0] https://www.open-std.org/JTC1/SC22/WG21/docs/papers/2022/p1689r5.html

MFC after:	3 days
Reviewed by:	kevans, dim
Approved by:	kevans (mentor)
Requested by:	jbo
Differential Revision:	https://reviews.freebsd.org/D51044
2025-07-06 22:02:52 +01:00
Rick Macklem
ac64cd191c pathconf.2: Document the _PC_HAS_HIDDENSYSTEM name
Commit afd5bc6309 added a new pathconf name
_PC_HAS_HIDDENSYSTEM.

This patch documents this new name.

This is a content change.

Reviewed by:	kib, ziaee (manpages)
Differential Revision:	https://reviews.freebsd.org/D51175
Fixes:	afd5bc6309 ("pathconf: Add a new variable for hidden/system")
2025-07-06 12:23:05 -07:00
Lexi Winter
032d32c2c2 bridge: add per-interface vlan access list
The new ifconfig options 'tagged', '+tagged' and '-tagged' allow the
vlan access list of a bridge interface to be configured:

- Incoming tagged frames will be dropped if the vlan tag isn't in the
  interface's access list.

- Outgoing frames will be dropped if the vlan tag isn't in the
  interface's access list (e.g., for BUM traffic).

This has no effect if vlan filtering is not enabled on the interface.

Since we now add a tag to untagged frames at ingress, remove the
vlan argument from bridge_vfilter_out() and use VLANTAGOF instead.

Reviewed by:	des, kp, adrian
Approved by:	des (mentor)
Differential Revision:	https://reviews.freebsd.org/D50503
2025-07-05 08:04:31 +01:00
Mark Johnston
79102e1080 libprocstat: Add handling for inotify descriptors
MFC after:	3 months
Sponsored by:	Klara, Inc.
2025-07-04 14:42:34 +00:00
Mark Johnston
5202cfcf93 inotify: Add man pages for the new syscalls and for VOP_INOTIFY
Reviewed by:	kib
MFC after:	3 months
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D50315
2025-07-04 14:42:33 +00:00
Mark Johnston
b79bd43f9a libsysdecode: Add support for decoding inotify syscall flags
MFC after:	3 months
Sponsored by:	Klara, Inc.
2025-07-04 14:42:33 +00:00
Mark Johnston
cf65b5e43d libsys: Add inotify support
Include the two new syscalls in the symbol map.

Reviewed by:	kib
MFC after:	3 months
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D50315
2025-07-04 14:42:33 +00:00
Mark Johnston
245ff4c4b2 libc: Add inotify support
inotify_init() and inotify_init1() are implemented using __specialfd(2).
inotify_add_watch() is implemented in terms of inotify_add_watch_at(2).

Reviewed by:	kib
MFC after:	3 months
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D50315
2025-07-04 14:42:33 +00:00
Mark Johnston
d4ead7edbb inotify: Regenerate syscall definitions
Sponsored by:	Klara, Inc.
2025-07-04 14:42:33 +00:00
Felix Johnson
bd173a540c
write.2: Add EINVAL to ERRORS
Since phk rewrote the block layer ~2 decades ago, write(2) can return
EINVAL when the target is a block device and nbytes, the write size, is
not a multiple of the sector's block size.

From the original PR:
When coming from Linux, people are surprised by the fact
that write(2) to a device must be aligned to block size.
Writing a non-aligned block onto a raw device is a case
where EINVAL is also returned but the manpage does not mention this.

MFC after:		3 days
PR:			227185
Reported by:		riggs
Reviewed by:		imp, Pau Amma <pauamma@gundo.com>
Differential Revision:	https://reviews.freebsd.org/D51138
2025-07-04 01:14:19 -04:00
Dag-Erling Smørgrav
5e96f4006d opendir: Simplify is_unionstack().
Sponsored by:	Klara, Inc.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D51118
2025-07-02 12:22:29 +02:00
Dag-Erling Smørgrav
8d02b7190d fts: Add test cases for unreadable directories.
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D51098
2025-07-02 12:22:29 +02:00
Dag-Erling Smørgrav
bc624c9735 fts: Clarify what FTS_DNR is used for.
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D51097
2025-07-02 12:22:29 +02:00
Kristof Provost
41fd03c08f pf: add 'max-pkt-size'
Allow pf to limit packets to a specified maximum size. This applies to all
packets, and if reassembly is enabled, looks at the reassembled size, not the
size of individual fragments.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-06-27 16:55:15 +02:00
Dag-Erling Smørgrav
8ebc076866 scandir: Code cleanup.
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D51050
2025-06-26 09:37:06 +02:00
Dag-Erling Smørgrav
62e0f12f51 scandir: Propagate errors from readdir().
Currently, if `readdir()` fails, `scandir()` simply returns a partial
result (or a null result if it fails before any entries were selected).
There is no way within the current API design to return both a partial
result and an error indicator, so err on the side of caution: if an
error occurs, discard any partial result and return the error instead.

MFC after:	1 week
Reported by:	Maxim Suhanov <dfirblog@gmail.com>
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D51046
2025-06-26 09:37:00 +02:00
Baptiste Daroussin
0f5c86ddb0 libyaml: import libyaml vendor version 0.2.5
The yaml parser used in nuageinit is too incomplete, import libyaml
in order to be able to use as a complete parser for nuageinit.
2025-06-26 09:02:31 +02:00
Kristof Provost
ff11f1c8c7 pf: add a generic packet rate matching filter
allows things like
pass in proto icmp max-pkt-rate 100/10
all packets matching the rule in the direction the state was created are
taken into consideration (typically: requests, but not replies).
Just like with the other max-*, the rule stops matching if the maximum is
reached, so in typical scenarios the default block rule would kick in then.
with input from Holger Mikolon
ok mikeb

Obtained from:	OpenBSD, henning <henning@openbsd.org>, 5a4ae9a9cb
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D50798
2025-06-25 19:56:23 +02:00
SHENGYI HUNG
4981b8968d libusb: consider bad fd as a broken event
Application can use libusb_get_pollfds to get pollfds from libusb then
close the fd themselves. This cause the hotplug thread unable to leave
because it will be consider as a invalid event then loop forever instead
of a broken event that should be quit immediately.

Reviewed by: bapt
Sponsored by: FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50959
2025-06-25 14:40:02 +02:00
Andrew Turner
fa1c23da01 libsys: Add AT_HWCAP3 and AT_HWCAP4
This is needed to read these values.

Reviewed by:	brooks, imp, kib
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D51006
2025-06-24 17:26:40 +01:00
Gleb Smirnoff
d17cbe4698 sendfile: retire SF_SYNC
The flag was added in b75a1171d8 for the sake of Varnish.  However, that
idea didn't work.  Quoting email from Poul-Henning:

"We had to give up sendfile(), the overhead of keeping track of everything
between the network stack and VM system made ate any gain we saw. ... I
dont think we ever shipped a version where sendfile was enabled by
default."

PR:	287348
2025-06-24 15:24:04 -07:00
Mark Johnston
f35525ff20 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.

PR:		262180
Reviewed by:	kib
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D50371
2025-06-24 21:04:18 +00:00
Mark Johnston
b5c04c8f96 csu/tests: Add tests to verify that errno == 0 upon program startup
Reviewed by:	kib, kevans
Differential Revision:	https://reviews.freebsd.org/D50998
2025-06-24 01:24:04 +00:00
Konstantin Belousov
6458400813 csu: C standard requires errno on main() entry
Reported by:	Greg Becker <greg.becker@klarasystems.com>
Reviewed by:	emaste, kevans, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Also see:	https://reviews.freebsd.org/D50998
Differential revision:	https://reviews.freebsd.org/D50997
2025-06-24 04:11:17 +03:00
Dag-Erling Smørgrav
0a5b763d98 libc: Rename fscandir{,_b}() to fdscandir{,_b}().
This seems to fit the pattern better (e.g. fdopendir()).

I've added weak references to ease the transition, but since it's only
been a few days, we can remove them (and the ObsoleteFiles entries for
the manual pages) before we branch stable/15.

Fixes:		deeebfdeca
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D50980
2025-06-23 15:03:10 +02:00
Bojan Novković
b2ac169802 glob: Delete trailing whitespace in 'struct glob_limit' definition
Sponsored by: Klara, Inc.
2025-06-23 11:58:41 +02:00
Bojan Novković
66d780ab1d glob.3: Fix punctuation mistakes
Fixes: 1e0743f54d
Sponsored by: Klara, Inc.
2025-06-23 11:34:45 +02:00
Dag-Erling Smørgrav
7fe39bec80 glob: Improve callback tests.
Most importantly, they need to run without privileges, since root is
allowed to read a directory regardless of its permission bits.

PR:		287694
Fixes:		4d7c31bca2
Sponsored by:	Klara, Inc.
Reviewed by:	bnovkov
Differential Revision:	https://reviews.freebsd.org/D50965
2025-06-23 10:44:31 +02:00
Konstantin Belousov
6b96e7a573 libthr/amd64: do not set THR_C_RUNTIME for thr_new() if the main thread did used AMD64_SET_TLSBASE
It is up to the code that organizes the runtime to properly set the
signal handler, and to set %fsbase if libthr signal handler is to be
called. The change should leave the CPU state on the signal handler
entry identical to what it was before introduction of TLSBASE, for code
that provides its own startup and thread pointer, but still calls into
libthr as a hack.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2025-06-22 09:14:07 +03:00
Ahmad Khalifa
2e91875bc2 libkvm/kvm_open.3: document broken full dumps
Starting 13.1 the amd64 kernel was made relocatable, but the kernel
didn't provide enough information for libkvm to figure out where it was
loaded.

Reviewed by: markj
Approved by: imp (mentor)
Pull Request: https://github.com/freebsd/freebsd-src/pull/1706
Closes: https://github.com/freebsd/freebsd-src/pull/1706
2025-06-22 06:49:32 +03:00
Ahmad Khalifa
308659acbf libkvm/kvm_amd64: account for relocatable kernels
amd64 kernels don't have to be loaded at 2M physical anymore, they can
be anywhere in the lower 4G of the physical address space. The kernel
now provides its physical address in an ELF section in the dump, so
account for it.

Reviewed by: markj
Approved by: imp (mentor)
Pull Request: https://github.com/freebsd/freebsd-src/pull/1706
2025-06-22 06:49:32 +03:00
Gleb Smirnoff
220cdd1b39 libc/rpc/svc_nl: plg a memory leak
CID:	1591126
2025-06-20 15:37:47 -07:00
Dag-Erling Smørgrav
c187b673bb scandir: Fix behavior when no entries match.
In the previous commit, I removed the initial initialization of the
`names` array, not realizing that `scandir()` is expected to return
a non-null (but empty) array of entries if no entries matched.
Restore the historical behavior, document it, and add a test.

Fixes:		deeebfdeca
Sponsored by:	Klara, Inc.
Reviewed by:	kevans, allanjude, markj
Differential Revision:	https://reviews.freebsd.org/D50949
2025-06-20 18:13:48 +02:00
Dag-Erling Smørgrav
deeebfdeca libc: Add fscandir(), fscandir_b(), scandirat_b().
While here, clean up scandir() a bit and improve the documentation.

MFC after:	never
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D50935
2025-06-20 13:10:23 +02:00
Kyle Evans
ee9895e10d kern: send parent a SIGCHLD when the debugger has detached
The practical scenario that leads to this is porch(1) spawning some
utility and sending it a SIGSTOP as a debugging aide.  The user then
attaches a debugger and walks through how some specific input is
processed, then detaches to allow the script to continue.  When ptrace
is detached, the process resumes execution but the parent is never
notified and may be stuck in wait(2) for it to continue or terminate.

Other platforms seem to re-suspend the process after the debugger is
detached, but neither behavior seems unreasonable.  Just notifying the
parent that the child has resumed is a relatively low-risk departure
from our current behavior and had apparently been considered in the
past, based on pre-existing comments.

Move p_flag and p_xsig handling into childproc_continued(), as just
sending the SIGCHLD here isn't really useful without P_CONTINUED set
and the other caller already sets these up as well.

Reviewed by:	kib, markj
Differential Revision:	https://reviews.freebsd.org/D50917
2025-06-19 10:32:04 -05:00