FreeBSD/src bd15d6econtrib/libarchive/libarchive archive_string.c

libarchive: Force GNU iconv compatibility on FreeBSD

When libarchive is compiled with FreeBSD's native iconv instead of
libiconv, as happens with libarchive in the base system, we need to
configure iconv(3) to handle invalid sequences by returning -1, as
iconv_strncat_in_locale() assumes GNU iconv semantics.

This corresponds to upstream PR 3056.

PR:             294577
MFC after:      1 week
DeltaFile
+11-1contrib/libarchive/libarchive/archive_string.c
+11-11 files

FreeBSD/src e9346d1lib/libutil login.conf.5

login.conf(5): Add missing resource limits

While here, reorder the table.

PR:             295618
MFC after:      1 week
Reviewed by:    olce
Differential Revision:  https://reviews.freebsd.org/D57258
DeltaFile
+6-5lib/libutil/login.conf.5
+6-51 files

FreeBSD/src 210bee0libexec/tftpd tftp-io.c

tftpd: Simplify packet drop macro

The first argument is always the function name, for which we can simply
use __func__.  This leaves only the optional return value, so we can use
a single variadic macro instead of two nearly-identical copies.

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

(cherry picked from commit 76c3387024b40c2e28ed2d1bb64b3a14371c3c0b)
DeltaFile
+23-28libexec/tftpd/tftp-io.c
+23-281 files

FreeBSD/src 2d9d040libexec/tftpd tftp-io.c

tftpd: Add missing bounds checks

In send_[rw]rq(), we were using strlcpy() to avoid overflowing our
packet buffer, then failing to check the result and blithely advancing
our pointer by the full length.

Luckily, this code is only ever used by tftp(1), not tftpd(8).

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

(cherry picked from commit 933893771344e1647eeda152016b938fdc30ccdc)
DeltaFile
+32-26libexec/tftpd/tftp-io.c
+32-261 files

FreeBSD/src 6764267usr.bin/tftp/tests tftp_test.sh

tftp: Add test case with over-long URL

This adds a test case that passes a very long URL on the command line,
which would previously have resulted in a benign buffer overflow in
urihandling(), detectable only by compiling tftp with ASAN enabled.

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

(cherry picked from commit b94689d036c5f5bdc04d080ff7dd5d0e9df9b8d4)
DeltaFile
+24-0usr.bin/tftp/tests/tftp_test.sh
+24-01 files

FreeBSD/src 12e8c16usr.bin/tftp tftp.c main.c

tftp: Fix handling of port name or number

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

(cherry picked from commit 47e4571df15804fe2b010a3c82b22691d80ee680)
DeltaFile
+22-18usr.bin/tftp/tftp.c
+4-3usr.bin/tftp/main.c
+26-212 files

FreeBSD/src ddd16aeusr.bin/tftp main.c

tftp: Close files when we're done with them

Also, delete the file we created if receiving it failed.

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

(cherry picked from commit 29351335704e39ce3ca09c528d534c7898bbdc2c)
DeltaFile
+8-2usr.bin/tftp/main.c
+8-21 files

FreeBSD/src e1703e1usr.bin/tftp main.c tftp.c

tftp: Style cleanup

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

(cherry picked from commit 29aaaa5e6660310311fe443d8792b31181e1dd3c)
DeltaFile
+20-36usr.bin/tftp/main.c
+20-20usr.bin/tftp/tftp.c
+40-562 files

FreeBSD/src 13f6bf4usr.bin/tftp main.c

tftp: Replace fgets with getline

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

(cherry picked from commit 5fd928cf1cef21e0fc20ab7c2be156a0eeecdf40)
DeltaFile
+45-45usr.bin/tftp/main.c
+45-451 files

FreeBSD/src 2d0b4eeusr.bin/tftp main.c

tftp: Simplify URI handling

* No need to copy our argument into a new buffer; it is writeable and
  will not be reused after we return.

* Instead of constructing the string "get path" and then splitting it
  into an argument vector, just construct the vector directly.  This
  avoid potentially overrunning the buffer.

* Call settftpmode() just once, with either the default mode or the
  user-provided value we already validated.

* Use errx() instead of fprintf(stderr) + exit().

Reported by:    Moyao, Minghao Fu
MFC after:      1 week
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D57070

(cherry picked from commit a4b17594181502cea38ab0d8b2a9a10782286334)
DeltaFile
+12-20usr.bin/tftp/main.c
+12-201 files

FreeBSD/src 5999b12lib/libc/gen nlist.c nlist.3

nlist: Handle multiple symbol tables

* Instead of looking for and stopping at the first SHT_SYMTAB section,
  iterate over all SHT_DYNSYM and SHT_SYMTAB sections until we've either
  found all our symbols or run out.

* Perform bounds checks on section and string table offsets and sizes
  before attempting to mmap() the string table.

* Perform bounds checks on individual symbol table entries before
  attempting to access the corresponding strings.

* Stop treating _Foo and Foo as the same symbol.

This unbreaks OpenSSH which uses nlist(3) to verify PKCS#11 providers.

PR:             295336
MFC after:      1 week
Fixes:          77909f597881 ("Initial elf nlist support [...]")

    [13 lines not shown]
DeltaFile
+84-68lib/libc/gen/nlist.c
+5-3lib/libc/gen/nlist.3
+89-712 files

FreeBSD/src dd92722libexec/tftpd tftp-io.c

tftpd: Add missing bounds checks

In send_[rw]rq(), we were using strlcpy() to avoid overflowing our
packet buffer, then failing to check the result and blithely advancing
our pointer by the full length.

Luckily, this code is only ever used by tftp(1), not tftpd(8).

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

(cherry picked from commit 933893771344e1647eeda152016b938fdc30ccdc)
DeltaFile
+32-26libexec/tftpd/tftp-io.c
+32-261 files

FreeBSD/src 838c8a5usr.bin/tftp main.c tftp.c

tftp: Style cleanup

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

(cherry picked from commit 29aaaa5e6660310311fe443d8792b31181e1dd3c)
DeltaFile
+20-36usr.bin/tftp/main.c
+20-20usr.bin/tftp/tftp.c
+40-562 files

FreeBSD/src 1f78485libexec/tftpd tftp-io.c

tftpd: Simplify packet drop macro

The first argument is always the function name, for which we can simply
use __func__.  This leaves only the optional return value, so we can use
a single variadic macro instead of two nearly-identical copies.

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

(cherry picked from commit 76c3387024b40c2e28ed2d1bb64b3a14371c3c0b)
DeltaFile
+23-28libexec/tftpd/tftp-io.c
+23-281 files

FreeBSD/src 99cbf1fusr.bin/tftp/tests tftp_test.sh

tftp: Add test case with over-long URL

This adds a test case that passes a very long URL on the command line,
which would previously have resulted in a benign buffer overflow in
urihandling(), detectable only by compiling tftp with ASAN enabled.

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

(cherry picked from commit b94689d036c5f5bdc04d080ff7dd5d0e9df9b8d4)
DeltaFile
+24-0usr.bin/tftp/tests/tftp_test.sh
+24-01 files

FreeBSD/src 8c11ec3usr.bin/tftp tftp.c main.c

tftp: Fix handling of port name or number

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

(cherry picked from commit 47e4571df15804fe2b010a3c82b22691d80ee680)
DeltaFile
+22-18usr.bin/tftp/tftp.c
+4-3usr.bin/tftp/main.c
+26-212 files

FreeBSD/src b838a02usr.bin/tftp main.c

tftp: Simplify URI handling

* No need to copy our argument into a new buffer; it is writeable and
  will not be reused after we return.

* Instead of constructing the string "get path" and then splitting it
  into an argument vector, just construct the vector directly.  This
  avoid potentially overrunning the buffer.

* Call settftpmode() just once, with either the default mode or the
  user-provided value we already validated.

* Use errx() instead of fprintf(stderr) + exit().

Reported by:    Moyao, Minghao Fu
MFC after:      1 week
Reviewed by:    markj
Differential Revision:  https://reviews.freebsd.org/D57070

(cherry picked from commit a4b17594181502cea38ab0d8b2a9a10782286334)
DeltaFile
+12-20usr.bin/tftp/main.c
+12-201 files

FreeBSD/src 547c9c6usr.bin/tftp main.c

tftp: Replace fgets with getline

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

(cherry picked from commit 5fd928cf1cef21e0fc20ab7c2be156a0eeecdf40)
DeltaFile
+45-45usr.bin/tftp/main.c
+45-451 files

FreeBSD/src 66a6b7eusr.bin/tftp main.c

tftp: Close files when we're done with them

Also, delete the file we created if receiving it failed.

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

(cherry picked from commit 29351335704e39ce3ca09c528d534c7898bbdc2c)
DeltaFile
+8-2usr.bin/tftp/main.c
+8-21 files

FreeBSD/src 5a0d8a7lib/libc/gen nlist.c nlist.3

nlist: Handle multiple symbol tables

* Instead of looking for and stopping at the first SHT_SYMTAB section,
  iterate over all SHT_DYNSYM and SHT_SYMTAB sections until we've either
  found all our symbols or run out.

* Perform bounds checks on section and string table offsets and sizes
  before attempting to mmap() the string table.

* Perform bounds checks on individual symbol table entries before
  attempting to access the corresponding strings.

* Stop treating _Foo and Foo as the same symbol.

This unbreaks OpenSSH which uses nlist(3) to verify PKCS#11 providers.

PR:             295336
MFC after:      1 week
Fixes:          77909f597881 ("Initial elf nlist support [...]")

    [13 lines not shown]
DeltaFile
+84-68lib/libc/gen/nlist.c
+5-3lib/libc/gen/nlist.3
+89-712 files

FreeBSD/src 7a11a6csys/compat/linuxkpi/common/src linux_acpi.c, sys/dev/acpi_support acpi_ibm.c

acpi: Update mentions of s2idle in comments

We use the explicit "suspend-to-idle" name now.

Sponsored by:   The FreeBSD Foundation
DeltaFile
+2-2sys/dev/acpi_support/acpi_ibm.c
+1-1sys/compat/linuxkpi/common/src/linux_acpi.c
+3-32 files

FreeBSD/src 071d82dshare/man/man4 acpi.4

acpi.4: Update sysctl descriptions with new stype names

Sponsored by:   The FreeBSD Foundation
DeltaFile
+9-6share/man/man4/acpi.4
+9-61 files

FreeBSD/src e4328c1sys/dev/acpica acpi.c

acpi: Update s2idle strings to new name

Reviewed by:    obiwac, emaste, olce
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D57232
DeltaFile
+9-8sys/dev/acpica/acpi.c
+9-81 files

FreeBSD/src f0e702asys/fs/smbfs smbfs_node.c

smbfs: plug smbfs_node_alloc() leak of name buffers when insmntque() fails

PR:     295577
MFC after:      2 weeks
DeltaFile
+4-0sys/fs/smbfs/smbfs_node.c
+4-01 files

FreeBSD/src 7a070calib/libsys fcntl.2

fcntl.2: clarify arg use for F_SETFD

(cherry picked from commit db513f3a55d59339055e6033829964738b879501)
DeltaFile
+3-1lib/libsys/fcntl.2
+3-11 files

FreeBSD/src 0c0f665share/man/man4 linuxkpi_wlan.4, sys/compat/linuxkpi/common/src linuxkpi_80211_pm.c linux_80211.c

LinuxKPI: 802.11: add support for suspend/resume

Add support for automatic suspend/resume as we know it for wireless.
The problem is that the PCI driver which would normally gets the code
is the LinuxKPI PCI framework/Linux wireless driver, which we cannot
ammend or generally add extra suspend/resume code to.
A further problem is that with growing support, the LinuxKPI 802.11
(mac80211) layer also is involved in suspend/resume for WoWLAN (not
yet supported) meaning that we need to hook the suspend/resume
framework into that as well.  Unlike Linux we do not have a general
suspend/resume "hook" we can hang into and we need to tie this one
to the hardware so cannot indepedently (after the driver one) run it.

The solution for FreeBSD, in order to not mangle the Linux native
drivers and get extra maintanace overhead, is to add a bus child
which inherits the general framework and thus is 2 lines + #includes
for each driver extra to add to.

The general suspend/resume framework lives in LinuxKPI (linuxkpi_80211_pm)

    [36 lines not shown]
DeltaFile
+214-0sys/compat/linuxkpi/common/src/linuxkpi_80211_pm.c
+137-0sys/compat/linuxkpi/common/src/linux_80211.c
+116-0sys/compat/linuxkpi/common/src/linux_80211_macops.c
+15-1sys/compat/linuxkpi/common/src/linux_80211.h
+7-1share/man/man4/linuxkpi_wlan.4
+8-0sys/contrib/dev/rtw88/lkpi_rtw88_pm.c
+497-27 files not shown
+521-413 files

FreeBSD/src de65e20sys/compat/linuxkpi/common/src linux_80211.c

LinuxKPI: 802.11: reset chanctx when recycling

When we no longer need a channel context and put it back on the
reserved list, zero it for all but the vif so that we get the same
state as if it was freshly allocated.

Sponsored by:   The FreeBSD Foundation
Fixes:          e62c92c0a5cf, 88cb1e17f471

(cherry picked from commit 8ead19207e56790bd4c64dba4ddbf2e0eb6922f7)
DeltaFile
+5-0sys/compat/linuxkpi/common/src/linux_80211.c
+5-01 files

FreeBSD/src f1de8e3tools/tools/nanobsd defaults.sh

nanobsd: Register the boot.config file in the metalog

Ensure that the boot.config file gets an entry in the metalog by
tgt_touch()ing it.  If a file is not present in the metalog, it gets
excluded from the final image when using "-U" (unprivileged builds).

MFC after:      2 weeks
DeltaFile
+1-0tools/tools/nanobsd/defaults.sh
+1-01 files

FreeBSD/src 5435998tools/tools/nanobsd legacy.sh defaults.sh

nanobsd: Adjust the order of the flags in makefs

The order of the flags matter in makefs(8). The -t (type) flag must come
before the -o (options) flag; otherwise, the options are reset.

Move the -t flag before the -o flag and remove the shim function
_xxx_adjust_code_size() that was created to align to the default makefs
FFS values.

It effectively prevented us from generating NanoBSD images using
unprivileged builds with the partitions internally aligned as intended.

Reviewed by:    senguptaangshuman17_gmail.com, imp
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D57226
DeltaFile
+0-13tools/tools/nanobsd/legacy.sh
+2-2tools/tools/nanobsd/defaults.sh
+2-152 files

FreeBSD/src c579927tools/tools/nanobsd defaults.sh

nanobsd: Use makefs -R flag to honor rounded sizes

Switch from the min/max size flag (-s) to the round-up flag (-R) when
invoking makefs(8).

Because the partition sizes passed to nano_makefs have already been
rounded up by calculate_partitioning(), using -s can cause makefs to try
to perform sizing adjustments that usually result in failures.

Reviewed by:    imp
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D57225
DeltaFile
+1-1tools/tools/nanobsd/defaults.sh
+1-11 files