Commit graph

25301 commits

Author SHA1 Message Date
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
Sergey A. Osokin
22c7815118 exec(3): add missing execvpe(3) to MLINKS
Reviewed by:	glebius
2025-06-18 17:40:22 -04:00
Cy Schubert
6d669a5d77 pam-krb5: Add manpage
To build the man page one must run pod2man on
contrib/pam-krb5/docs/pam_krb5.pod and copy it to ${.CURDIR}.
2025-06-17 12:59:37 -07:00
Cy Schubert
29b02abb90 pam_ksu: Move temp_realm into the correct context
Fixes:		98f18cd988
2025-06-16 16:45:28 -07:00
Jessica Clarke
66cc116bb2 libprocstat: Drop zfs_defs.c hack, including its _KERNEL define
Now that we have a _WANT_ZNODE we can use that instead of defining
_KERNEL, and we're able to move the code back into zfs.c using a real
znode_t pointer.

Whilst here, tidy the includes.

Reviewed by:	imp, kib, markj
Differential Revision:	https://reviews.freebsd.org/D50721
2025-06-16 22:34:34 +01:00
Jessica Clarke
20aaf0f657 libprocstat: Drop all _KERNEL defines outside of zfs_defs.c
Defining _KERNEL is a historical hack that can often break due to the
environment not actually being that of a kernel build. Now that we have
other targeted macros we can define instead that don't have far-reaching
implications like _KERNEL we can drop this.

Reviewed by:	imp, kib, markj
Differential Revision:	https://reviews.freebsd.org/D50719
2025-06-16 22:33:54 +01:00
Cy Schubert
98f18cd988 pam_ksu: Move the realm free to end of function
This avoids a use after free.

Noted by:	jhb
2025-06-16 11:42:30 -07:00
Cy Schubert
78d4557a9b telnet: Add Support for MIT KRB5 build
MIT KRB5 does not support telnet. This is because telnet uses 3DES
encryption, which requires 3DES encrypted keys in the KDC database.
As MIT had deprecated and removed 3DES support about a decade ago,
telnet is not supported.

Sponsored by:		The FreeBSD Foundation
Reviewed by:		markj
Differential revision:	https://reviews.freebsd.org/D50785
2025-06-15 19:49:36 -07:00
Cy Schubert
0acf1dd792 lib: Only build libcom_err with Heimdal
MIT KRB5 provides its own libcom_err.

Sponsored by:		The FreeBSD Foundation
Reviewed by:		markj, emaste
Differential revision:	https://reviews.freebsd.org/D50809
2025-06-15 19:49:36 -07:00
Cy Schubert
bafe0e7eda pam_ksu: Proactively address MIT KRB5 build failure
MIT KRB5 does not provide a krb5_make_principal() function. We need to
provide this ourselves for now. We provide the function for now while
MIT and Heimdal are both in the tree. When Heimdal is removed we can
inline the calls to krb5_get_default_realm() and
krb5_build_principal_va(). krb5_build_principal_va() is
deprecated in MIT KRB5. Its replacement, krb5_build_principal_alloc_va()
will be used instead at that time.

Sponsored by:		The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D50808
2025-06-15 19:49:35 -07:00
Cy Schubert
3d79be24cf pam_krb5: Stitch pam-krb5 plumbing into libpam
The eyeire.org pam-krb5 supports MIT KRB5 and Heimdal. FreeBSD will use
it to implement pam_krb5 for MIT KRB5. The existing libpam pam_krb5
only supports Heimdal and therefore cannot be used with the MIT KRB5
import.

Sponsored by:		The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D50696
2025-06-15 19:49:35 -07:00
Alexander Ziaee
54d2737e7f
bectl: Use SPDX only license
bectl.8 had a truncated license without the required disclaimer.
Correct it consistently by converting all bectl licenses to SPDX form.

Approved by:		kevans
Approved by:		Kyle Kneitinger <kyle@kneit.in>
Approved by:		Wes Maag <wes@jwmaag.org>
Approved by:		mhorne (mentor, implicit)
Differential Revision:	https://reviews.freebsd.org/D49066
2025-06-13 15:09:22 -04:00
Warner Losh
67c5db938c clock_gettime: Better markup
Markup CLOCK_REALTIME better.

Noticed by: kib
Fixes: 7b7ba7857c
Sponsored by:		Netflix
2025-06-13 12:29:38 -06:00
Warner Losh
bd8621c6cd kern_time: minor style nits
Typically we spell error values 'error' not 'err'. And fix EINVAL markup
nit.

Suggested by: kib
Fixes: 7b7ba7857c
Sponsored by:		Netflix
2025-06-13 08:34:21 -06:00
Alexander Ziaee
1b6936e125
manuals: Align our tree with upstream C23 macro
Switch all instances of the -isoC-2024 macro to -isoC-2023 selected by
upstream. Keep -isoC-2024 defined, but deprecated, for backwards compat.

MFC after:      3 days (I will resolve merge conflicts with cdefs)
2025-06-12 17:24:10 -04:00
SHENGYI HUNG
4acd63a626 libusb: Fix netlink sysevent multicast group name
Reviewed by:	hrs
Differential Revision: https://reviews.freebsd.org/D50739
2025-06-13 04:30:29 +09:00
Nathan Whitehorn
7b7ba7857c Implement CLOCK_TAI
Provide a clock through clock_gettime() that returns the current TAI
time (UTC without leap seconds) as a complement to CLOCK_REALTIME. This
provides compatibility with Linux, which also provides a CLOCK_TAI since
kernel 2.6.26, and this seems to be becoming the standard way to acquire
TAI time. Unlike Linux, this code will return EINVAL if the TAI offset
(set by ntpd, ptpd, etc.) is not known since it seems pathological for
CLOCK_TAI to silently give the wrong (UTC) time if the offset is not
known as it does on Linux.

Reviewed by: imp
Differential Revision:	https://reviews.freebsd.org/D46268
2025-06-12 12:25:31 -06:00
Hiroki Sato
b60053fde1 libcasper: Fix inconsistent error codes of cap_get{addr,name}info()
The get{addr,name}info(3) API is designed to return an API-specific error
code that is independent of errno.  The cap_get{addr,name}info() functions
returned either an errno or API-specific error code inconsistently.
This change fixes this mismatch.

When the API returns an errno, the return value itself is set to
EAI_SYSTEM and errno is set depending on the actual error.  So, usually
this API is called in the following form:

    error = getnameinfo(...);
    if (error == EAI_SYSTEM)
        perror("getnameinfo");
    else if (error)
        errx(1, "getnameinfo: %s", gai_strerror(error);

If the above getnameinfo() call is replaced with cap_getnameinfo(),
it breaks the error handling.  For example, the cap_get{addr,name}info()
functions can return ENOTCAPABLE.

This change simply adds "errno", in addition to "error", to the nvlout and
cap_get{addr,name}info() restores the errno if the error code is EAI_SYSTEM.

Reviewed by:	oshogbo
Differential Revision:	https://reviews.freebsd.org/D45859
2025-06-13 03:16:49 +09:00
Hiroki Sato
6501b68ffb
libcasper: Use __VA_ARGS__ for function-like macros
cap_net.h uses "#define cap_f(chan, a) f(a)" to call the conventional
service function with the first argument of cap_f() dropped for
compatibility with the environment where the casper service is
unavailable.  However, this function-like macro does not work when the
arguments contains C99 compound literals, such as f(chan, (int[]){1,2,3}).
The following is a typical example:

    error = cap_getaddrinfo(capnet, "192.168.0.1", "100",
        &(struct addrinfo){
            .ai_family = AF_INET,
            .ai_flags = AI_NUMERICHOST
    }, &res);

Using cap_f(chan, ...) and __VA_ARGS__ in C99 seems a reasonable solution
for this problem.  While there is a workaround using parenthesis around
the compound literal like f(chan, ((int[]){1,2,3})), it is not intuitive
and the above example works when the cap_net is available and f() is
defined as a function.

A possible moot point is that __VA_ARGS__ cannot control how many
arguments are passed at the macro level, and "chan" is not protected.
However, "chan" is less likely to be written in compound literal, and
the function prototype should check the remaining arguments.

Reviewed by:	oshogbo
Differential Revision:	https://reviews.freebsd.org/D45858
2025-06-13 03:04:21 +09:00
Aymeric Wibo
4c556a4e8d libusb: implement libusb_get_parent
Newer versions of drivers such as libwacom (graphics tablets) or
libfprint (fingerprint scanners) call g_usb_device_get_parent.  This in
turn calls libusb_get_parent on platforms which implement it, and
returns NULL on platforms that don't.  This patch implements this
function on FreeBSD.

Reviewed by:	bapt, kevans
Differential Revision:	https://reviews.freebsd.org/D46992
2025-06-12 11:56:31 -05:00
Brooks Davis
12913e4ddf fix build after _types.h changes
Reported by:	imp, Jenkins CI
Fixes:		b01e971fd3 ("Don't rely on sys/_types.h including sys/cdefs.h")
2025-06-12 14:22:17 +01:00
Brooks Davis
4f4c465b45 arm: fix build after _types.h changes
Reported by:	alc
Fixes:		b01e971fd3 ("Don't rely on sys/_types.h including sys/cdefs.h")
2025-06-12 01:38:00 +01:00
Ricardo Branco
b0334450aa include: ssp: fortify <signal.h>
sig2str(3)

Reviewed by: imp, kib, des, jilles
Pull Request: https://github.com/freebsd/freebsd-src/pull/1696
Closes: https://github.com/freebsd/freebsd-src/pull/1696
2025-06-11 17:16:22 -06:00
Ricardo Branco
d580567dfb Add tests for sig2str() / str2sig()
Reviewed by: imp, kib, des, jilles
Pull Request: https://github.com/freebsd/freebsd-src/pull/1696
2025-06-11 17:16:22 -06:00
Ricardo Branco
f942680e8e Fix proc_signame() to use sig2str()
Reviewed by: imp, kib, des, jilles
Pull Request: https://github.com/freebsd/freebsd-src/pull/1696
2025-06-11 17:16:22 -06:00
Ricardo Branco
3d12567133 Add the POSIX sig2str(3) & str2sig(3) calls
Signed-off-by: Ricardo Branco <rbranco@suse.de>
Reviewed by: imp, kib, des, jilles
Pull Request: https://github.com/freebsd/freebsd-src/pull/1696
2025-06-11 17:16:22 -06:00
Ricardo Branco
6ff5a5bc1a Remove definition of SIG2STR_MAX from libproc.h
Reviewed by: imp, kib, des, jilles
Pull Request: https://github.com/freebsd/freebsd-src/pull/1696
2025-06-11 17:16:21 -06:00
Ricardo Branco
86f06e612b Add POSIX NSIG_MAX & _SC_NSIG
Signed-off-by: Ricardo Branco <rbranco@suse.de>
Reviewed by: imp, kib
Pull Request: https://github.com/freebsd/freebsd-src/pull/1710
Closes: https://github.com/freebsd/freebsd-src/pull/1710
2025-06-11 17:16:20 -06:00
Brooks Davis
b01e971fd3 Don't rely on sys/_types.h including sys/cdefs.h
These headers relied in __BEGIN_DECS/__END_DECLS being defined when
sys/_types.h was included, but there's not a requirement that this be
the case.

Reviewed by:	imp
Exp-run by:	antoine (PR 286274)
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1595
2025-06-11 17:39:01 +01:00