ipfw: hold sleepable "upper half lock" for periodic state expiry
The state expiration may lead to freeing rules, which requires this lock.
Since the lock is sleepable, move the expiry routine from callout context
to a taskqueue. This also should have a positive effect of not running
expensive function as a callout.
Fixes: e3caa360d5d0a73af0de1d293d5b8ff6e900ceb4
Reviewed by: pouria
Differential Revision: https://reviews.freebsd.org/D60869
tcp: refactor tcp_autosndbuf() and associated sysctls
Rename tcp_sndbuf_autoscale() to tcp_autosndbuf(). This matches
complementary tcp_autorcvbuf() that was factored out as a separate
function a few months before tcp_sndbuf_autoscale() was. Move the large
comment to the header of the function. Use unsigned types for all sizing
sysctls and variables and use bool for the switching sysctl. Add a
comment above net.inet.tcp.sendbuf_auto_lowat (default to off) providing a
reference to its origins. Add DTrace probe tcp::send-autoresize,
complementary to the existing tcp::receive-autoresize.
Rack has its own function, just enable the DTrace probe there.
Reviewed by: tuexen
Differential Revision: https://reviews.freebsd.org/D60732
tcp: refactor tcp_autorcvbuf() and associated sysctls
Run the entire function under the socket buffer lock. Make it responsible
to set the new limit or clear SB_AUTOSIZE in case of a failure. Use
unsigned type for newsize, that matches both the sb_hiwat type and min()
argument types. Make byte counter in the tcpcb unsigned, too. Make the
sizing tunables unsigned, and make the switching tunable a boolean. Don't
execute Dtrace probe in case of a failure. Simplify the Dtrace probe to
report only relevant information, the previous probe looked more like a
leftover from a debugging session.
Reviewed by: tuexen
Differential Revision: https://reviews.freebsd.org/D60731
ping: use CLOCK_REALTIME for ICMP Originate Timestamp
RFC 792 defines the ICMP Originate Timestamp field as milliseconds
since midnight UTC. However, ping(8) currently derives this value
from CLOCK_MONOTONIC, which represents time since an unspecified
starting point and is not related to UTC.
The issue was introduced by commit 1ad76f1b6047, which replaced
gettimeofday(2) with clock_gettime(CLOCK_MONOTONIC) for timekeeping
in ping(8).
Fix this by using CLOCK_REALTIME when generating the ICMP originate
timestamp.
Before:
$ ping -Mt -c1 127.0.0.1
ICMP_TSTAMP
PING 127.0.0.1 (127.0.0.1): 56 data bytes
[17 lines not shown]
ping: fix test timestamp_origin when tstamprepl is disabled
The timestamp_origin test sends an ICMP Timestamp Request (ping -Mt) and parses
the tso/tsr fields out of the reply.
When the sysctl net.inet.icmp.tstamprepl is 0, the kernel silently drops the
request, ping receives no reply, and the sed extraction yields an empty $tso.
The test then fails inside atf_check test -n "$tso" with the unhelpful message
Approved by: maxim
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D57287
(cherry picked from commit ff873565bc2c3e47fe1d070305aa851189ee8bcf)
ping: do a better job with what we received from the net, part 2
When we see a difference between the payload we sent and what we
received, we dump both but we were not prepared for the case when
the received payload is less than we sent. In this case we were trying
to dump more than needed.
Funny enough, 23 years ago I already fixed a similar issue here but
didn't pay attention to this small dumping loop.
Test written by jlduran.
Reviewed by: jlduran
MFC after: 1 month
Found with: Claude Code Sonnet 5
Differential Revision: https://reviews.freebsd.org/D59556
Differential Revision: https://reviews.freebsd.org/D59582
(cherry picked from commit 0b9434d707c71de7b1b62e400e6e780224f0384d)
ping: do a better job checking what we receive from the net
- zero out a buffer for the incoming icmp message that
we are about to parse
- for ICMP_MASKREPLY and ICMP_TSTAMPREPLY responses check their length
and warn and reject them if they are truncated
Without these checks a part of stack allocated struct icmp icp could
be printed out which seems low severity since we already dropped root
privileges by the time icp is allocated.
Reviewed by: glebius
MFC after: 1 month
Found with: Claude Code Sonnet 5
Differential Revision: https://reviews.freebsd.org/D59555
(cherry picked from commit aa6683207d189a0b58ccf8806bd9f8793914bc45)
mkimg: Ignore redundant %align values
Partitions are trivially aligned to sector boundaries, so asking e.g.
for a partition to be aligned to a 64-byte boundary is pointless but
harmless. Treat it as such, with a warning (in case the request was
a mistake, e.g. requesting 1-byte instead of 1M-byte alignment) rather
than as an error.
Reviewed by: markj
Suggested by: markj
MFC after: 1 week
Sponsored by: Amazon
Differential Revision: https://reviews.freebsd.org/D60819
vmimage.subr: Support partition alignment
If VM_PARTALIGN is set, pass %${VM_PARTALIGN} to mkimg in the
specification of swap, config, root, and ESP partitions. (Boot
partitions are not aligned, both because they're small and in
case firmware makes assumptions about their locations.)
Reviewed by: lwhsu, imp
MFC after: 1 week
Sponsored by: Amazon
Differential Revision: https://reviews.freebsd.org/D60454
mii: Fix SMSC name
The LAN8700 / LAN8710 PHYs were Standard Microsystems Corporation parts,
which early on used SMC as an abbreviation but they were using SMSC when
they were exclusively an IC maker (as opposed to full add-in NICs).
SMSC was acquired by Microchip in 2012. I kept the pre-acquisition
name, as NetBSD (from where we obtained miidevs) uses SMSC.
Reviewed by: adrian
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D56819
(cherry picked from commit 89c883c09ab5e0fdca7ac5dfe74fcc46b7669eb5)
(cherry picked from commit f2f67df8c92b51d0bff9c226755cd31c8d685573)
sound: Use GID_WHEEL/0666 instead of GID_AUDIO/0660 to create the mixer cdev
This change got accidentally carried over after an MFC, because in all
audio devices are now created with GID_AUDIO/0660 in -CURRENT.
Fixes: 2b61245f5a16 ("sound: Simplify how snd_mixer is fetched and how the cdev is created")
PR: 299683
Sponsored by: The FreeBSD Foundation
mkimg: Add per-partition alignment
This adds a "%align" field to partition specifications, resulting in
the start of a partition being shifted to the next aligned position.
When both :offset and %align are used, a relative offset is treated as
a minimum value, while an unaligned absolute offset is an error.
Reviewed by: imp (earlier version)
MFC after: 1 week
Sponsored by: Amazon
Differential Revision: https://reviews.freebsd.org/D60450
mkimg: Don't ignore invalid partition offsets
When handling PART_KIND_FILE, the "error" variable is set to reflect
any errors in parsing the specified offset; but that value is then
overwritten by the return value of image_copyin.
Error out immediately instead. Note that it is not necessary to change
the code in PART_KIND_SIZE which parses the size, since in that case we
do not overwrite the value in "error".
Fixes: 8f3c71c85e5f ("mkimg: Add support for offset if the source is an image")
MFC after: 1 week
Sponsored by: Amazon
Differential Revision: https://reviews.freebsd.org/D60422
machine/ieeefp.h: include <sys/cdefs.h>
The <machine/ieeefp.h> headers wrap their deprecated FPU control
prototypes in __BEGIN_DECLS/__END_DECLS but rely on the includer to
have pulled in <sys/cdefs.h>. Including <floatingpoint.h> first on
arm, arm64, powerpc and riscv (or amd64 <machine/ieeefp.h> with
__IEEEFP_NOINLINES__) fails with "unknown type name '__BEGIN_DECLS'".
This breaks e.g. devel/py-pyinstaller.
Suggested by: jhb
Reviewed by: jhb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D59659
(cherry picked from commit 9d50245a0f1333e10cc1c4dda16878cd79a7c42b)
(cherry picked from commit 252500da3a45a89d91c276db88f9669314cc2dfa)
machine/ieeefp.h: include <sys/cdefs.h>
The <machine/ieeefp.h> headers wrap their deprecated FPU control
prototypes in __BEGIN_DECLS/__END_DECLS but rely on the includer to
have pulled in <sys/cdefs.h>. Including <floatingpoint.h> first on
arm, arm64, powerpc and riscv (or amd64 <machine/ieeefp.h> with
__IEEEFP_NOINLINES__) fails with "unknown type name '__BEGIN_DECLS'".
This breaks e.g. devel/py-pyinstaller.
Suggested by: jhb
Reviewed by: jhb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D59659
(cherry picked from commit 9d50245a0f1333e10cc1c4dda16878cd79a7c42b)
LinuxKPI: restore several hard coded return values for the CONFIG_PM case
drm-kmod sets CONFIG_PM (unclear if for other parts) but LinuxKPI
has no understanding of a dev->power implementation for pm_runtime.h.
The return values based on !CONFIG_PM thus cause problems to drm-kmod.
Return the previous values under CONFIG_PM but leave the TODO logging
as the actual implementation is missing and return values may not be
universally correct (beyond the known drm-kmod use cases).
The following functions having a return value but none sepcific for
CONFIG_PM as (based on drm-kmod master):
pm_runtime_resume only caller ignores the return value
pm_runtime_set_active two callers ignore the return value
pm_runtime_put_autosuspend all callers seem to ignore the return value
pm_runtime_autosuspend 2/3 callers ignore the return value;
3rd is #ifdef __linux__
pm_runtime_suspended 3/4 callers ... do check the return value
but the logic expects the false, which also
[7 lines not shown]
pam_exec: fix the stderr close test and avoid a double close
The cleanup tested cherr[0] when closing cherr[1]. The parent also closed
chin[0]/chout[1]/cherr[1] after pdfork() without clearing them, so the out:
cleanup path closed them again. Clear each fd after closing and test the right
one.
Reviewed by: des, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D60924
bhyve: Treat BAR registration failures as non-fatal
Some guest operating systems (at least 9front) will leave device I/O
space decoding enabled while probing BAR sizes. In this case, a
sufficiently large 32-bit BAR can overlap with the HPET MMIO region
fixed at 0xfed00000. This results in an assertion failure in
modify_bar_registration(), even though the collision is transient, i.e.,
the guest will promptly map the BAR elsewhere.
Tolerate such overlaps. Keep track of a BAR's registration state and
make sure that modify_bar_registration() doesn't try to unregister an
I/O space if registration failed.
This fixes a problem where a 32MB framebuffer ends up overlapping with
the HPET MMIO region, causing some guests to crash with an assertion
failure when probing BARs during boot.
PR: 290098
Reviewed by: bnovkov
[3 lines not shown]