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
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)
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)
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)
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)
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]
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)
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)
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)
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)
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]
acpi: Update s2idle strings to new name
Reviewed by: obiwac, emaste, olce
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57232
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]
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)
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
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
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