pkg-serve: stat the opened descriptor instead of the path
Open first and fstat() that fd, so the file checked is the one served.
O_NONBLOCK avoids blocking on a FIFO.
pkg-serve: do not leak whether a path exists
Report "ko: file not found" for non-regular files as well, so a
client cannot tell an existing path from a missing one.
pkg-serve: bound the command line length
getline(3) grows its buffer without limit, so a client could make the
process consume unbounded memory. Read commands with a bounded
reader, drain and reject lines longer than MAXLINE with
"ko: command too long", and document the limit.
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
powerpc: save and restore VRSAVE with the vector state
VRSAVE was never saved or restored, although user code can write it
and the mcontext carries it, so every process saw the value the
previous process on that CPU had left there.
Two processes pinned to the same CPU and writing different values to
VRSAVE each read back the other's; each reads back its own now.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61544
powerpc: move get_pcpu() to machine/pcpu.h
Every other arch defines get_pcpu() in machine/pcpu.h, powerpc has it in
machine/cpufunc.h, which is entirely under _KERNEL. lsof includes
sys/systm.h without _KERNEL first on purpose, so on powerpc cpufunc.h
turns into an empty header and pcpup later expands to a call of an
undeclared get_pcpu(). Since sys/mount.h started pulling in sys/proc.h
this breaks the lsof build on powerpc64 and powerpc64le.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61305
snd_uaudio: Fix the MIDI TX round-robin
Nothing advances curr_cable, so umidi_bulk_write_callback() only
services cable 0, which is a problem on MIDI devices with more than one
jack.
Fixes: 039477d3e7e7 ("snd_uaudio: Simplify chan->curr_cable calculation in uaudio_bulk_write_callback()")
Sponsored by: The FreeBSD Foundation
MFC after: 1 day
usbdevs: Add HumanWare BrailleNote Apex IDs
Add the HumanWare vendor ID and the BrailleNote Apex
product ID to support the Apex 32 BT when configured
as a screen reader terminal in USB Client mode.
This device will also serve as the starting point for
developing the FreeBSD braille(4) subsystem.
Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61624
twsi: Wait for the bus to go idle before starting a transfer
The status register does not read as idle (0xf8) right after the
previous transfer ended and the module was disabled. On fast
(optimised) kernels the next transfer starts too early, sees a
different status and fails with EIO ("Bad status at start of
transfer").
On the Pine H64 this made the AXP805 write that disables the PHY
supply fail from awg_shutdown(), leaving the PHY powered and the
board hanging on warm reboot. Poll the status register for up to 1ms
before declaring the bus not idle.
Tested on: Pine H64 (5 warm reboots with a NODEBUG kernel)
Fixes: cb167e1ae954 ("twsi: do not attempt transfer if bus is not idle")
arm64 pmap: combine L3C accessed bits in pmap_mincore()
The accessed bit may be set in only some of an L3C superpage's L3
PTEs. However, when pmap_mincore() found an L3C mapping, it reported
the accessed state of the specified L3 PTE only, so mincore(2) could
fail to report MINCORE_REFERENCED for an L3C superpage that had been
accessed. When the accessed bit is not set in the specified entry, use
pmap_load_l3c() to combine the accessed bits from all of the L3C
superpage's L3 PTEs.
(cherry picked from commit 3ba68f5c5dcc9a4bcd513c28efce29afdfcb76ff)
bhyve: Reject unsupported checkpoints before saving RAM
pci_snapshot() rejects devices without a pe_snapshot callback, but
vm_checkpoint() reaches that check only after truncating checkpoint
files, pausing the VM, and saving RAM and kernel state.
Check for unsupported PCI devices at the start of vm_checkpoint(),
before creating files or pausing the VM. This preserves existing
checkpoint files when the request cannot succeed. Add
pci_can_snapshot() so that the new check and pci_snapshot() use the
same test.
Reviewed by: markj, kevans
Approved by: markj (mentor)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61003