FreeBSD/src 2b4bc0f — sys/conf kern.post.mk

kern.post.mk: Further refine ports module build

A handful of kmod ports have NO_PACKAGE set, which disables the package
target, which means the previous commit made things worse for those
ports rather than better.  Work around this by explicitly building the
stage target first.

Fixes:          b393df657811 ("kern.post.mk: Fix unprivileged ports module build")
DeltaFile
+1-1sys/conf/kern.post.mk
+1-11 files

FreeBSD/src c41ba5c — share/misc usb_vendors, sys/dev/rtwn/rtl8192f r92f_chan.c r92f_rom.c

rtwn: (RTL8192FU) fix init, with_ucode build and tx power handling

- added noop for RTWN_WITHOUT_UCODE builds on sc_set_media_status
- fixed upper bound of power delta for MCS for HT20/HT40 in tx power
- moved reading per channel bb trim values after efuse and bb initialization
- use 256 bytes per TX pages as per vendor and linux rtl8xxxu
- added tab character instead of spaces in share/misc/usb_vendors after the device name

Tested on RTL8192FU

Sponsored by: Alchemilla Ventures Private Limited

Reviewed by:    adrian
Differential Revision:  https://reviews.freebsd.org/D62241
Reported by: llm-postcr
Fixes:  1f0e186e1832 ("rtwn: added support for Realtek RTL8192FU...")
DeltaFile
+34-0sys/dev/rtwn/rtl8192f/r92f_init.c
+0-17sys/dev/rtwn/rtl8192f/r92f_rom.c
+4-2sys/dev/rtwn/rtl8192f/usb/r92fu_attach.c
+1-1sys/dev/rtwn/rtl8192f/r92f_chan.c
+1-1share/misc/usb_vendors
+1-0sys/dev/rtwn/rtl8192f/usb/r92fu.h
+41-216 files

FreeBSD/src 69a5247 — sys/dev/rge if_rge.c, sys/modules/rge Makefile

rge(4): Fix build without INET

rge_tx_pad() calls in_delayed_cksum_o() and in_cksum_skip()
unconditionally. in_delayed_cksum_o() lives in netinet/ip_output.c
(optional inet) and in_cksum_skip() lives in netinet/in_cksum.c
(optional inet | inet6). So kernels with "device rge" and no
INET fail to link. This breaks LINT-NOINET and LINT-NOIP.

Include opt_inet.h, add it to the module's SRCS, and wrap the IPv4
software checksum block in #ifdef INET.

Fixes: e3ded948ad41 ("rge(4): Implement RTL8125 UDP hardware workaround")
Reported by: llm-postcr

Differential Revision:  https://reviews.freebsd.org/D62240
DeltaFile
+4-0sys/dev/rge/if_rge.c
+1-1sys/modules/rge/Makefile
+5-12 files

FreeBSD/src 5321904 — lib/libsys libsys_private.h

libsys: Reformat lines moved from libc_private.h in previous commit

MFC after:      1 week
DeltaFile
+3-3lib/libsys/libsys_private.h
+3-31 files

FreeBSD/src 832f45f — lib/libc/include libc_private.h, lib/libsys Makefile auxv.c

libsys: Split out a new libsys_private.h from libc's libc_private.h

Downstream we have accidentally ended up referencing libc symbols from
within libsys, which went unnoticed because in practice libc is always
loaded whenever libsys is. Split out a new header to detect such cases
at build time, without relying solely on the test recently added in
493c84741c45 ("libsys: add test checking that -lsys alone is linkable").

Note we still add libc to the compiler's include path for compat.h and
(un-)namespace.h, but none of these provide declarations. Ideally that
would also be refactored, but that is a more invasive change.

Copyright header copied from those added by kib@ in 8495e8b1e9e1 ("Fix
known issues which blow up the process after dlopen("libthr.so") (or
loading a dso linked to libthr.so into process which was not linked
against threading library)."), the commit that introduced what is almost
all the code in this header; none of this code originates from jb@, to
whom libc_private.h is attributed.


    [3 lines not shown]
DeltaFile
+107-0lib/libsys/libsys_private.h
+1-63lib/libc/include/libc_private.h
+1-2lib/libsys/Makefile
+2-1lib/msun/Makefile
+2-1lib/libsys/auxv.c
+1-1lib/libsys/x86/sched_getcpu_x86.c
+114-6830 files not shown
+144-9336 files

FreeBSD/src c2044a3 — lib/libfetch ftp.c

libfetch: Fix buffer overruns in FTP code

* When parsing the reply to a CWD, PWD, or CDUP command, if we ran out
  of space in the destination buffer, we would correctly terminate the
  loop, but then incorrectly see the remaining length as non-zero,
  causing us to write a terminating NUL one past the end of the buffer
  and report success instead of a protocol error.  Additionally, the
  code would fail to notice an improperly terminated pathname, and was
  hard to follow, so rewrite the entire loop.

* When comparing the current working directory to the intended working
  directory to calculate the minimal operation to get from one to the
  other, if the current working directory was an empty string, we would
  improperly read one byte below the start of the intended working
  directory.

MFC after:      1 week
Reported by:    Laam Alif at Ibteda Digital Library
Differential Revision:  https://reviews.freebsd.org/D61502

    [2 lines not shown]
DeltaFile
+32-27lib/libfetch/ftp.c
+32-271 files

FreeBSD/src bedca0f — lib/libfetch ftp.c

libfetch: Fix buffer overruns in FTP code

* When parsing the reply to a CWD, PWD, or CDUP command, if we ran out
  of space in the destination buffer, we would correctly terminate the
  loop, but then incorrectly see the remaining length as non-zero,
  causing us to write a terminating NUL one past the end of the buffer
  and report success instead of a protocol error.  Additionally, the
  code would fail to notice an improperly terminated pathname, and was
  hard to follow, so rewrite the entire loop.

* When comparing the current working directory to the intended working
  directory to calculate the minimal operation to get from one to the
  other, if the current working directory was an empty string, we would
  improperly read one byte below the start of the intended working
  directory.

MFC after:      1 week
Reported by:    Laam Alif at Ibteda Digital Library
Differential Revision:  https://reviews.freebsd.org/D61502

    [2 lines not shown]
DeltaFile
+32-27lib/libfetch/ftp.c
+32-271 files

FreeBSD/src b393df6 — sys/conf kern.post.mk

kern.post.mk: Fix unprivileged ports module build

When building ports modules along with the kernel, we run the build
target during buildkernel, and the install target during installkernel.
This was fine back in the day when we installed ports straight from the
working directory, but these days we stage them first, then build a
package, and install the package.  This staging and packaging should be
seen as part of the build process, not the installation process, so we
should use the package target, rather than the build target, during
buildkernel.

This fixes an issue where doing buildkernel as an unprivileged user,
then installkernel as root, left a root-owned staging directory in the
kernel object tree which the next unprivileged buildkernel would be
unable to remove or replace.

MFC after:      1 week
Reviewed by:    imp
Differential Revision:  https://reviews.freebsd.org/D62195
DeltaFile
+2-2sys/conf/kern.post.mk
+2-21 files

FreeBSD/src e79b273 — sys/compat/linuxkpi/common/src linux_compat.c

linuxkpi: Make list_sort stable

Linux's list_sort() is intended to be stable, but linuxkpi implemented
it as a wrapper around qsort(), which is not.  This used to work because
our qsort() had a bug that effectively turned it into insertion sort,
but this is no longer the case.  Replace the qsort() call with an inline
implementation of insertion sort.

MFC after:      1 week
Reviewed by:    bz, markj
Differential Revision:  https://reviews.freebsd.org/D62194
DeltaFile
+27-26sys/compat/linuxkpi/common/src/linux_compat.c
+27-261 files

FreeBSD/src bd5b94f — usr.bin/truss/tests truss_test.sh

tests/truss_test: test for linux_newfstat on aarch64

This fixes a test failure in CI[0] since aarch64 does
not support linux_newstat yet.

[0] https://ci.freebsd.org/job/FreeBSD-main-aarch64-test/2190/testReport/usr.bin.truss/truss_test/accepted_abis/

Reviewed by:    dteske
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D62237
DeltaFile
+1-1usr.bin/truss/tests/truss_test.sh
+1-11 files

FreeBSD/src 8e243a9 — lib/libc/tests/sys sendfile_test.c

libc/sendfile_test: fix another copy-paste bug

Reviewed by:    ngie
Fixes:          b29e14264845 ("Add [initial] functional tests for sendfile(2)...")
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D62246
DeltaFile
+1-1lib/libc/tests/sys/sendfile_test.c
+1-11 files

FreeBSD/src 99b47b1 — lib/libc/gen feature_present.c

Fix typo in comment describing `feature_present(3)`

feature_present(3) checks `kern.features`, not `kern.feature`, for
feature existence.

Extremely naive readers, like GitHub's Copilot (Lite effort) take
comments at face value without actually looking at the code to make sure
the comment is correct. This can lead to very incorrect conclusions [1].

1. https://github.com/freebsd/atf/pull/242#discussion_r4746930972

MFC after:      1 week
DeltaFile
+1-1lib/libc/gen/feature_present.c
+1-11 files

FreeBSD/src e361fd8 — lib/libc/tests/locale c16rtomb_test.c mbrtoc16_test.c, lib/libiconv_modules/GBK2K citrus_gbk2k.c

libiconv/gbk2k: Handle GB18030SUPP correctly.

According to https://en.wikipedia.org/wiki/GB_18030#Mapping, the code
above 0x90308130 is mapped linearly to unicode 0x10000 to 0x10FFFF. It
is not handled in our iconv implemenation. We implement such mapping in
here and add some tests.

Reviewed by:    kevans
MFC after:      2 weeks
Differential Revision: https://reviews.freebsd.org/D61153
DeltaFile
+74-0lib/libc/tests/locale/mbrtoc32_test.c
+37-0lib/libc/tests/locale/mbrtoc16_test.c
+27-0lib/libiconv_modules/GBK2K/citrus_gbk2k.c
+24-0lib/libc/tests/locale/c16rtomb_test.c
+2-0share/i18n/csmapper/GB/mapper.dir.GB.src
+2-0share/i18n/csmapper/GB/charset.pivot.GB.src
+166-02 files not shown
+168-08 files

FreeBSD/src bea1eaf — lib/libiconv_modules/UTF8 citrus_utf8.c

libiconv: Respect RFC 3629

RFC 3629 limits UTF-8 to U+10FFFF, which our iconv doesn't follow but
has been correctly handled in libc. As iconv is the default locale
implementation now. We should respect the standard in here.

Reviewed by:   kevans
MFC after:         2 weeks
Differential Revision: https://reviews.freebsd.org/D61152
DeltaFile
+3-2lib/libiconv_modules/UTF8/citrus_utf8.c
+3-21 files

FreeBSD/src 384d73b — sys/dev/acpica acpi_thermal.c

acpi/tz: Resync cooler device after resume

A acpi_fan under tz domain can inconisist after resume. The device now
switch between D3 and D0 in suspend and resume. However, if a tz turn
off the cooler before resume, the device will still run after resume as
there is no mechanism in tz to resync activity and the cooler can
by default enter D0.

Reported by:    llm-postcr
DeltaFile
+14-0sys/dev/acpica/acpi_thermal.c
+14-01 files

FreeBSD/src 162dcf9 — sys/kern kern_membarrier.c

membarrier(2): do not call smp_rendezvous_cpus() with an empty mask

If the caller migrates while the mask is computed and no other thread
of the process is running, the mask is empty, and smp_rendezvous_cpus()
panics.

PR:     301240
Fixes:  4a69fc16a583 ("Add membarrier(2)")
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
DeltaFile
+4-2sys/kern/kern_membarrier.c
+4-21 files

FreeBSD/src 8a25b8b — sys/kern kern_membarrier.c

membarrier(2): issue the leading fence before reading other CPUs' state

There are two problems:
- The old fence ran after the mask was computed, so a store the caller
  made before the syscall could still be in its store buffer when it read
  another CPU's state. A thread switched in right after that read then got
  neither the IPI nor the store.
- MEMBARRIER_CMD_GLOBAL had no fence before its first pass, which marks
  idle CPUs done immediately.

Fixes:  4a69fc16a583 ("Add membarrier(2)")
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
DeltaFile
+11-1sys/kern/kern_membarrier.c
+11-11 files

FreeBSD/src 5efc448 — share/man/man4 acpi_fan.4, sys/dev/acpica acpi_fan.c

acpi/fan: Always call _FSL

Fan device can adjust the fan level itself and propogate to the APCI
Table. This however is opaque to the driver as there is no interrupt
to notify us that the fan level is chaged.

This can cause problem if we want to set the same value as the cached
one, which is all in all short-circuited.

As a result, we call _FSL unconditionally. Also, the condition is also
racy if two writes reach kernel. The value doesn't reflect the last
one. Therefore, we enlarge the critical section and use sx to protect
frequently read case.

Reported by:    llm-postcr
Fixes: 116216477e8a ("acpi: Add acpi_fan")
DeltaFile
+24-31sys/dev/acpica/acpi_fan.c
+3-0share/man/man4/acpi_fan.4
+27-312 files

FreeBSD/src bf96b5b — sys/dev/snp snp.c

snp(4): for snp_read(), check tty_gone() under tty lock before cv_wait()

Otherwise snp_read() might lose the wakeup from a gone tty.

Keep the unlocked tty_gone() check on entry, so that a non-blocking
read on a gone tty with an empty snoop queue returns EIO instead of
EWOULDBLOCK.

A sleeping reader whose wakeup races with the tty going away now returns
the output captured before that, instead of EIO.

Reported by:    llm-postcr
Fixes:  d8569724dc0d ("snp(4): wake up the readers and pollers when the tty is gone")
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
DeltaFile
+2-6sys/dev/snp/snp.c
+2-61 files

FreeBSD/src 5495a0a — sys/ofed/drivers/infiniband/ulp/nfsclrdma xprt_verbs.c

xprt_verbs.c: Add reconnect support for 2 additional cm events

This patch adds RDMA_CM_EVENT_DEVICE_REMOVAL and
RDMA_CM_EVENT_ADDR_CHANGE to RDMA_CM_EVENT_DISCONNECTED
to force a new QP.

Reported by:    llm-postcr
MFC after:      1 month
Fixes:  80bee4d83637 ("nfsclrdma: Add code to support client side NFS over RDMA")
DeltaFile
+2-0sys/ofed/drivers/infiniband/ulp/nfsclrdma/xprt_verbs.c
+2-01 files

FreeBSD/src a7dcbd2 — sys/nlm nlm_prot_impl.c

nlm_prot_impl.c: Fix commit 4bc351e3635b for NFSv2

Commit 4bc351e3635b broke NFSv2 support, since NFSv2 uses a
32 byte file handle and sizeof(fhandle_t) == 28.

This patch fixes this.

Reported by:    llm-postcr
MFC after:      2 weeks
Fixes:  4bc351e3635b ("nlm_prot_impl.c: Fix a crash caused by a bogus file handle")
DeltaFile
+1-1sys/nlm/nlm_prot_impl.c
+1-11 files

FreeBSD/src 60fa25d — tests/sys/kern procdesc.c

tests/sys/kern/procdesc: test pddupfd(PD_DUPFD_EXECUTABLE)

Check that the returned file descriptor references the process binary,
both for the calling process and for a child whose binary was unlinked
after exec, and that it is close-on-exec, readable and lacks the write
capability right.

Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D61314
DeltaFile
+112-0tests/sys/kern/procdesc.c
+112-01 files

FreeBSD/src e590e2f — sys/kern vfs_syscalls.c, sys/sys file.h

sys: un-staticise finit_open()

Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D61314
DeltaFile
+1-1sys/kern/vfs_syscalls.c
+2-0sys/sys/file.h
+3-12 files

FreeBSD/src 46019d4 — tests/sys/kern procdesc.c

tests/sys/kern/procdesc: test pddupfd(PD_DUPFD_ME)

Check that the descriptor of the calling process is duplicated with
O_CLOEXEC set and the file shared, and that a closed descriptor
gives EBADF.

Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D61314
DeltaFile
+31-0tests/sys/kern/procdesc.c
+31-01 files

FreeBSD/src d1e3d97 — tests/sys/kern ptrace_test.c

ptrace_test: use PD_NOWAITPID in procdesc_reparent_wait_child

The test expects that, after a debugger collected the exit status of
a child created by pdfork(2), the parent cannot collect the child with
wait(2).  With the zombie references, a child created without
PD_NOWAITPID is waitable by its parent, and the test only passed
because the debugger's waitpid(2) dropped the parent's reference.
proc_reap() no longer lets the debugger take the exit status away
from the parent, so the parent's wait(2) now collects the child.

Create the child with PD_NOWAITPID, which is what hides it from
wait(2) now.  Since waitpid(2) does not see it either, wait for its
stop with pdwait(2).  The debugger's waitpid(2) in the test then also
covers collecting a tracee that has no waitpid reference.

Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D62051
DeltaFile
+10-7tests/sys/kern/ptrace_test.c
+10-71 files

FreeBSD/src ec8ee3f — usr.bin Makefile, usr.bin/procfdcat Makefile procfdcat.1

procfdcat(1): utility to read content of a file opened by process

It reads the content of a regular file opened by another process, or of
its executable, using pddupfd(2) and pread(2).

Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D61314
DeltaFile
+154-0usr.bin/procfdcat/procfdcat.c
+105-0usr.bin/procfdcat/procfdcat.1
+6-0usr.bin/procfdcat/Makefile
+1-0usr.bin/Makefile
+266-04 files

FreeBSD/src e87aab1 — sys/fs/tmpfs tmpfs_vnops.c

tmpfs: VOP_OPEN() should be allowed on unlinked files

There is no reason for such restriction, and other file systems do not
impose it.

Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D61314
DeltaFile
+0-8sys/fs/tmpfs/tmpfs_vnops.c
+0-81 files

FreeBSD/src 1ba902d — lib/libsys pdfork.2

pdfork.2: document PD_DUPFD_ME and PD_DUPFD_EXECUTABLE

Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D61314
DeltaFile
+16-2lib/libsys/pdfork.2
+16-21 files

FreeBSD/src efc319c — sys/kern sys_procdesc.c, sys/sys procdesc.h

pddupfd(2): allow to open the executable

One of the common uses for sysctl kern.proc.<pid>.pathname is to
immediately open(2) the returned path to parse the image, e.g. to read
the symbols.  This operation was made more reliable since introduction
of p_textdvp, but still rename or unlink of the binary cause unnecessary
failures for that.

Introduce pddupfd(pfd, PD_DUPFD_EXECUTABLE) special case that returns
read-only file descriptor to the process executable image.

Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D61314
DeltaFile
+44-18sys/kern/sys_procdesc.c
+1-0sys/sys/procdesc.h
+45-182 files

FreeBSD/src c6d75f9 — sys/kern sys_procdesc.c, sys/sys procdesc.h

pddupfd(2): add a designator for the current process

Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D61314
DeltaFile
+20-12sys/kern/sys_procdesc.c
+2-0sys/sys/procdesc.h
+22-122 files