FreeBSD/src 4f0342cstand/lua core.lua

lualoader: fix pruning of non-existent default kernel

Removing the kernel from the list of available kernels is sufficient to
avoid rendering it in the list, but we need more for booting to actually
work.  Notably, the 'kernel' loader.conf var was left intact to its
default value, so if one didn't use the kernel selector in the menu then
we'd try to boot the nonexistent 'kernel' instead of the new default
(first autodetected).

There's room to improve the error messages here, but for now let's just
make it actually work correctly.

PR:             292232
Fixes:  d04415c520b03 ("loader: lua: remove the default kernel [...]")
(cherry picked from commit e30086ab4c8778ea70a3b19e83546ce1b4a16492)
DeltaFile
+6-0stand/lua/core.lua
+6-01 files

FreeBSD/src 919c1e1lib/libbe libbe.3 be.c, sbin/bectl bectl.c

bectl: log modifying functions to zpool history

Modeled directly after the method used by the zfs/zpool commands: flag
commands with a "please log me" flag, and when there, reconstruct the
command line. On success, call the library function to add it to the
log.

(Majority of the change by Rob; minor edits by kevans@)

Signed-off-by: Rob Norris <rob.norris at klarasystems.com>
Co-authored-by: Kyle Evans <kevans at FreeBSD.org>
Sponsored by:   Modirum MDPay
Sponsored by:   Klara, Inc.
(cherry picked from commit 2a87929671e6e6919c18f2c25d60f2c73c3d18f4)
DeltaFile
+57-16sbin/bectl/bectl.c
+14-2lib/libbe/libbe.3
+12-0lib/libbe/be.c
+2-0lib/libbe/be.h
+85-184 files

FreeBSD/src d3c523bshare/man/man9 make_dev.9

makedev(9): drop an additional note about cdevpriv dtors

These were previously somewhat safe to call destroy_dev(9), but will now
also cause a deadlock in the same fashion that d_close doing so would
previously.  Amend the note to point it out, in case it's useful for
someone.

Reviewed by:    imp, kib, markj

(cherry picked from commit 90314c04f10f583c37c59ec51fd628e3deaf3622)
DeltaFile
+8-4share/man/man9/make_dev.9
+8-41 files

FreeBSD/src b196a71lib/libc/gen sysconf.c sysconf.3, lib/libc/tests/sys cpuset_test.c

libc: report _SC_NPROCESSORS_ONLN more accurately in cpu-limited jails

We don't support CPU hotplug, but we do support cpuset(8) restrictions
on jails (including prison0, which uses cpuset 1).  The process cannot
widen its cpuset beyond its root set, so it makes sense to instead
report the number of cpus enabled there rather than the total number
in the system.

This change is effectively a nop for the majority of systems and jails
in the wild, though it does reduce the performance of this query now
that we can't take advantage of AT_NCPUS being provided in the auxinfo.

The implementation here is notably different than Linux, which would not
take cgroups into account.  They do, however, take CPU hotplug into
account, so the possibility for it to diverge from (and be lower than)
the # configured count to reflect what the process can actually be
scheduled on doesn't really diverge in semantics.

Reviewed by:    kib

    [2 lines not shown]
DeltaFile
+137-3lib/libc/tests/sys/cpuset_test.c
+15-1lib/libc/gen/sysconf.c
+4-2lib/libc/gen/sysconf.3
+156-63 files

FreeBSD/src 57b08d9lib/libutil login_class.c

libutil: defer setting the MAC label until after the login class

MAC policies, like mac_biba(4), may forbid changing the login class once
a label has been applied.  For setting up the initial login context,
this isn't really expected and in-fact may break some class-based
configuration.

Defer setting the MAC label until after the login class is set, and
remove the requirement that we have a pwd entry since the label is
pulled from the login class -- we only use pwd for syslog in this path.

Patch is largely by Kevin Barry, with some modifications and this commit
message by kevans@.

PR:             177698
Reviewed by:    des, olce
Co-authored-by: Kevin Barry <ta0kira gmail com>

(cherry picked from commit 98edcbcce0a4650084bd86e704cfa38bf590250c)
DeltaFile
+31-26lib/libutil/login_class.c
+31-261 files

FreeBSD/src f00ebc7lib/libc/posix1e mac_text.3 mac_free.3

libc: fix description issues in mac_text(3)/mac_free(3)

mac_text(3) as-written would seem to indicate that a `mac_t` should be
freed with free(3), but this isn't the case.  One can derive from
context from when the change was introduced and COMPATIBILITY that this
was intended to talk about *text in `mac_to_text`, so move the comment
there.

PR:             179832
Co-authored-by: Priit Järv <priit cc ttu ee>

(cherry picked from commit 081218b7a2006e5b6783e51f66fd751871ac1272)
DeltaFile
+5-3lib/libc/posix1e/mac_text.3
+2-2lib/libc/posix1e/mac_free.3
+7-52 files

FreeBSD/src 6dabfd3stand/lua core.lua

lualoader: fix pruning of non-existent default kernel

Removing the kernel from the list of available kernels is sufficient to
avoid rendering it in the list, but we need more for booting to actually
work.  Notably, the 'kernel' loader.conf var was left intact to its
default value, so if one didn't use the kernel selector in the menu then
we'd try to boot the nonexistent 'kernel' instead of the new default
(first autodetected).

There's room to improve the error messages here, but for now let's just
make it actually work correctly.

PR:             292232
Fixes:  d04415c520b03 ("loader: lua: remove the default kernel [...]")
(cherry picked from commit e30086ab4c8778ea70a3b19e83546ce1b4a16492)
DeltaFile
+6-0stand/lua/core.lua
+6-01 files

FreeBSD/src bc859balib/libbe libbe.3 be.c, sbin/bectl bectl.c

bectl: log modifying functions to zpool history

Modeled directly after the method used by the zfs/zpool commands: flag
commands with a "please log me" flag, and when there, reconstruct the
command line. On success, call the library function to add it to the
log.

(Majority of the change by Rob; minor edits by kevans@)

Signed-off-by: Rob Norris <rob.norris at klarasystems.com>
Co-authored-by: Kyle Evans <kevans at FreeBSD.org>
Sponsored by:   Modirum MDPay
Sponsored by:   Klara, Inc.
(cherry picked from commit 2a87929671e6e6919c18f2c25d60f2c73c3d18f4)
DeltaFile
+57-16sbin/bectl/bectl.c
+14-2lib/libbe/libbe.3
+12-0lib/libbe/be.c
+2-0lib/libbe/be.h
+85-184 files

FreeBSD/src 5b2a742share/man/man9 make_dev.9

makedev(9): drop an additional note about cdevpriv dtors

These were previously somewhat safe to call destroy_dev(9), but will now
also cause a deadlock in the same fashion that d_close doing so would
previously.  Amend the note to point it out, in case it's useful for
someone.

Reviewed by:    imp, kib, markj

(cherry picked from commit 90314c04f10f583c37c59ec51fd628e3deaf3622)
DeltaFile
+8-4share/man/man9/make_dev.9
+8-41 files

FreeBSD/src e760f45lib/libc/gen sysconf.c sysconf.3, lib/libc/tests/sys cpuset_test.c

libc: report _SC_NPROCESSORS_ONLN more accurately in cpu-limited jails

We don't support CPU hotplug, but we do support cpuset(8) restrictions
on jails (including prison0, which uses cpuset 1).  The process cannot
widen its cpuset beyond its root set, so it makes sense to instead
report the number of cpus enabled there rather than the total number
in the system.

This change is effectively a nop for the majority of systems and jails
in the wild, though it does reduce the performance of this query now
that we can't take advantage of AT_NCPUS being provided in the auxinfo.

The implementation here is notably different than Linux, which would not
take cgroups into account.  They do, however, take CPU hotplug into
account, so the possibility for it to diverge from (and be lower than)
the # configured count to reflect what the process can actually be
scheduled on doesn't really diverge in semantics.

Reviewed by:    kib

    [2 lines not shown]
DeltaFile
+137-3lib/libc/tests/sys/cpuset_test.c
+15-1lib/libc/gen/sysconf.c
+4-2lib/libc/gen/sysconf.3
+156-63 files

FreeBSD/src d15be6dlib/libutil login_class.c

libutil: defer setting the MAC label until after the login class

MAC policies, like mac_biba(4), may forbid changing the login class once
a label has been applied.  For setting up the initial login context,
this isn't really expected and in-fact may break some class-based
configuration.

Defer setting the MAC label until after the login class is set, and
remove the requirement that we have a pwd entry since the label is
pulled from the login class -- we only use pwd for syslog in this path.

Patch is largely by Kevin Barry, with some modifications and this commit
message by kevans@.

PR:             177698
Reviewed by:    des, olce
Co-authored-by: Kevin Barry <ta0kira gmail com>

(cherry picked from commit 98edcbcce0a4650084bd86e704cfa38bf590250c)
DeltaFile
+31-26lib/libutil/login_class.c
+31-261 files

FreeBSD/src b5b3bf5lib/libc/posix1e mac_text.3 mac_free.3

libc: fix description issues in mac_text(3)/mac_free(3)

mac_text(3) as-written would seem to indicate that a `mac_t` should be
freed with free(3), but this isn't the case.  One can derive from
context from when the change was introduced and COMPATIBILITY that this
was intended to talk about *text in `mac_to_text`, so move the comment
there.

PR:             179832
Co-authored-by: Priit Järv <priit cc ttu ee>

(cherry picked from commit 081218b7a2006e5b6783e51f66fd751871ac1272)
DeltaFile
+5-3lib/libc/posix1e/mac_text.3
+2-2lib/libc/posix1e/mac_free.3
+7-52 files

FreeBSD/src 3f3b53elib/libc/posix1e mac.conf.5 mac.conf, lib/libjail jail.c

jail(3): fix common usage after mac.label support

Nobody else's mac.conf(5) has any entries for jails, so they get a
trivial ENOENT and we fail before we can fetch any jail parameters.
Most notably, this breaks `jls -s` / `jls -n` if you do not have any
loaded policy that applies jail labels.

Add an entry that works for everyone, and hardcode that as an ENOENT
fallback in libjail to provide a smoother transition.  This is probably
not harmful to leave in long-term, since mac.conf(5) will override it.

This unearthed one additional issue, in that mac_get_prison() in the
MAC framework handled the no-label-policies bit wrong.  We don't want
to break jail utilities enumerating jail parameters automatically, so
we must ingest the label in all cases -- we can still use it as a small
optimization to avoid trying to copy out any label.  We will break
things if a non-optional element is specified in the copied in label,
but that's expected.


    [8 lines not shown]
DeltaFile
+9-6lib/libjail/jail.c
+2-6sys/security/mac/mac_syscalls.c
+2-1lib/libc/posix1e/mac.conf.5
+1-0lib/libc/posix1e/mac.conf
+14-134 files

FreeBSD/src bef0475share/man/man4 mac.4

mac(4): also list jails in the example enumeration of objects

The prison may also be considered part of the subject by way of its
ucred association, but I don't think this is significantly different
enough today than before recent work -- policies could have always
taken them into account, and some did (e.g., mac_bsdextended).

Reported by:    olce
Reviewed by:    olce, ziaee
Differential Revision:  https://reviews.freebsd.org/D54748
DeltaFile
+2-2share/man/man4/mac.4
+2-21 files

FreeBSD/src b016fa6usr.bin/sockstat sockstat.c

sockstat: improve printaddr() according to style(9)

Reviewed by:    des
MFC after:      3 days
Differential Revision:  https://reviews.freebsd.org/D54412

(cherry picked from commit f89f7e58ba1d54c6a683e3cc899938895496c088)
DeltaFile
+3-3usr.bin/sockstat/sockstat.c
+3-31 files

FreeBSD/src b46515eusr.bin/sockstat sockstat.c

sockstat: improve printaddr() according to style(9)

Reviewed by:    des
MFC after:      3 days
Differential Revision:  https://reviews.freebsd.org/D54412

(cherry picked from commit f89f7e58ba1d54c6a683e3cc899938895496c088)
DeltaFile
+3-3usr.bin/sockstat/sockstat.c
+3-31 files

FreeBSD/src f51bc79usr.bin/sockstat main.c

sockstat: improve formataddr() according to style(9)

Reviewed by:    des
MFC after:      3 days
Differential Revision:  https://reviews.freebsd.org/D54412

(cherry picked from commit f89f7e58ba1d54c6a683e3cc899938895496c088)
DeltaFile
+4-4usr.bin/sockstat/main.c
+4-41 files

FreeBSD/src 2e0e45asbin/pfctl parse.y, sbin/pfctl/tests/files pf1077.ok pf1076.in

pfctl(8): change default limiter action from no-match to block

pf(4) users who use limiters in current should update the rules
accordingly to reflect the change in default behavior. The existing
rule which reads as follows:

    pass in from any to any state limiter test

needs to be changed to:

    pass in from any to any state limiter test (no-match)

OK dlg@

Obtained from:  OpenBSD, sashan <sashan at openbsd.org>, c600931321
Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+11-11share/man/man5/pf.conf.5
+3-3tests/sys/netpfil/pf/limiters.sh
+2-0sys/netpfil/pf/pf.h
+1-1sbin/pfctl/tests/files/pf1077.ok
+1-1sbin/pfctl/parse.y
+1-1sbin/pfctl/tests/files/pf1076.in
+19-176 files

FreeBSD/src 68a449fsys/modules/sctp Makefile

sctp: improve compilation as module

When compiling SCTP as a module, don't compile sctp_crc32.c into
the module. This avoids code and variable duplication since
sctp_crc32.c is compiled into the kernel. In particular, the variable
system_base_info is not duplicated. This fixes the handling of the
statistic counters sctps_sendhwcrc and sctps_sendswcrc when using
sctp_delayed_cksum.

MFC after:      3 days
DeltaFile
+0-1sys/modules/sctp/Makefile
+0-11 files

FreeBSD/src c0898bdusr.bin/usbhidctl usbhidctl.1

usbhidctl.1: adjust option list indent

For improved legibility.
DeltaFile
+1-1usr.bin/usbhidctl/usbhidctl.1
+1-11 files

FreeBSD/src d80f249usr.bin/grep/tests grep_freebsd_test.sh

grep/tests: Fix up the zgrep executable path in a newly added test

Fixes:  da5d94d29a5e ("Remove obsolete BUGS section from zgrep(1) man page, add test")
(cherry picked from commit 045112f148fa092c92ec53204708f638b226ff8f)
DeltaFile
+1-1usr.bin/grep/tests/grep_freebsd_test.sh
+1-11 files

FreeBSD/src 6aca792usr.bin/grep zgrep.1, usr.bin/grep/tests grep_freebsd_test.sh

Remove obsolete BUGS section from zgrep(1) man page, add test

I forgot to check/update the man page with D54217. While here add
a test for multiple -e flags.

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

(cherry picked from commit da5d94d29a5ec29817476c39ae2b2ad1666c3f06)
DeltaFile
+0-18usr.bin/grep/zgrep.1
+11-0usr.bin/grep/tests/grep_freebsd_test.sh
+11-182 files

FreeBSD/src dccf005usr.bin/grep/tests grep_freebsd_test.sh

grep/tests: Fix up the zgrep executable path in a newly added test

Fixes:  da5d94d29a5e ("Remove obsolete BUGS section from zgrep(1) man page, add test")
(cherry picked from commit 045112f148fa092c92ec53204708f638b226ff8f)
DeltaFile
+1-1usr.bin/grep/tests/grep_freebsd_test.sh
+1-11 files

FreeBSD/src 5828825usr.bin/grep zgrep.1, usr.bin/grep/tests grep_freebsd_test.sh

Remove obsolete BUGS section from zgrep(1) man page, add test

I forgot to check/update the man page with D54217. While here add
a test for multiple -e flags.

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

(cherry picked from commit da5d94d29a5ec29817476c39ae2b2ad1666c3f06)
DeltaFile
+0-18usr.bin/grep/zgrep.1
+11-0usr.bin/grep/tests/grep_freebsd_test.sh
+11-182 files

FreeBSD/src 902e305lib/libthr/tests pthread_tryjoin_test.c Makefile

lib/libthr: add pthread_tryjoin(3) test

Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D54766
DeltaFile
+62-0lib/libthr/tests/pthread_tryjoin_test.c
+1-0lib/libthr/tests/Makefile
+63-02 files

FreeBSD/src 7f026a5share/man/man3 pthread_join.3 Makefile

Document pthread_tryjoin_np(3)

Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D54766
DeltaFile
+23-3share/man/man3/pthread_join.3
+2-1share/man/man3/Makefile
+25-42 files

FreeBSD/src afa70a8include pthread_np.h, lib/libthr pthread.map

libthr: add pthread_tryjoin_np()

Similar to the same glibc function.

Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D54766
DeltaFile
+41-14lib/libthr/thread/thr_join.c
+4-0lib/libthr/pthread.map
+1-0include/pthread_np.h
+46-143 files

FreeBSD/src ce16be7lib/libthr/thread thr_join.c

libthr/thread/thr_join.c: deduplicate backout_join() helper

Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D54766
DeltaFile
+13-8lib/libthr/thread/thr_join.c
+13-81 files

FreeBSD/src 002c50esys/amd64/vmm vmm.c

amd64/vmm: remove unused static function vcpu_state2str()

It is guarded by #ifdef KTR, so the warning does not show up under usual
kernel configs.

Fixes:  ed85203fb7a0334041db6da07e45ddda4caef13d
Sponsored by:   The FreeBSD Foundation
Differential revision:  https://reviews.freebsd.org/D54781
DeltaFile
+0-20sys/amd64/vmm/vmm.c
+0-201 files

FreeBSD/src 4b534b8sys/dev/acpica acpi.c

acpi: Fix not calling AcpiLeaveSleepState() in S3 path

When resuming from ACPI suspend, the ACPI_SS_SLP_PREP bit in slp_state
was being checked and subsequently unset when calling resumeclock().
This bit was also being checked for the AcpiLeaveSleepState() call in
the non-s2idle path, but having just been unset, it was never actually
being called.

Change this so that resumeclock() is always being called (since we never
goto breakout between suspendclock() and resumeclock() anyway) and
ACPI_SS_SLP_PREP is purely used for AcpiEnterSleepStatePrep() and
AcpiLeaveSleepState() in the non-s2idle paths.

PR:             292568
Reported by:    Marek Zarychta
Reviewed by:    olce
Tested by:      Marek Zarychta
Approved by:    olce
Fixes:  7669cbd0f064 (“acpi: Suspend-to-idle support (s2idle)”)

    [2 lines not shown]
DeltaFile
+3-6sys/dev/acpica/acpi.c
+3-61 files