tzcode: Avoid integer truncation resulting in wrong weekday
From a report[1] on the tz mailing list:
In timesub() the weekday is stored in (int) tm_wday before reduction
modulo seven (DAYSPERWEEK). Previously this could overflow a 32-bit
int, resulting in an incorrect weekday calculation.
Calculate two additional intermediate terms modulo seven to avoid an
intermediate value that does not fit in 32 bits.
We're committing this patch now so we can have something in place for
FreeBSD 15.2. If a different change is committed upstream we will
replace this.
[1] https://lists.iana.org/hyperkitty/list/tz@iana.org/thread/O3RZGBKSO5GXBFDZKW2JXO3OQIIGYBF3/
Approved by: re (cperciva)
PR: 300977
[6 lines not shown]
tcp: count only the SACK blocks that fit in tcp_maxseg()
tcp_addoptions() sends only the SACK blocks that fit in TCP_MAXOLEN.
tcp_maxseg() counted every pending block and clamped the total, so
without timestamps and with five or more blocks pending it came out 4
bytes below the segment tcp_output() sends. Limited transmit after an
RTO then sent one full segment and failed the "sent too much" KASSERT.
Approved by: re (cperciva)
PR: 282605
Approved by: adrian (mentor)
Signed-off-by: Nick Price <nprice at FreeBSD.org>
Reviewed by: tuexen, glebius, adrian
Differential Revision: https://reviews.freebsd.org/D60460
(cherry picked from commit d3b02115d4b373c719d9a716da38d94511de3f07)
(cherry picked from commit aacae7b35a22a56e187a0a41db231d63ca9cefb6)
tcp: improve consistency
Use an inline function tcp_adapt_iss_check() to perform the check
consistently instead of replicating the code multiple times. These
checks already became inconsistent.
A fix for PR 298560 requires more calls to tcp_adapt_iss_check().
Approved by: re (cperciva)
Reviewed by: Peter Lei
Fixes: fa2ad70a4511 ("tcp: make ghost ACK handling more conformant")
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D61685
(cherry picked from commit e3483dbc91b59b5b2c73a4bc792fbb834c3dc111)
(cherry picked from commit 73929d1dc3b4116ca12cc3fe08fa3a9b66bf3318)
tcp: make ghost ACK handling more conformant
The latest version of draft-ietf-tcpm-tcp-ghost-acks changed
a condition. This should make no substantial difference, but makei
it compliant to the latest version of the specification.
Approved by: re (cperciva)
Reviewed by: rscheff, Peter Lei
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D58411
(cherry picked from commit fa2ad70a4511e7b379e81de82c9e51b2e0994295)
(cherry picked from commit a170546cb8d13a67ee3062114228d3df4744bbee)
tcp: improve sender side SWS avoidance
When checking for a full sized segment, take all TCP options that will
be included into account. This fixes a bug which can trigger the
"sent too much" KASSERT related to limited transmit.
Approved by: re (cperciva)
Reported by: olivier
Reviewed by: rscheff, Peter Lei
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D61605
(cherry picked from commit d174085f9f895ed444bd95120da3eff481a58f1a)
(cherry picked from commit 13357c1ee34f9f8655375714c60da8bf4881493a)
tcp bbr: improve handling of retransmissions in LAST-ACK
When performing a timer based retransmission, clear the
BBR_RWND_COLLAPSED flag. If it sticks, t_rxtshift is never incremented
resulting in unlimited retransmissions in the LAST-ACK state.
Approved by: re (cperciva)
Reported by: Illia Vynohradov
Reviewed by: Peter Lei
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D61586
(cherry picked from commit 3c6fd437b1824caeddb5f0d4570d43cf0c999c14)
(cherry picked from commit cbd17b66e64e9bdf025200c4993b8aeae6a0ebe9)
tcp bbr: improve retransmit timout calculation
The retransmission timeout should the srtt + 4 * rttvar.
The srtt is using 5 bits of fractions and rttvar is using 4 bits of
fractions, some specific shifting is required.
Approved by: re (cperciva)
Reviewed by: Peter Lei
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D61581
(cherry picked from commit 2f98793a13fe3e69cf6b698fa469550b4ba0fea1)
(cherry picked from commit ccf8e3762c3948446263ae3ef0dd98391ef9f97e)
tzcode: Avoid integer truncation resulting in wrong weekday
From a report[1] on the tz mailing list:
In timesub() the weekday is stored in (int) tm_wday before reduction
modulo seven (DAYSPERWEEK). Previously this could overflow a 32-bit
int, resulting in an incorrect weekday calculation.
Calculate two additional intermediate terms modulo seven to avoid an
intermediate value that does not fit in 32 bits.
We're committing this patch now so we can have something in place for
FreeBSD 15.2. If a different change is committed upstream we will
replace this.
[1] https://lists.iana.org/hyperkitty/list/tz@iana.org/thread/O3RZGBKSO5GXBFDZKW2JXO3OQIIGYBF3/
PR: 300977
Requested by: re (cperciva)
[4 lines not shown]
acpica: Fix SRAT memory region insertion sort
The SRAT table can list memory regions in any order, but we need them
sorted. There is an insertion sort to accomplish this when building
the mem_info array, but instead of inserting the new region before
the *first* higher-base-address region, it was inserting the new
region before the *last* higher-base-address region; i.e. if the array
already held "1 3 4" then inserting "2" would produce "1 3 2 4".
Break out of the insertion-location-finding loop when we find the right
spot to insert the new memory region into the list, rather than looking
further.
Approved by: re (cperciva)
Reviewed by: jhb
Fixes: dd540b46236b ("Add a parser for the ACPI SRAT table...")
MFC after: 1 day
Sponsored by: Amazon
Tested on: c5n.9xlarge, c6a.24xlarge, c6a.metal, c7a.metal-48xl
[7 lines not shown]
EC2: Set hw.dmar.enable="1"
Large EC2 "bare metal" instances route interrupts to APIC IDs > 255,
and unlike the "virtualized" instances, don't support extended APIC
destination IDs (since that's a hypervisor feature, and bare metal
instances have no hypervisor).
Enable the IOMMU for interrupt remapping; this unbreaks booting on
m8i.metal-96xl and variants thereof (e.g. c8in).
Approved by: re (cperciva)
MFC after: 1 day
Sponsored by: Amazon
Tested on: c5n.9xlarge, c6a.24xlarge, c8in.96xlarge, c5.metal,
c6in.metal, c6a.metal, c7a.metal-48xl, c7i.metal-24xl,
c7i.metal-48xl, c8a.metal-24xl, c8a.metal-48xl,
c8i.metal-48xl, c8i.metal-96xl, c8in.metal-48xl,
c8in.metal-96xl, m5.metal, m8azn.metal-24xl
[2 lines not shown]
procctl: Zero the output structure for the compat32 syscall
Otherwise the freebsd32 implementation of PROC_REAP_STATUS leaks
uninitialized kernel stack memory.
Approved by: re (cperciva)
Reviewed by: kib
Reported by: Dennys Kaluzny Pereira <dennyskaluzny at gmail.com>
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61510
(cherry picked from commit 5a834ad15f1f09d43a6840c74da194db6f890aa2)
(cherry picked from commit 42e71f0bafc23c0707752381d0b25649d12ae8c4)
imgact_elf: Pass program headers to the sv_protect hook
We handle program headers beyond the first page of the file, but
arm64_exec_protect() wasn't updated to handle this. Pass the program
header array directly to the sv_protect hook.
Also fix a pre-existing bug: imgp->et_dyn_addr isn't the right base
address to use for the SV_INTERP case.
Approved by: re (cperciva)
Reported by: alc
Reviewed by: alc, kib
Fixes: 804daf166406 ("imgact_elf: read program headers if not contained in the first page")
Fixes: 670af174e27b ("arm64: Enable BTI in the kernel ELF loader")
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61999
(cherry picked from commit 884e1a00151d181e5dd1ba9d83c1adcffd25e5e8)
sysrc: Restore alignment with rc(8) boot process
Fix 1 issue identified in post-commit review of d0a1676:
POSTCR-d0a167652278ed81d259a1b77620b0c1cb9f72c8-1:
set -f around source_rc_confs stops glob expansion of rc_conf_files,
so sysrc no longer sees files that rc(8) sources
Partially "revert" d0a167652278 with respect to RC_CONFS, `-f file`,
rc_conf_files handling, and source_rc_confs invocation.
Add an ATF test to ensure we maintain rc(8) alignment.
Reported by: llm-postcr
Fixes: d0a167652278 ("sysrc: Support special characters in file names")
tzcode: Avoid integer truncation resulting in wrong weekday
From a report[1] on the tz mailing list:
In timesub() the weekday is stored in (int) tm_wday before reduction
modulo seven (DAYSPERWEEK). Previously this could overflow a 32-bit
int, resulting in an incorrect weekday calculation.
Calculate two additional intermediate terms modulo seven to avoid an
intermediate value that does not fit in 32 bits.
We're committing this patch now so we can have something in place for
FreeBSD 15.2. If a different change is committed upstream we will
replace this.
[1] https://lists.iana.org/hyperkitty/list/tz@iana.org/thread/O3RZGBKSO5GXBFDZKW2JXO3OQIIGYBF3/
PR: 300977
Requested by: re (cperciva)
[2 lines not shown]
nfsclrdma: Add build glue for nfsclrdma sources
Commit 80bee4d836 added the sources for client side NFS
over RDMA.
This patch adds the code to build these sources as a
module called nfsclrdma.ko or in the kernel when
kernel options NFSCL and OFED are specified.
Reviewed by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D61926
Fixes: 80bee4d83637 ("nfsclrdma: Add code to support client side NFS over RDMA")
nfs_clvfsops.c: Don't allow krb5i/krb5p or TLS for RDMA
I don't think it makes any sense to do encryption/decryption via
the cpu for data being RDMA'd. (The whole point of RDMA is to
move the data fast.) Disallow the combination of "rdma" and
"krb5i", "krb5p" or "tls".
MFC after: 1 month
Fixes: 884ee8d6c9b4 ("nfscl: Add some glue for client side NFS over RDMA")
localedef: off by one bug drops the highest code point from every collation table
localedef(1) writes one fewer entry than it has into the "large" (code point
above UCHAR_MAX) collation table, and records a count one short. The table is
built in code point order, so the entry lost is always the character with the
highest code point in the locale. For that character wcsxfrm(3) returns 0 and
wcscoll(3) gives it no weight: it sorts with the ignorables and compares equal
to unrelated characters.
Reviewed by: rmoeller, kevans
Approved by: kevans (mentor)
Differential Revision: https://reviews.freebsd.org/D60057
netlink: Do not change interface flags on an empty ifinfomsg
Since f89f82e4042a, _nl_modify_ifp_generic() treats ifi_change == 0
as a request to apply all of ifi_flags. A RTM_NEWLINK request that
only modifies attributes carries a zeroed ifinfomsg, so it brought
the interface down and cleared its permanent promiscuous mode as a
side effect.
Only apply flags for an empty ifi_change when ifi_flags is set,
which matches the behavior of Linux.
Fixes: f89f82e4042a ("netlink: Fix IFF_UP flag handling in RTM_NEWLINK's modify_link handler")
Differential Revision: https://reviews.freebsd.org/D61504
nd6: Keep addresses tentative when DAD cannot run
in6_ifa_need_dad() ignored the interface state, making addresses on
down/ifdisabled interfaces optimistic and usable while DAD was deferred.
Guard it like nd6_dad_start() and re-evaluate it in in6_if_up() and
nd6_timer().
Also, reject IN6_IFF_NOTREADY sources in nd6_ns_output_fib() and
GRAND because optimistic DAD can fail while sockets are already using
the address.
While here, add some tests to make sure these never happen.
Reported by: llm-postcr
Fixes: c7cd7e7fad57 ("nd6: Add support for Optimistic DAD (RFC 4429)")
Differential Revision: https://reviews.freebsd.org/D55229
tcp/rack: reject unknown rate_sample_method values
The net.inet.tcp.rack.rate_sample_method sysctl is copied into every
new RACK connection but accepts any integer, while the
TCP_BBR_RACK_RTT_USE socket option only accepts USE_RTT_HIGH (0),
USE_RTT_LOW (1) and USE_RTT_AVG (2). With any other value,
tcp_rack_xmit_timer_commit() panics an INVARIANTS kernel on the first
RTT sample of each new connection ("Unknown rtt variant"). Without
INVARIANTS it returns early on every sample, so the connection never
updates its SRTT, RTTVAR or RTO.
Validate the sysctl with a handler that accepts only the three values
that the socket option accepts, and document the third value in the
sysctl description and in tcp_rack(4).
Reviewed by: tuexen
Co-authored-by: Claude Opus 5.5
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D62072
tcp/rack: range-check pace_max_seg sysctl and socket option
The net.inet.tcp.rack.pacing.pace_max_seg sysctl is a 32-bit integer,
but rack_init() copies it into each new connection's 7-bit bitfield
rc_user_set_max_segs. Values that do not fit are truncated, and a value
of 128 becomes 0. A connection with rc_user_set_max_segs of 0 ends up
with a pacing max segment size of 0, and rack_setup_fast_output() then
executes rounddown(left_to_send, 0), causing an integer divide fault:
Fatal trap 18: integer divide fault while in kernel mode
#5 rack_do_segment_nounlock+0x29eb
... (fault in rack_setup_fast_output() inlined into rack_output())
The TCP_RACK_PACE_MAX_SEG socket option clamps values above
MAX_USER_SET_SEG (63), but it accepts 0, which leads to the same
division by zero.
Validate the sysctl with a handler that only accepts 1 to
MAX_USER_SET_SEG, and reject a socket option value of 0 with EINVAL
[12 lines not shown]
tests/net/bpf: run the bpf:inject test with RSS again
1abb62867f2a skipped the test on RSS kernels because epair(4) delivered
the injected frames out of order. The reordering within a flow is fixed
in if_epair, but the test still failed in about one run in seven: the
first capture starts with the ARP request from ping(8), which is not an
IP packet and goes to the first epair queue, while the ICMP flow goes to
the queue its hash selects. Written back to back by the inject step,
the two may arrive in either order.
Add static ARP entries on both ends so that the captures hold only the
ICMP flow, and remove the skip. On an 8-CPU RSS kernel the test then
passed 250 of 250 runs with the if_epair fix and failed 26 of 150
without it.
While here, use the -j option of ifconfig(8), netstat(1) and arp(8)
instead of jexec(8).
Reviewed by: glebius, pouria
[2 lines not shown]
arp: Teach arp to attach and run itself in a jail
Add a -j jail option, which makes arp(8) attach to the named jail
before it does its work. This lets the host display and change the ARP
table of a vnet jail that does not have arp(8) installed, such as a
thin jail or a Linux jail. For example, `arp -j foo -an` or
`arp -j foo -d -a`.
The file given to -f is opened before attaching and processed inside
the jail, as sysctl(8) and ngctl(8) do. It must be a regular file or
a pipe, so that no directory or device descriptor is carried into the
jail. Host names are resolved inside the jail, as route(8) and
netstat(1) do.
Reviewed by: pouria, zlei, ziaee
MFC after: 1 week
Relnotes: yes
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D61725
fdescfs: descend through /dev/fd/N when mounted linrdlnk
Linux resolves a path below /proc/self/fd/N in the directory the
descriptor names, and linprocfs makes /proc/<pid>/fd a symlink to
/dev/fd. Under linrdlnk the fdescfs node carries only VV_READLINK,
which namei will not walk through, so such a path fails with ENOTDIR.
Return the underlying vnode from fdesc_lookup for a non-final component,
or a trailing slash, reusing the machinery the nodup option already
uses. The last component is untouched, so open("/dev/fd/N") keeps its
dup(2) semantic; a descriptor with no vnode behind it, such as a pipe,
yields ENOTDIR.
Add ATF coverage for traversal, descriptor reuse, and preservation of
last-component and mount-option semantics.
Approved by: adrian (mentor)
Reviewed by: kib, adrian
Differential Revision: https://reviews.freebsd.org/D59393
[2 lines not shown]