virtio_random: defer first enqueue until after DRIVER_OK
According to the virtio spec:
> The driver MUST NOT send any buffer available notifications to the
> device before setting DRIVER_OK.
DRIVER_OK isn't set until after attach completes, so defer the first
enqueue. We haven't found any problems as a result of this to the best
of my knowledge: q35 and other devices that we *have* been used with
will apparently check when we go DRIVER_OK.
Tested with q35 virtio-random, which still works.
Reported by: llm-postcr
Reviewed by: kfv, markj
Fixes: f1c5a2e3a62505 ("virtio_random: Pipeline fetching the data")
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D61228
ggate: fix test intermittency
* ggatel: fix piped output. Flush stdout before daemonizing, so the
output can be read when it's in a command pipeline.
* ggated: bind the port _before_ daemonizing, so an invoking script can
be sure that the port is bound as soon as the command returns.
* tests: allow ggatec or ggatel to automatically allocate a device
number instead of choosing one in a racy way.
With all of these changes I can no run the tests 1000 times without
fail. And in parallel, too.
Sponsored by: ConnectWise
PR: 298942
Reported by: siva
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D60707
[2 lines not shown]
nfsserver: Do not increment seqid on BADSEQID
When returning NFSERR_BADSEQID, the server should not have incremented
the sequence ID, yet the call to nfsrv_checkseqid() a few lines above
does precisely that. Instead, check for a legitimate retransmission
of the original successful request, and reject otherwise, before the
ticket is used and sequence ID incremented.
MFC after: 1 week
Fixes: ff45b9fc1a8c ("Bjorn reported a problem...")
Sponsored by: Klara, Inc.
Reviewed by: rmacklem
Differential Revision: https://reviews.freebsd.org/D61156
libc: Export timespec_getres(3) and add tests
timespec_getres() has been declared in <time.h> and built into libc,
but never listed in a symbol map. It is therefore local to libc.so,
and dynamically linked callers fail to link.
Reviewed by: ziaee, fuz, des
Approved by: fuz (mentor)
Fixes: 9b5d724cad10 ("libc: Add timespec_getres(3) as per C23.")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D60799
tpm_crb: wait for idle and locality release after each command
transmit only requested GO_IDLE and the locality release, so a back-to-back
command could see stale state and fail with EIO.
A post-send idle timeout no longer discards a completed response.
Reviewed by: kbowling
Approved by: kbowling
Differential Revision: https://ron-dev.freebsd.org/FreeBSD/src/pulls/93
tarfs: Fix length calculation for file read
When the offset is within a block rather than at its beginning, the
length should be clamped to the remaining length of the block, not its
total length.
Reported by: n0ps1ed
MFC after: 1 week
Reviewed by: markj, emaste
Differential Revision: https://reviews.freebsd.org/D60904
(cherry picked from commit 18bce6e65cdf059618ff12ace82a9f7334e1b610)
vfs: Avoid integer overflow when faulting
In vn_io_fault1(), the read / write length can easily exceed INT_MAX.
Passing it directly to uiomove(), which expects an int, results in a
negative uio_resid, which to the caller looks like we read more than
was requested.
PR: 298159
MFC after: 1 week
Reviewed by: olce, kib
Differential Revision: https://reviews.freebsd.org/D59412
(cherry picked from commit b487aca48535e5f04e4913447fcbe33f1bf56c68)
tarfs: Limit file name length
When indexing the tarball on mount, fail if a file or directory name
exceeds MAXNAMLEN.
Reported by: n0ps1ed
Reported by: Franz Bettag <franz at bett.ag>
MFC after: 1 week
Reviewed by: markj, emaste
Differential Revision: https://reviews.freebsd.org/D60903
(cherry picked from commit a38033234692e9dab6f3f4404adc693fccabc14a)
tarfs: Limit file name length
When indexing the tarball on mount, fail if a file or directory name
exceeds MAXNAMLEN.
Reported by: n0ps1ed
Reported by: Franz Bettag <franz at bett.ag>
MFC after: 1 week
Reviewed by: markj, emaste
Differential Revision: https://reviews.freebsd.org/D60903
(cherry picked from commit a38033234692e9dab6f3f4404adc693fccabc14a)
tarfs: Fix length calculation for file read
When the offset is within a block rather than at its beginning, the
length should be clamped to the remaining length of the block, not its
total length.
Reported by: n0ps1ed
MFC after: 1 week
Reviewed by: markj, emaste
Differential Revision: https://reviews.freebsd.org/D60904
(cherry picked from commit 18bce6e65cdf059618ff12ace82a9f7334e1b610)
vfs: Avoid integer overflow when faulting
In vn_io_fault1(), the read / write length can easily exceed INT_MAX.
Passing it directly to uiomove(), which expects an int, results in a
negative uio_resid, which to the caller looks like we read more than
was requested.
PR: 298159
MFC after: 1 week
Reviewed by: olce, kib
Differential Revision: https://reviews.freebsd.org/D59412
(cherry picked from commit b487aca48535e5f04e4913447fcbe33f1bf56c68)
e6000sw: Write the value, not the register, in Clause 45 writes
e6000sw_write_xmdio() loaded the Clause 45 register address into the
SMI PHY data register a second time, where the value to write belongs,
so every Clause 45 write stored the register address.
Its only caller, e6000sw_serdes_power(), runs at attach for ports 9 and
10 of the 88E6190 and 88E6190X to power one SERDES interface up and the
other down. It wrote 0x2000 to the SGMII control register and 0x1000
to the 10GBASE-R PCS control register instead, so neither interface was
powered down and the rest of each register was overwritten.
Fixes: 9aba06377d26 ("Add support for the Marvell 88E6190 11 ports switch.")
Sponsored by: Rubicon Communications, LLC ("Netgate")
iflib: Use a single tx dma map
The need for a separate map for TSO and non-TSO seems to have arisen from
a misunderstanding about the DMA requirements for Intel drivers like
ice/ixl/iavf. Specifically, this Intel hardware has a quirk where no
more than N (=8) segs can be DMA'ed per packet on the wire. This limit
was enforced using a DMA map with a low segment limit for non-TSO and a
driver specific check for TSO. This led to a *lot* of complexity in
iflib (~80 extra lines of code that this change removes) when the
limit can simply be enforced via the existing EFBIG mechanisms.
This change adds a new flag, IFLIB_SPARSE_TX, that drivers for hardware
with this quirk must set. When set, it causes non-TSO sends that
exceed isc_tx_nsegment to be treated as if bus_dmamap_load_mbuf_sg()
had returned EFBIG.
Due to the API/KABI change, I've bumped the FreeBSD version as well.
Note kgalazka suggested the flag, rather than a more awkward
[5 lines not shown]
libthr: Create landing pad in thr_once in C++ exception
In _thr_once, if init_routine fails with exception, the stack allocate
__cup will become invalid when unwinder walk back and free the stack of
thr_once. This cause cleanup linked list be dangling. In here, we give
the cleanup function a landing pad so that we td can correctly point
to previous cleanup function.
Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D61212
libthr: Predict libthr is initialized in _thr_check_init
_thr_check_init() is called on hot paths such as pthread_once(), and
the uninitialized case can only happen once. Mark it with
__predict_false so the compiler lays out the initialized case as the
fall-through path.
Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D61213
hastd: Remove pidfile on exit
Make hastd remove its pidfile before exit after catching a signal or a
stop control message, not just on failure to start.
MFC after: 1 week
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D60192
(cherry picked from commit 3f2f6bb8f7b562276bffd04a9ae4c05a351b4435)
hastd: Remove pidfile on exit
Make hastd remove its pidfile before exit after catching a signal or a
stop control message, not just on failure to start.
MFC after: 1 week
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D60192
(cherry picked from commit 3f2f6bb8f7b562276bffd04a9ae4c05a351b4435)
ice(4): Do not leave device non-functional if Tx scheduler config fails
The ice_cfg_tx_topo function attempts to apply Tx scheduler topology
configuration based on NVM parameters, selecting either a 5 or 9 layer
topology. As part of this flow, the driver acquires the "Global Configuration Lock",
which is a hardware resource associated with programming the DDP package
to the device. This "lock" is implemented by firmware as a way to
guarantee that only one PF can program the DDP for a device. Unlike a
traditional lock, once a PF has acquired this lock, no other PF will be
able to acquire it again (including that PF) until a CORER of the device.
However, if configuration of the Tx topology fails, (i.e.
ice_get_set_tx_topo returns an error code), the driver exits
ice_cfg_tx_topo() immediately, and fails to trigger CORER.
While the global configuration lock is held, the firmware rejects most
AdminQ commands, as it is waiting for the DDP package download (or Tx
scheduler topology programming) to occur.
Refactor ice_cfg_tx_topo() to always trigger a CORER after acquiring the
global lock, regardless of success or failure of the topology
configuration.
[15 lines not shown]
auditdistd: Use void pointers for opaque data
Use void, not char, for pointers to opaque data in our send and receive
functions.
Sponsored by: Klara, Inc.
Sponsored by: Qualys, Inc.
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D60728
(cherry picked from commit 4f19e4aca4f4b7a3058be5d3bfc5aed66668b00f)
auditdistd: Fix build failure
Fixes: 4f19e4aca4f4 ("auditdistd: Use void pointers for opaque data")
Reported by: garga@
(cherry picked from commit 0ce9d6e240a14d5b7cd8eb45a83d0e429f4a3edf)
auditdistd: Use fixed-length protocol names
All communication between auditdistd senders and receivers and
internally between auditdistd and its worker children passes through the
same pair of send / receive functions. The receive function uses
recv(2) with the MSG_WAITALL flag, which in theory means we should never
get a short read. However, when handing off a socket to a worker child,
we also pass a variable-length string identifying the type of socket
we're passing, and reading this string relies on a short read. This
used to work because the arrival of the descriptor would interrupt the
recv(2) call, but this bug was fixed when the AF_UNIX code was rewritten
a while ago and auditdistd has been broken ever since.
Fixing the length of the protocol name to four characters including the
terminating null solves the short-read bug by never requiring a short
read (nothing else in auditdistd requires one).
PR: 296107
MFC after: 1 week
[4 lines not shown]
libfetch: Plug leak in 304 Not Modified case
When we get a 304 Not Modified response, we need to go through the error
path to properly free any resources we've allocated instead of just
returning NULL directly.
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D60016
(cherry picked from commit b212f565fb1a34fdcd2f5c9530164ff4718a1a9f)
auditd: Support logging directly to syslog
Every tenth call to auditwarnlog(), check that the audit_warn(5) script
exists and is executable by us. If it is, execute it as previously;
otherwise, fall back to calling syslog(3) directly.
Additionally, if we choose to use the script and fail, also log the
original message to syslogd, not just the fact that we failed to log.
We could record the result of trying to execute the script, but that
would require pausing while it runs (or at least until the execve(2)
call has completed).
Retesting every tenth call is a little clunky but avoids having to
restart or signal auditd(8) to force it to notice a change in
availability, or adding a command-line option and / or modifying the
audit_control(5) syntax to let the user express a preference.
MFC after: 1 week
[6 lines not shown]
audit_warn: Avoid pointless fork and path search
While here, document what the script actually does, not what it once did
on a project branch somewhere that was never merged.
MFC after: 1 week
Sponsored by: Klara, Inc.
Sponsored by: Qualys, Inc.
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D60171
(cherry picked from commit 173268f3d5ede5f55a25f684d4c8c4c43749fde7)
libfetch: Plug connection leaks in FTP code
When setting up an FTP transfer, we need to dereference the cached
connection before returning after a failure.
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D60017
(cherry picked from commit 570869838f8bdaedb4c54953e80fe001a82190fd)