It is needed to invalidate cache in case of inode space removal
to avoid situation, when extents cache returns not exist extent.
Reviewed by: pfg
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D29931
(cherry picked from commit b3f4665639)
Adding a temporary workaround for plugging a fw_com upon if_fwip unloading.
Steps to reproduce(needs two hosts connected with firewire):
while true; do
ifconfig fwip0 10.0.0.5 up
fwcontrol -r
ping -c 10.0.0.3
kldunload if_fwip
done
There's a chance that the unloading of if_fwip.ko triggers following warning:
Warning: memory type fw_com leaked memory on destroy (1 allocations, 64 bytes leaked).
commit d79b6b8ec2 (origin/main, origin/HEAD)
(cherry picked from commit 25a5bb7318)
We already run `certctl rehash` at the end, there is no point in asking
users upgrading from 15.0 to 15.1 to manually merge the trust store.
MFC after: 3 days
Reviewed by: cperciva
Differential Revision: https://reviews.freebsd.org/D57028
(cherry picked from commit 2509ddee9b)
Reported by: Adam Crosser, Praetorian
Reviewed by: philip
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55812
(cherry picked from commit 9a9f93bcf1)
(cherry picked from commit 9f8db9cc67)
(cherry picked from commit a347e6e20e)
Reported by: Adam Crosser, Praetorian
Reviewed by: philip
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55811
(cherry picked from commit 097cb4e9f0)
(cherry picked from commit 4551ea3b3f)
(cherry picked from commit 6a808cd753)
Reported by: Calif.io in collaboration with Claude and Anthropic Research
Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55806
(cherry picked from commit 25cc459286)
(cherry picked from commit 6348a5fd0d)
(cherry picked from commit e61804ae63)
Reported by: Yuxiang Yang, Yizhou Zhao, Ao Wang, Xuewei Feng, Qi Li, and Ke Xu from Tsinghua University using GLM-5.1 from Z.ai
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D56976
(cherry picked from commit e68433e199)
(cherry picked from commit 0cef1a9ae5)
(cherry picked from commit 5e6b16f455)
Similar to glibc, define all the stdint.h macros such as `SIZE_MAX`,
`UINT64_C`, etc unconditionally. I.e. no longer check whether
`__STDC_CONSTANT_MACROS` or `__STDC_LIMIT_MACROS` are defined. See also
<https://sourceware.org/bugzilla/show_bug.cgi?id=15366>.
This is part of reverting base 00bee6fcd7, which reverted an upstream
libc++ commit that eliminated libc++'s stdint.h wrapper header.
Submitted by: Nikolas Klauser <[email protected]>
MFC after: 1 week
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D56746
(cherry picked from commit 966fb94cb3)
When operating on a file descriptor, acquire_lock() would ignore the
flags argument and always operate in non-blocking mode, resulting in
unnecessary busy-looping.
PR: 294832
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D56722
(cherry picked from commit d90513ea85)
Instead of printing the driver version over and over again if multiple
controllers are used, set a sysctl name for the used driver version.
Approved by: imp, ziaee
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D56110
(cherry picked from commit ea1764e5fc)
* Don't iterate over each string three times; once is enough.
* Reject control characters (anything below space) in addition to the
double quote and backslash.
* If an unsafe character is encountered, discard the string instead of
rejecting the entire lease.
* If backslashes are encountered in the file name option, convert them
to forward slashes instead of rejecting the option.
* Tweak the warning messages a bit. Looking through the rest of the
code, it seems to me that notes generally end with a period while
warnings generally don't.
Fixes: 8008e4b88d ("dhclient: Check for unexpected characters in some DHCP server options")
PR: 294886
MFC after: 1 week
Reviewed by: brooks, markj
Differential Revision: https://reviews.freebsd.org/D56740
(cherry picked from commit 873a195ba6)
The current arm64 PCPU implementation uses a global register asm
variable to use x18, which we reserve with -ffixed-x18, from C. Inside a
critical_enter() or sched_pin(), it is vital that any PCPU reads use the
right PCPU pointer, as often the whole point of the critical_enter() or
sched_pin() is to ensure consistent PCPU use (e.g. for SMR it relies on
zpcpu giving the same SMR state). critical_enter() and sched_pin() both
include atomic_interrupt_fence(), i.e. asm volatile("" ::: "memory"),
barriers to ensure that memory accesses don't get moved by the compiler
outside the critical section, which on most architectures will also
order the read of the PCPU pointer itself (whether due to the read being
another asm volatile statement, or due to using a segment-relative
memory access as on x86). However, this approach on arm64 is in no sense
a memory access, and therefore the register access is not ordered with
respect to the the critical_enter() or sched_pin(), or more specifically
the curthread->td_critnest++ / curthread->td_pinned++ within.
In practice upstream today this works out ok because the read of x18 is
inlined into the actual PCPU_GET/ADD/SET memory accesses (i.e. you will
get something like ldr xN, [x18, #imm-or-xM] for PCPU_GET, etc.), and
since *that* instruction is ordered properly due to being a memory
access, the x18 ends up being read in the right place. However, that is
not in any way guaranteed, it just relies on the hope that compiler
optimisations will be perfect at inlining the use. Moreover, PCPU_PTR is
definitely not a memory access in this world, it's just pointer
arithmetic on x18, and so that has nothing ordering it. This can be
observed with the following test function compiled into the kernel:
void
pcpu_test(void)
{
extern void __weak_symbol use_pcpu_ptr(void *);
critical_enter();
use_pcpu_ptr(PCPU_PTR(curthread));
critical_exit();
}
Obviously, this is a bit contrived as you could just read curthread
directly via its atomic definition that bypasses any worries about PCPU
atomicity, but it illustrates the point. With the in-tree LLVM*, this
ends up being compiled for me to:
paciasp
stp x29, x30, [sp, #-0x10]!
mov x29, sp
ldr x8, [x18]
ldr w9, [x8, #0x4fc]
mov x0, x18
add w9, w9, #0x1
str w9, [x8, #0x4fc]
bl use_pcpu_ptr
...
Note that, although the PCPU_PTR was within the critical section in the
C source, the read of x18 into x0, the argument register passed to
use_pcpu_ptr, has been hoisted to before the str, which is storing the
new, incremented, value of td_critnest to curthread, and so there is a
window within which we have to hope the thread is not preempted and
migrated to a different CPU, otherwise it will pass a pointer to the
wrong CPU's pc_curthread PCPU member.
Initially it would seem as though the solution to this would be to add
an additional barrier to critical_enter() / sched_pin() to ensure the
register reads could not be hoisted like this. However, I have not been
able to find a sequence that works reliably across both GCC and Clang,
independent of optimisation level. Using inline asm with x18 marked as a
clobber, using "=r"(pcpup), and using "+r"(pcpup) all run into various
issues; some combinations don't actually seem to be a barrier, and for
Clang at -O0 some combinations will actually generate writes to x18**,
at which point you then have to hope that the kernel is compiled with
optimisations, and that the redundant writes are optimised away such
that x18 is just passed through. But that just gets us back to hoping
optimisation works, which isn't a solution to the problem, it just
trades one point of fragility for another.
In talking to GCC developers, who seemed rather horrified by the
implications of trying to do this (which is effectively "register
volatile", a combination that's explicitly forbidden), we could not find
a solution to this, and so I have concluded that the only reliable to
have a sound PCPU implementation is to ditch this optimisation and
follow other non-x86 architectures in using inline asm in one form or
another; specifically, this adopts riscv's approach of just calling
get_pcpu(), which, curiously, was already implemented in inline asm here
on arm64, rather than reading pcpup.
Anyone who feels strongly enough about PCPU performance is welcome to
try to find a working approach, but such proposals should be heavily
scrutinised to be certain that they won't come back to bite us in
future. In particular, this caused a lot of problems downstream in
CheriBSD's experimental compartmentalised kernel, which is trialling
interposing on PCPU accesses in order to restrict access within
compartments. As a result, even PCPU_GET/SET/ADD can look like PCPU_PTR,
as they pass an opaque PCPU reference to wrapper functions, and so this
case gets hit all over the kernel, giving highly-confusing panics with
locks that aren't owned by the current thread or SMR use allegedly not
within an smr_enter().
The ia64 port encountered the same issue and reached the same conclusion
in e31ece45b7 ("Fix the PCPU access macros."), though went to the
trouble of trying to fold the offset into the inline assembly (assuming
it fit, with no fallback if not, since it's using the add pseudo-op that
will be expanded to either adds with a 14-bit immediate or, if somehow
that doesn't fit, addl with a 22-bit immediate). Curiously though it
left pcpup around as a footgun. sparc64 had similar code but was never
fixed. It also defined a curpcb in the same manner which was presumably
similarly broken, but looks to have been entirely unreferenced from C,
only referenced in actual assembly files. Alpha also had the same
design, but it was removed whilst critical_enter() was extern rather
than static inline so uses of the pointer could not have been hoisted,
and whilst sched_pin() didn't have any form of atomic_interrupt_fence()
to even try to make PCPU well-ordered.
* At time of writing, when that was LLVM 19, not verified at time of
commit with LLVM 21.
** For "+r"(pcpup), Clang's initial code generation is to do:
mov xTtmp1, x18
mov x18, xTmp1
/* asm (empty) */
mov xTmp2, x18
mov x18, xTmp2
since its interpretation of what that means is "read the value of
pcpup, and make sure that value is in x18 for the duration of the
assembly due to the asm("x18") on pcpup", and similarly for the output
side.
Reviewed by: andrew, jhb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D56601
(cherry picked from commit 551d47c567)
bi_load itself loads various things into the staging area which can
cause it to grow, which may result in the staging area moving, including
the kernel. Therefore the address we get for the kernel entry point
prior to bi_load may not be correct afterwards when we actually call it,
and so we must defer the translation.
On arm and riscv (but not arm64, which predates both of them in
loader.efi and did not gain a copy of arm's added printf when arm
support was added) we also printf this entry point to the console, which
we can no longer do since bi_load calls ExitBootServices, so remove this
printf that, in practice, seems to not be so useful, given nobody ever
felt the need to add it to arm64. If anyone really feels this is an
important printf to have then bi_load will need to be split so we can
call printf after all the loading and potential reallocation of the
staging area, but before ExitBootServices is called.
We may also want to make this code more uniform and shared between the
three architectures here, since there isn't much architecture-specific
about this (and something like the RISC-V boot hart protocol could
easily be made an MD hook).
Reviewed by: imp
Fixes: 0cafabf97f ("Add support for arm64 to loader.efi and boot1.efi")
Fixes: ea7796a9ae ("EFI: don't call printf after ExitBootServices, since it uses Boot Services")
Fixes: 2192efc03b ("RISC-V boot1.efi and loader.efi support")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D56431
(cherry picked from commit ab1d659e78)
* Get certdata.txt directly from the NSS Mercurial repository, rather
than from the Mozilla Firefox repository which imports it from NSS at
irregular intervals.
* Instead of always fetching the latest certdata.txt, fetch a specific
version. For this commit, we set this to the version that was last
imported in May 2025.
* Add a refrence to the MPL to the generated files.
* Regenerate with latest OpenSSL. This is purely cosmetic; mostly, the
certificate names now contain less unnecessary whitespace and some
elements are quoted.
MFC after: 1 week
Reviewed by: michaelo, kevans
Differential Revision: https://reviews.freebsd.org/D56620
(cherry picked from commit ce33d6396a)
Until now, the untrusted directory has been maintained manually. Modify
the script used to maintain the trusted directory so it can handle both.
While here, clean it up a bit.
MFC after: 1 week
Reviewed by: mandree, markj
Differential Revision: https://reviews.freebsd.org/D51774
(cherry picked from commit b88b0bb784)
This was encountered on a Gigabyte GA-P55A-UD4 motherboard identifying itself
as:
ahci0@pci0:2:0:0: class=0x01018f rev=0x11 hdr=0x00 vendor=0x1b4b device=0x91a3 subvendor=0x1458 subdevice=0xb000
vendor = 'Marvell Technology Group Ltd.'
class = mass storage
subclass = ATA
The physical chip has "88SE9128-NAA2" printed on it.
Similar code has been in Linux for a long time:
https://github.com/torvalds/linux/commit/50be5e3657cd2851a297dc0b3fd459f25829d29b
Co-authored-by: Michael Osipov <[email protected]>
PR: 288526
Reviewed by: jhb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D56464
(cherry picked from commit c72edc2b2e)
nvlist_check_header() validated nvlh_size for overflow before
performing conversion. An mallicous user can set
NV_FLAG_BIG_ENDIAN in the header and craft nvlh_size so that
the orginall value passes the check, but after the conversion the
sizeof(nvlist_header) + size can overflow.
This can lead to a heap buffer overflow.
Approved by: so
Security: FreeBSD-SA-26:17.libnv
Security: CVE-2026-35547
Fixes: 36fa90dbde
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D56342
The previous implementation used FD_SET() on a stack-allocated fd_set,
which is an out-of-bounds write whenever the socket fd is >= FD_SETSIZE
(1024).
Approved by: so
Security: FreeBSD-SA-26:16.libnv
Security: CVE-2026-39457
Reported by: Joshua Rogers of AISLE Research Team (https://aisle.com/)
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D56689
As per RFC5061 "4.2. New Parameter Types" the add/delete IP address
parameters (0xc001, 0xc002) may not be present in an INIT or INIT-ACK
chunk. They are only allowed to be present in an ASCONF chunk.
This also prevents unbounded recursion while parsing an SCTP packet.
Approved by: so
Security: FreeBSD-SA-26:14.pf
Security: CVE-2026-7164
PR: 294799
Reported by: Igor Gabriel Sousa e Souza
MFC after: 3 days
Sponsored by: Orange Business Services
When the number of DHCP options exceeds a threshold, script_set_env()
will reallocate the environment, stored as an array of pointers. The
calculation of the array size failed to multiply by the pointer size,
resulting in a smaller than expected buffer which admits out-of-bounds
writes.
Approved by: so
Security: FreeBSD-SA-26:15.dhclient
Security: CVE-2026-42511
Reported by: Joshua Rogers of AISLE Research Team (https://aisle.com/)
Some options are written directly to the lease file, which may be parsed
by subsequent dhclient invocations. We must make sure that a malicious
server can't control the "medium" field of a lease definition, otherwise
they can achieve RCE by injecting one into the lease file, whereupon it
will be passed to dhclient-script, which passes it through eval.
Approved by: so
Security: FreeBSD-SA-26:12.dhclient
Security: CVE-2026-42511
Reported by: Joshua Rogers of AISLE Research Team (https://aisle.com/)
The buggy version allowed userspace to overflow the copy into adjacent
execve KVA regions, which enables, among other things, injecting
environment variables into privileged processes.
Approved by: so
Security: FreeBSD-SA-26:13.exec
Security: CVE-2026-7270
Reported by: Ryan Austin of Calif.io
Reviewed by: brooks, kib
Fixes: f373437a01 ("Add helper functions to copy strings into struct image_args.")
Differential Revision: https://reviews.freebsd.org/D56665
so=\E[3m (italic) is incorrect, should be so=\E[7m (reverse video).
se=\E[23m (italic off) is incorrect, should be se=\E[27m (reverse off).
mr=\E[7m (reverse video) is correctly defined in the same entry.
screen-256color inherits from screen via tc=screen and is fixed
transitively.
PR: 294499
Pull Request: https://github.com/freebsd/freebsd-src/pull/2139
Signed-off-by: Dan Mahoney <[email protected]>
(cherry picked from commit 2bff747bb0)
Improve mfi_pd_inq_string() by
* Reusing buffer sizes from cam/cam.h according to SCSI specification + NULL byte
* Don't truncate vendor-specific information by escaping into a too small buffer
* Use cam_strvis() from libcam instead of old, outdated local copy
* Recaculate size of inq_string based on the reused buffer sizes and
format statements
PR: 294354
Reviewed by: imp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D56328
(cherry picked from commit 850eb149e7)
The example provided puts the semicolon in the wrong place. It must
come after the file:// specification, not in it.
(cherry picked from commit f5d0b30e4a)
ping6 needs IPV6_RECVPKTINFO and IPV6_RECVHOPLIMIT to process
incoming replies. When these options fail, replies are silently
dropped and ping6 appears to hang. Use err(3) instead of warn(3)
so the user gets a clear error and immediate exit.
Signed-off-by: Christos Longros <[email protected]>
Reviewed by: pouria, jlduran, glebius
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D56237
(cherry picked from commit 9a4a9f623b)
This code was not being built due to errors in our libarchive
configuration. Now that those have been addressed, staticize some
variables that trip a “no previous extern declaration” error. This
is a subset of upstream PR 2962.
MFC after: 1 week
Reviewed by: mm
Differential Revision: https://reviews.freebsd.org/D56471
(cherry picked from commit 7e9d974bc0)
Several testcases assume BLOCKSIZE=K, so set it at the top of the
script. This fixes an issue where the tests would sometimes fail
when run under sudo.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D56476
(cherry picked from commit d618ba314d)
pmap_pkru_update_range() did not handle the case where a PDPE has PG_PS
set. More generally, the SET_PKRU and CLEAR_PKRU sysarch
implementations did not check whether the request covers a "boundary" vm
map entry. Fix this, add the missing PG_PS test, and add some tests.
Approved by: so
Security: FreeBSD-SA-26:11.amd64
Security: CVE-2026-6386
Reported by: Nicholas Carlini <[email protected]>
Reviewed by: kib, alc
Differential Revision: https://reviews.freebsd.org/D56184
The TIOCNOTTY handler detaches the calling process from its controlling
terminal. It clears the link from the session to the tty, but not the
pointers from the tty to the session and process group. This means that
sess_release() doesn't call tty_rel_sess(), and that pgdelete() doesn't
call tty_rel_pgrp(), so the pointers are left dangling.
Fix this by clearing pointers in tty_drop_ctty(). Add a standalone
regression test.
Approved by: so
Security: FreeBSD-SA-26:10.tty
Security: CVE-2026-5398
Reported by: Nicholas Carlini <[email protected]>
Reviewed by: kib, kevans
Fixes: 1b50b999f9 ("tty: implement TIOCNOTTY")
Differential Revision: https://reviews.freebsd.org/D56046
The correct path is /etc/defaults/rc.conf (defaults in plural).
Reviewed by: netchild
Fixes: cc4eb1ea10 ("Add support for a /etc/defaults/vendor.conf override file")
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D56456
(cherry picked from commit 8e08080ee5)
Focus on the MRQE field of the MRQC register, which is 4 bits wide,
and we use these 3 types of values.
- IXGBE_MRQC_RSSEN 0x1 (non VF mode)
- IXGBE_MRQC_VMDQRSS32EN 0xA (less than 33 VFs)
- IXGBE_MRQC_VMDQRSS64EN 0xB (less than 65 VFs)
If we always take a bitwise OR with IXGBE_MRQC_RSSEN,
IXGBE_MRQC_VMDQRSS32EN will never be chosen.
Select these 3 types of values for the proper case.
Signed-off-by: Yuichiro NAITO <[email protected]>
Pull Request: https://github.com/freebsd/freebsd-src/pull/2132
(cherry picked from commit 938c076b9b)
Both (U)EFI and BIOS are completely different things, be precise and don't use
them together.
Reviewed by: imp
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D56329
(cherry picked from commit 4f684e929d)
- When allocating a page, we should only consider the PG_ZERO flag when
handling the top-level page.
- Unconditionally reset the flag when restarting the fault handler.
Previously, vm_fault_busy_sleep() would fail to reset it.
PR: 294039
Reviewed by: kib
Tested by: Peter Much <[email protected]>
MFC after: 3 days
Fixes: cff67bc43d ("vm_fault: only rely on PG_ZERO when the page was newly allocated")
Differential Revision: https://reviews.freebsd.org/D56234
(cherry picked from commit 04132e0100)
When registering a new kevent backed by a file descriptor, we first look
up the file description with fget(), then lock the kqueue, then see if a
corresponding knote is already registered. If not, and KN_ADD is
specified, we add the knote to the kqueue.
closefp_impl() interlocks with this process by calling knote_fdclose(),
which locks each kqueue and checks to see if the fd is registered with a
knote. But, if userspace closes an fd while a different thread is
registering it, i.e., after fget() succeeds but before the kqueue is
locked, then we may end up with a mismatch in the knote table, where the
knote kn_fp field points to a different file description than the knote
ident.
Fix the problem by double-checking before registering a knote. Add a
new fget_noref_unlocked() helper for this purpose. It is a clone of
fget_noref(). We could simply use fget_noref(), but I like having an
explicit unlocked variant.
PR: 293382
Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D55852
(cherry picked from commit 8f3227f527)
* cd9660_rrip_slink() did not check that the lengths of individual
entries do not exceed the length of the overall record.
* cd9660_rrip_altname() did not check that the length of the record
was at least 5 before subtracting 5 from it.
Note that in both cases, a better solution would be to check the length
of the data before calling the handler, or immediately upon entry of
the handler, but this would require significant refactoring.
MFC after: 1 week
Reported by: Calif.io in collaboration with Claude and Anthropic Research
Reported by: Adam Crosser, Praetorian
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D56215
(cherry picked from commit d0afead876)
GEOM journaling shouldn't be used at the same time as soft updates, so
don't enable one if the other is already in use.
MFC after: 1 week
PR: 293896
Reviewed by: mckusick
Differential Revision: https://reviews.freebsd.org/D56002
(cherry picked from commit b1f72dd2a9)
GEOM journaling shouldn't be used at the same time as soft updates, so
don't enable soft updates if GEOM journaling has been requested, and
error out if both are explicitly requested.
MFC after: 1 week
PR: 293896
Reviewed by: mckusick
Differential Revision: https://reviews.freebsd.org/D55999
(cherry picked from commit e30fcdaae2)
Bug Fixes:
* Verify that an ENA ring is in netmap only in native mode
Minor Changes:
* Move parenthesis to correct place in switch
* Add comment
* Reorder define
Reviewed by: cperciva
Differential Revision: https://reviews.freebsd.org/D55698
Sponsored by: Amazon, Inc.
(cherry picked from commit 96c5eaf0ac)
netmap operates in two modes:
1) Emulated - netmap handling is done by the network stack, the
NIC driver operates transparently to netmap.
2) Native - netmap management is done by the NIC driver.
When checking whether a specific ENA ring is running in netmap
mode, only the following checks were done:
1. IFCAP_NETMAP - Check whether netmap capability is enabled on
the device.
2. NKR_NETMAP_ON - Check whether netmap is actively using this
ring.
The above checks implied that the netmap mode is native and the
ENA driver needs to handle the netmap logic.
The code was missing an explicit check on whether native mode
is actually on (NAF_NATIVE).
This led to a case where though emulated mode was used and
a netmap application was turned on, the ENA driver still managed
netmap logic partially and caused missing buffers and lack of
refill as part of the datapath.
Note: Enabling netmap emulated mode is insufficient and there's
a need to load a netmap program in order to trigger this use-case.
Add an explicit check of whether NAF_NATIVE mode is set.
The issue was reported in [1].
[1]: https://github.com/amzn/amzn-drivers/issues/361
Fixes: 358bcc4c6c ("Add support for ENA NETMAP partial initialization")
Reviewed by: cperciva
Differential Revision: https://reviews.freebsd.org/D55697
Sponsored by: Amazon, Inc.
(cherry picked from commit 97e84c587d)
1. Move parenthesis to correct place in switch and fix include order
2. Add comment at the end of an ifdef for clarity
3. Change include order.
Reviewed by: cperciva
Differential Revision: https://reviews.freebsd.org/D55696
Sponsored by: Amazon, Inc.
(cherry picked from commit 2667a8454c)
If this eventually poses a problem for unsupported branches we can fix
them directly.
Sponsored by: Innovate UK
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D53838
(cherry picked from commit 1e18927957)
We could patch the tzcode config to not use it, but it's simple to
provide an implementation of it and avoid spreading cross-build
bootstrapping special cases.
Fixes: ff2c98b30b ("tzcode: Update to 2026a")
MFC after: 1 week
(cherry picked from commit 47402c9422)
Normally, syslogd reacts only to SIGTERM, and ignores SIGINT and SIGQUIT
unless in debug mode. Extend that to also apply when running in the
foreground.
MFC after: 1 week
Reviewed by: jfree
Differential Revision: https://reviews.freebsd.org/D55886
(cherry picked from commit 828de702ad)
* Stop abbreviating macro names half-randomly to 8 chars, this is no
longer 1990.
* Likewise for function names (in particular use doindex for a function
that is notably different from the classic index function).
* Rename a few things for more fidelity: eval is the builtin name, not
expr and your maketemp/mkstemp conform to mkstemp semantics for better
security.
* Rewrap a few comments that were ludicrously short.
No functional changes except improved accuracy of some error messages.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D55793
(cherry picked from commit f8f6f1cbd5)
This allows libmagic to recognize the FS_DOSOFTDEP, FS_SUJ, FS_GJOURNAL,
FS_ACLS, and FS_NFS4ACLS flags on a UFS2 file system.
Accepted upstream as 482259e5e952.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D56010
(cherry picked from commit fa03f93e88)
svc_rpc_gss_validate() copies the input message into a stack buffer
without ensuring that the buffer is large enough. Sure enough,
oa_length may be up to 400 bytes, much larger than the provided space.
This enables an unauthenticated user to trigger an overflow and obtain
remote code execution.
Add a runtime check which verifies that the copy won't overflow.
Approved by: so
Security: FreeBSD-SA-26:08.rpcsec_gss
Security: CVE-2026-4747
Reported by: Nicholas Carlini <[email protected]>
Reviewed by: rmacklem
Fixes: a9148abd9d
(cherry picked from commit 143293c14f)
There's been a problem where rules which differed only in address ranges
were considered duplicates and not added. Test for this.
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
(cherry picked from commit ab74151e8d)
It should be decreased only when the interface has been successfully
removed from the "active" list.
This prevents vnet_if_return() from potential OOB writes to the
allocated memory "pending".
Reviewed by: kp, pouria
Fixes: a779388f8b if: Protect V_ifnet in vnet_if_return()
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D55873
(cherry picked from commit 8065ff63c0)
(cherry picked from commit 1b7687f053)
(cherry picked from commit 47339e4a92)
Some 32-bit architectures, e.g., armv7, require strict 8-byte
alignment while doing atomic 64-bit access. Hence aligning to the
pointer type (4-byte alignment) does not meet the requirement on
those architectures.
Make the space allocated by vnet_data_alloc() sufficent aligned to
avoid unaligned access.
PR: 265639
Diagnosed by: markj
Reviewed by: jhb, markj
Co-authored-by: jhb
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D55560
(cherry picked from commit 32beb3ae71)
(cherry picked from commit 973d607b28)
(cherry picked from commit baee504b86)
Set a 120-second receive timeout on all client connections, and add a
command-line option to change that value.
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D55400
(cherry picked from commit 56fbfd1ecd)
* Check for integer overflow when receiving file sizes.
* Check for buffer overflow when receiving file names, and fully
validate the names.
* Check for integer overflow when checking for available disk space.
* Check for I/O errors when sending status codes.
* Enforce one job per connection and one control file per job (see
code comments for additional details).
* Simplify readfile(), avoiding constructs vulnerable to integer
overflow.
* Don't delete files we didn't create.
* Rename read_number() to read_minfree() since that's all it's used
for, and move all the minfree logic into it.
* Fix a few style issues.
PR: 293278
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D55399
(cherry picked from commit 9065be0a59)
This is necessary for use with supervision, e.g. runit.
I chose -F simply because that is what the folks at LPRng use.
Approved by: pfg, gad, ngie
Differential Revision: https://reviews.freebsd.org/D29566
(cherry picked from commit 3c63660670)
Our manual page currently states that system() will return 127 if it
fails to execute the shell. The actual return value is, to quote POSIX,
“as if the command language interpreter had terminated using exit(127)
or _exit(127)”.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: bnovkov, kevans
Differential Revision: https://reviews.freebsd.org/D55483
(cherry picked from commit 7305604b29)
This corresponds to Linux f74dc880098b4a29f76d756b888fb31d81ad9a0c
That commit does not provide any public background detail, but it's been
in use for over 5 years and corresponds to previous chip bugs w.r.t.
automatic generation of PAUSE frames.
Reviewed by: kgalazka
Differential Revision: https://reviews.freebsd.org/D54555
(cherry picked from commit 2bdec2ee73)
On ifnet attaching, ether_ifattach() makes the link-layer address by
shadow copying the ha->primary_mac. Well, the link-layer address will
not be altered during attaching, thus it is pointless to copy it back.
No functional change intended.
Reviewed by: kbowling
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D54883
(cherry picked from commit 4ac3081b28)
(cherry picked from commit 23ffd1650c)
(cherry picked from commit 7d7cee09b9)
The hardware can count statistics and the driver has already retrieved
them via qlnx_get_counter().
Advertise the IFCAP_HWSTATS capability to avoid the net stack from
double counting IFCOUNTER_IBYTES.
Reviewed by: kbowling
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D51451
(cherry picked from commit 386960a880)
(cherry picked from commit bfbb93b6de)
While attaching the qlnx driver we can end up trying to call ifmedia functions
before those are set up (through ether_ifattach() -> rtnl_handle_ifattach()
-> dump_iface() -> get_operstate_ether() -> ifmedia_ioctl()). Postpone the
ether_ifattach() until after the ifmedia setup.
Reviewed by: markj,zlei
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D50819
MFC note: qlnxe(4) does not exhibit panic at startup on stable/13, but
there's a small windows that the setup of ifmedia has not been done but
other threads try to access the ifmedia, since the ifnet is public
visible on ether_ifattach(). Postpone ether_ifattach() until after the
ifmedia setup to prevent that.
(cherry picked from commit 4f7473d18a)
(cherry picked from commit 8ef7ad95e9)
If socket() fails because the address family or protocol is unsupported,
just continue with the next address.
MFC after: 1 week
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D55407
(cherry picked from commit b5d570e711)
This fixes an issue where the first address that DNS returns is blocked
by a packet filter, so we hang for a while, then the user hits Ctrl-C,
interrupting connect(2), whereupon we move on to the next address, get
a connection, request the file, and return to fetch(1), which sees that
SIGINT was caught and bails.
Note that we make no attempt to enforce fetchTimeout in the connection
phase, and never have. It's feasible, but non-trivial, so we'll leave
it as an exercise for future us.
PR: 293312
MFC after: 1 week
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D55406
(cherry picked from commit afbdcd402b)
* Provide a wrapper for the common if (verbose) fetch_info(...) idiom.
* Replace remaining instances of fprintf(stderr, ...) with fetch_info().
* Fix a few style nits.
MFC after: 1 week
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D55405
(cherry picked from commit 1b7c4d29fd)
According to POSIX, the optional third argument is the minimum number
of digits to print regardless of sign. We interpreted it as the minimum
width of the output including the sign. Additionally, the variable used
to hold this value was confusingly named “maxdigits”.
PR: 293214
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D55311
(cherry picked from commit 507c611aea)
When operating the multicast MAC filters, the current usage of
ECORE_FILTER_ADD and ECORE_FILTER_REMOVE are rather misleading.
ECORE_FILTER_ADD reads "adding new filter", but it actually removes
any existing filters and then addes a new one. ECORE_FILTER_REMOVE
reads "removing a filter", but it actually removes all filters.
Let's use ECORE_FILTER_REPLACE and ECORE_FILTER_FLUSH instead to
avoid confusion.
In the current implementation, only one MAC address is passed to
ecore_sp_eth_filter_mcast() and any previously installed filters are
removed, hence it breaks the multicast function. That can be observed
via either assigning new IPv6 addresses to the interface or putting
the interface as a member of lagg(4) interface with LACP aggregation
protocol. Fix that by calculating the multicast filter bins directly
from multicast MAC addresses and replace the filters every time
the bins changes.
Due to the nature of the multicast filter, which is hash based, a
full 1's multicast filter bin means all multicast packets are to be
accepted. Thus there's no need to make the vport into allmulti mode
when the number of multicast MAC addresses exceeds the limit
(ECORE_MAX_MC_ADDRS, 64).
Tested with a FastLinQ QL41212HLCU 25GbE adapter, both MFW_Version
8.35.23.0 and 8.59.16.0 are tested.
Note: Currently the VF port is set to promiscuous mode unconditionally,
and the setting of the multicast MAC filters for VF ports is
short-circuited, so the VF port functions as it did.
PR: 265857
PR: 290973
Reviewed by: kbowling
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D54892
(cherry picked from commit 70256d2b86)
(cherry picked from commit 0cfc1145cd)
(cherry picked from commit 87942d7f8f)
Currently only the packets in the RX path can be captured by tcpdump
as the ETHER_BPF_MTAP call in the TX path is missing. Add it so that
packets in both directions can be captured.
PR: 290973
Reviewed by: kbowling
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D54891
(cherry picked from commit 968647502e)
(cherry picked from commit 425b9cec0b)
(cherry picked from commit ddfe98e8cc)
There are two entry points to set the promiscuous and allmulti mode.
One is ioctl, and another is the init routine. Given they share almost
the identical logic, refactor a little to make the code more clear.
While here, for the ioctl, translate the error to EINVAL to avoid
confusing the net stack.
Reviewed by: kbowling
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D54890
(cherry picked from commit 45b1718fad)
(cherry picked from commit b8d2c1c367)
(cherry picked from commit 00ab0df793)
Since the change [1], the init routine qlnx_init() works as intended.
Let ether_ioctl() handle SIOCSIFADDR to simplify the code.
Combined with the change [1], this shall be a better fix for PR 287445.
[1] c10e6bc0f0 qlnxe: Avoid reinitializing the interface when it is already initialized
PR: 287445
Reviewed by: kbowling
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D54888
(cherry picked from commit 4012b63889)
(cherry picked from commit 0f383f74b7)
(cherry picked from commit 20ffe22fcf)
qlnx_init_locked() unconditionally uninitialize the interface thus is
actually reinitializing the interface. Well the init routine qlnx_init()
is to initialize the interface by net stack when assigned with the first
inet or inet6 address. The ioctl SIOCSIFADDR for the first inet6 address
is handled by ether_ioctl() thus the interface is reinitialized no matter
it was initialized or not.
Add a driver status check for that to avoid reinitializing. Further plan
is removing SIOCSIFADDR ioctl from the driver and let ether_ioctl() handle
it.
Reviewed by: kbowling
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D54887
(cherry picked from commit c10e6bc0f0)
(cherry picked from commit 8731ff4871)
(cherry picked from commit ee64955809)
The driver-managed status flags should be lock protected to be touched.
Also this can serialize ioctls those check the IFF_DRV_RUNNING status.
Reviewed by: kbowling
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D54886
(cherry picked from commit 0df8a998a9)
(cherry picked from commit 285b25c080)
(cherry picked from commit 6e5b12acb6)
When an Ethernet interface is added to lagg(4) as a child interface, its
type, aka if_type, is changed from IFT_ETHER to IFT_IEEE8023ADLAG. Well
changing the link-layer address of the lagg(4) interface will be
propagated to all child interfaces, hence the drivers of child interfaces
shall not presume the type of the interface will not be changed.
Meanwhile, on initializing, an ifnet has been fully attached and it is
guaranteed to have non-null link-layer address so stop NULL checking for
it.
Reviewed by: kbowling
Fixes: 792226e530 qlnxe: Allow MAC address override
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D54885
(cherry picked from commit f250852c9a)
(cherry picked from commit 6d138e958f)
(cherry picked from commit 93719f8c83)
In case the device is VF, qlnx_get_mac_addr() returns ha->primary_mac
hence it ends up memcpy with same source and destination. Refactor
slightly to avoid that.
Reviewed by: kbowling
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D54884
(cherry picked from commit 3aeeedc7e0)
(cherry picked from commit 6462189595)
(cherry picked from commit ea1143bddb)
"trim /dev/da*" would print the following line multiple times
when given multiple agruments:
dry run: add -f to actually perform the operation
Print it once before looping over arguments.
Also, note possible suffixes P and E after offset/length
as per expand_number(3).
(cherry picked from commit 5d58486480)
(cherry picked from commit f1b934c813)
sifpidx (an interface name) cannot extend beyond the end of the
fr_names buffer.
We do the validation for fr_sifpidx here because it is a union that
contains an offset only when fr_sifpidx points to an interface name,
an offset into fr_names. The union is an offset into fr_names in this
case only.
interr_tbl now becomes a static variable outside a function to facilitate
its use by two functions within fil.c
Note that sifpidx is only used in ipf_sync() which implments ipf -y.
Reported by: Ilja Van Sprundel <[email protected]>
MFC after: 1 week
(cherry picked from commit 47fb51847f)
The destination buffer is FR_GROUPLEN (16 bytes) in length. When
gname is created, the userspace utilities correctly use FR_GROUPLEN
as the buffer length. The kernel should also limit its copy operation to
FR_GROUPLEN bytes to avoid any user written code from exploiting this
vulnerability.
Reported by: Ilja Van Sprundel <[email protected]>
(cherry picked from commit e40817302e)
Following up ziaee's pattern, and add andy's line.
I'm not sure whether the original commit bit creation date should be used,
and use commit bit re-activation date for now.
MFC after: 1 week
(cherry picked from commit 0d9b5db9fc)
Once upon a time, 32-bit PowerPC did indeed have a 32-bit time_t, but
FreeBSD 12.0 switched to a 64-bit time_t for PowerPC as an ABI break,
which predates the addition of FreeBSD support to OpenZFS. Moreover,
64-bit PowerPC has existed since FreeBSD 9.0, where __powerpc__ is also
defined (alongside __powerpc64__ to disambiguate), which has always had
a 64-bit time_t. This code has therefore always been wrong for all
PowerPC variants. Fix this by limiting the 32-bit case to just i386,
which is the only architecture in FreeBSD to have a 32-bit time_t and
not have broken ABI, due to its special legacy compatibility status.
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Signed-off-by: Jessica Clarke <[email protected]>
Closes#18217Closes#18218
Reported by: fuz
MFC after: 1 day
(cherry picked from commit 45c1e44779)
PR: 293124
MFC after: 1 week
Fixes: 792ef1ae7b ("Refactor fetch_connect() and fetch_bind() to improve readability and avoid repeating the same DNS lookups.")
Reverts: 8f8a7f6fff ("libfetch: apply timeout to SSL_read()")
Reviewed by: eugen, imp
Differential Revision: https://reviews.freebsd.org/D55293
(cherry picked from commit 73b82d1b0a)
(insta-mfc requested by re@)
pw.8 structure is quite different from usual manual page, especially in
describing -o option usage. Specifically, these paragraphs do not
contain "uid/gid" terms, and have "user id"/"group id" instead,
making searching for "override duplicate safety belt" difficult.
Try to simplify such searches.
Also, clarify uid/gid space between 100 and 1000 as "somewhat special",
as it actually is.
Discussed on: russian telegram FreeBSD group
Reviewed by: eugen, novel
MFC after: 1 week
(cherry picked from commit e89454417b)
The -r flag is not required to compare two directories; it is only
required to compare them recursively, i.e. descend into their common
subdirectories. Adjust tests that use -r needlessly, and adjust the
dirloop test to verify that these two cases remain distinct.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D55262
(cherry picked from commit b253243297)
POSIX uses the terms “positive decimal integer” for -C and “non-negative
decimal integer” for -U, which translates into lower bounds of 1 for -C
and 0 for -U.
POSIX does not specify a minimum upper bound for either mode, but as of
5fc739eb59 both our backends support context sizes up to and including
INT_MAX, so use that.
Having had the opportunity to consult the Unix System Test Suite, the
diff test cases found therein happen to precisely match these bounds.
While here, switch to using strtonum() to parse numerical arguments, and
try to be more consistent in how we report usage errors.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D55261
(cherry picked from commit 790f1d1cc5)
Check the length of the hook name when copying it into the sockaddr.
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D55258
(cherry picked from commit 585190dff4)
The daemon utility has always created its output file with a fixed mode
of 0600. This causes issues for log collection setups where the collector
does not run as root but instead relies on group access to the watched
daemon’s log file.
Introduce a new option that allows specifying the output file mode using
install(1)-style semantics. This enables non-root log collectors to access
the file as intended and improves compatibility with log rotation tools.
Reviewed by: kevans
MFC after: 1 week
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D54930
(cherry picked from commit a3b90a1f00)
When we're done processing a directory, remove its entry from the tree
of visited inodes, ensuring that we only report a loop when we encounter
a descendant-to-ancestor link, not when we encounter a cousin-to-cousin
or sibling-to-sibling link.
MFC after: 1 week
Reported by: Bakul Shah <[email protected]>
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D55248
(cherry picked from commit 71569594d8)
Both copy_file_range() and read() / write() in our fallback loop can be
interrupted before copying anything at all, in which case it returns -1
and sets errno to EINTR. If that happens, we should retry, not fail.
While here, drop the size argument from copy() (we always want to copy
the entire file anyway) and add test cases which exercise the metalog
and digest functionality.
PR: 293028
MFC after: 1 week
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D55168
(cherry picked from commit 0fb940fd63)
Both copy_file_range() and copy_fallback() can be interrupted before
they have read anything at all, in which case they return -1 and set
errno to EINTR. If that happens, we should retry, not fail.
PR: 293028
MFC after: 1 week
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D55167
(cherry picked from commit 7aa30669d6)
In base 8f0a6a9aad, usr/share/examples/drivers was cleaned up,
because it contained unmaintained scripts. The directory itself is
cleaned up by ObsoleteFiles.inc, but there was still an entry in
BSD.usr.dist that re-created the directory. Remove it.
Fixes: 8f0a6a9aad
MFC after: 3 days
(cherry picked from commit ac2f284258)
* Drop the ssl_meth member, there is no reason to hang on to it.
* Replace deprecated SSLv23_client_method() with TLS_client_method().
* Check the return value from SSL_CTX_new().
MFC after: 1 week
PR: 292903
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D55098
(cherry picked from commit 4e160c6197)
This change removes pre-OpenSSL 1.1 supporting code and removes/adjusted
preprocessor conditionals which were tautilogically true as FreeBSD main
has shipped with OpenSSL 1.1+ for some time.
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D40711
(cherry picked from commit bc1027a778)
As of OpenSSL 1.1 SSL_library_init() and SSL_load_error_strings() are
deprecated. There are replacement initialization functions but they do
not need to be called: "As of version 1.1.0 OpenSSL will automatically
allocate all resources that it needs so no explicit initialisation is
required."
Wrap both calls in an OPENSSL_VERSION_NUMBER block.
PR: 271615
Reviewed by: Pierre Pronchery <[email protected]>
Event: Kitchener-Waterloo Hackathon 202305
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40265
(cherry picked from commit 01aee8c92d)
Sponsored by: Klara, Inc.
Fixes: 5fc739eb59 ("diff: Fix integer overflows in Stone algorithm")
Fixes: 270492602b ("diff: Add test case for pagination resource leak")
Fixes: 590126789c ("diff: Don't compare a file or directory to itself")
(cherry picked from commit 157d6664ae)
While here, stop abusing struct dirent for something we don't even need
to store.
PR: 254455
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: thj, kevans
Differential Revision: https://reviews.freebsd.org/D55113
(cherry picked from commit 590126789c)
diff: Fix build
rc must be defined first.
Fixes: 590126789c
MFC after: 1 week
X-MFC with: 590126789c
(cherry picked from commit ee44ab936e)
* Drop an unnecessary variable and rename pidfd to procd.
* Rewinding stdout serves no purpose, so stop doing it.
* Don't bother freeing memory or setting the global status right
before erroring out.
* Error out if dup(2) or dup2(2) fail.
* In the unlikely case that our pipe is equal to stdout, we need to
record that information so we don't close it when cleaning up.
* Don't bother closing a descriptor before dup2(2)ing to it.
* Don't forget to close the the process descriptor after reaping the
child process.
PR: 266592
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans, markj
Differential Revision: https://reviews.freebsd.org/D55112
(cherry picked from commit c3904a7de7)
The pagination code leaks either processes or descriptors or both,
depending on the exact version of the code you have. Add a test case
which exercises this leak to facilitate fixing it.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: thj, kevans
Differential Revision: https://reviews.freebsd.org/D55111
(cherry picked from commit 270492602b)
In the legacy Stone algorithm, we do a first pass over the files to
check if they're identical before we start diffing them. That code
would correctly set the exit status if an I/O error was encountered,
but would not emit an error message. Do so.
PR: 292198
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: thj
Differential Revision: https://reviews.freebsd.org/D55125
(cherry picked from commit f8c12e6e38)
Fix integer overflows that may occur when the context window is very
large and add tests to exercise those conditions.
PR: 267032
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: thj, kevans
Differential Revision: https://reviews.freebsd.org/D55110
(cherry picked from commit 5fc739eb59)
by removing the cast to _Bool. The _Bool type is not defined for C++,
and the specification from the gcc info doc states that the return
type of the __builtin_{add,sub,mul}_overflow() is bool already.
This is done instead of including stdbool.h to avoid namespace
pollution, since defining bool from stdckdint.h simingly is not
sanctioned by ISO/IEC 9899:2024.
PR: 290299
Reviewed by: des
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D53149
(cherry picked from commit 3c052bec12)
This adds macros for checked addition, subtraction, and multiplication with semantics similar to the builtins gcc and clang have had for years.
Reviewed by: kib, emaste
Differential Revision: https://reviews.freebsd.org/D41734
(cherry picked from commit e6615b1034)
If a pair of jails with different filesystem roots is able to exchange
SCM_RIGHTS messages (e.g., using a unix socket in a shared nullfs
mount), a process in one jail can open a directory outside of the root
of the second jail and then pass the fd to that second jail, allowing
the receiving process to escape the jail chroot.
Address this using the new FD_RESOLVE_BENEATH flag. When externalizing
an SCM_RIGHTS message into the receiving process, automatically set this
flag on all new fds where a jail boundary is crossed. This ensures that
the receiver cannot do more than access files underneath the directory;
in particular, the received fd cannot be used to access vnodes not
accessible by the sender.
PR: 262179
Reviewed by: kib
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D50371
(cherry picked from commit 350ba9672a)
The O_RESOLVE_BENEATH openat(2) flag restricts name lookups such that
they remain under the directory referenced by the dirfd. This commit
introduces an implicit version of the flag, FD_RESOLVE_BENEATH, stored
in the file descriptor entry. When the flag is set, any lookup relative
to that fd automatically has O_RESOLVE_BENEATH semantics. Furthermore,
the flag is sticky, meaning that it cannot be cleared, and it is copied
by dup() and openat().
File descriptors with FD_RESOLVE_BENEATH set may not be passed to
fchdir(2) or fchroot(2). Various fd lookup routines are modified to
return fd flags to the caller.
This flag will be used to address a case where jails with different root
directories and the ability to pass SCM_RIGHTS messages across the jail
boundary can transfer directory fds in such as way as to allow a
filesystem escape.
PR: 262180
Reviewed by: kib
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D50371
(cherry picked from commit f35525ff20)
In the ice_if_promisc_set function, the driver currently disables the
IFF_ALLMULTI flag, thereby preventing the activation of multicast mode.
To address this issue, implement appropriate handling to ensure the
flag is managed correctly.
Signed-off-by: Yogesh Bhosale <[email protected]>
Tested by: Gowthamkumar K S <[email protected]>
Differential Revision: https://reviews.freebsd.org/D54186
(cherry picked from commit 98bdf63f6e)
The variable reg_rctl stores the value read from reg E1000_RCTL. It
may contain bits E1000_RCTL_VFE and E1000_RCTL_CFIEN which control
VLAN hardware filter feature. The promiscuous mode implies all tagged
or untagged packets should be accepted, so the VLAN hardware filter
feature should be disabled when enabling the promiscuous mode.
Calling em_if_vlan_filter_disable() did the task, but later writing
the value of reg_rctl back to the reg E1000_RCTL may restore the
feature.
Move the calling of em_if_vlan_filter_disable() after writing the reg
to fix that.
PR: 292759
Reviewed by: kbowling
Tested by: [email protected]
Fixes: 2796f7cab1 e1000: Fix up HW vlan ops
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D54973
(cherry picked from commit e63ee5fedb)
(cherry picked from commit 8880678b7a)
(cherry picked from commit 3cfe90545f)
Set the MK_LLVM_LINK_STATIC_LIBRARIES knob to "yes" when building the
native-xtools target. This reverts to the behaviour prior to
2e47f35be5.
This avoids a build failure that occurs otherwise, where compilation
fails looking for a libllvmprivate.so that was not built.
It is unclear if this addresses the issue in all instances---some
replies in the PRs indicate otherwise. Still, some report success, and
in my own testing this fixed creation of a cross-compiled poudriere
jail. Commit this while we continue to investigate...
PR: 286710, 291409
Tested by: marck, [email protected]
Reviewed by: emaste
MFC after: 3 days
Fixes: 2e47f35be5 ("Convert libllvm, libclang and liblldb into private shared libraries").
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D54815
(cherry picked from commit 38e5564ece)
Calling dotrap() can do almost anything, including reallocating the
jobtab array. Convert the job pointer to an index before calling
dotrap() and then restore a proper job pointer afterwards.
PR: 290330
Reported by: bdrewery
Reviewed by: bdrewery
Differential Revision: https://reviews.freebsd.org/D53793
(cherry picked from commit f44ac8cc9c)
The command
sh -c 'sleep 3 | sleep 2 & sleep 3 & kill %1; wait %1'
crashes (with appropriate sanitization such as putting
MALLOC_CONF=abort:true,junk:true in the environment or compiling with
-fsanitize=address).
What happens here is that waitcmdloop() calls dowait() with a NULL job
pointer, instructing dowait() to freejob() if it's a non-interactive
shell and $! was not and cannot be referenced for it. However,
waitcmdloop() then uses fields possibly freed by freejob() and calls
freejob() again.
This only occurs if the job being waited for is identified via % syntax
($! has never been referenced for it), it is a pipeline with two or more
elements and another background job has been started before the wait
command. That seems special enough for a bug to remain. Test scripts
written by Jilles would almost always use $! and not % syntax.
We can instead make waitcmdloop() pass its job pointer to dowait(),
fixing up things for that (waitcmdloop() will have to call deljob() if
it does not call freejob()).
The crash from
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=290330#c2 appears to
be the same bug.
PR: 290330
Reported by: bdrewery
Reviewed by: bdrewery
Differential Revision: https://reviews.freebsd.org/D53773
(cherry picked from commit 75a6c38e4d)
This helps future developers when adding additional options handlers in the
surrounding blocks.
This is effectively a no-op.
MFC after: 1 month
(cherry picked from commit 0adec3d7ec)
This change deletes benign trailing whitespace from rc.subr, making
future non-stylistic changes easier to spot.
MFC after: 1 week
(cherry picked from commit 4e9041a786)
The correct OID format for CTLTYPE_U64 is `QU` (`uquad_t`), not `A`
(text expressed via `char *`).
This issue was noticed while doing an sysctl tree walk using a
sysctl(9) consumer that relies on the OID format to intuit what the
type should be for a given sysctl.
MFC after: 1 month
Sponsored by: DellEMC Isilon
Differential Revision: https://reviews.freebsd.org/D34877
(cherry picked from commit 567378cc07)
The wrong value passed to strncmp meant that only enable and disable were being
accepted. This change corrects the logic so enabled and disabled are also
accepted.
Pull Request: https://github.com/freebsd/freebsd-src/pull/739
MFC after: 1 week
Reviewed by: delphij, ngie
(cherry picked from commit 5a9c724847)
The correct length of an ethernet address is ETHER_ADDR_LEN but not
ETHER_HDR_LEN.
MFC after: 1 week
(cherry picked from commit 85f499be90)
(cherry picked from commit 2b01cc1544)
(cherry picked from commit a1828b1226)
While here, replace loop copying the MAC address with memcpy() for
better readability.
Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D54177
(cherry picked from commit 094626d3a5)
(cherry picked from commit c162d7febb)
(cherry picked from commit e8de565f6b)
Now that newfs(8) has a command-line argument to disable soft updates,
use that instead of running tunefs(8) after the fact to turn them off.
MFC after: 1 week
Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.
Reviewed by: mckusick, imp
Differential Revision: https://reviews.freebsd.org/D54783
(cherry picked from commit 4b96204338)
A previous commit turned soft updates on by default for UFS2 without
providing a way to turn them off. This corrects that by adding a new -u
flag which forces soft updates (and soft updates journaling) off.
MFC after: 1 week
Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.
Fixes: 61dece6d27 ("Enable soft updates by default for UFS2 filesystems.")
Reviewed by: mckusick
Differential Revision: https://reviews.freebsd.org/D54576
(cherry picked from commit 68562f8145)
newfs: Add -u to getopt string
Fixes: 68562f8145 ("newfs: Add an option to disable soft updates")
(cherry picked from commit 717ae16391)
Build fails with BHYVE_SNAPSHOT enabled on non-amd64,
so add it to BROKEN_OPTIONS for these arches.
PR: 292686
Reviewed by: emaste, markj
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D54873
(cherry picked from commit b01763b2b2)
If net is all-zero, the loop to extract all leading non-zero octets will
iterate zero times and leave nn with the value 4, which the following
switch statement to initialise qbuf does not handle. As a result,
_dns_getnetbyaddr will look up the PTR record for this uninitialised
string, which will leak the pre-existing contents of that stack memory
to the DNS resolver and, if remote and not otherwise protected, network.
Note that _dns_getnetbyaddr is only used if nsswitch.conf is configured
to enable the "dns" source for the "networks" database, which is not the
default configuration in FreeBSD.
For glibc this same bug, in code also derived from BIND's, was issued
CVE-2026-0915. This commit adopts the same behaviour as glibc's fix,
which is to regard a net of 0 as being for 0.0.0.0. Apparently NetBSD
will return NS_UNAVAIL instead, which may or may not make more sense,
but in general glibc compatibility tends to cause less friction when
there's not a good reason to avoid it.
Reviewed by: markj (secteam)
Fixes: 1363f04ce1 ("get* rework and new bind code")
MFC after: 1 day
Security: Same bug as glibc's CVE-2026-0915
(cherry picked from commit 331316b073)
PR/656: harry.sintonen: Fix bug in byte swapping that was caused by the change to make flags uint16_t and cont_level uint8_t.
This fixes using a magic.mgc built with a different endianness than
file(1) itself, e.g. when building powerpc64 on amd64.
PR: 292079
Fixes: ae316d1d1c ("MFV: file 5.46.")
MFC after: 3 days
(cherry picked from commit 39047538cf)
This is based on an initial implementation by michaelo in
https://reviews.freebsd.org/D54361.
PR: 270497
Reported by: michaelo
Reviewed by: michaelo
Tested by: michaelo
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D54606
(cherry picked from commit 8ac6427b1b)
This is a rollup commit from upstream to fix:
Heap out-of-bounds write in BIO_f_linebuffer on short writes (CVE-2025-68160)
Unauthenticated/unencrypted trailing bytes with low-level OCB function calls (CVE-2025-69418)
Out of bounds write in PKCS12_get_friendlyname() UTF-8 conversion (CVE-2025-69419)
Missing ASN1_TYPE validation in TS_RESP_verify_response() function (CVE-2025-69420)
NULL Pointer Dereference in PKCS12_item_decrypt_d2i_ex function (CVE-2025-69421)
Missing ASN1_TYPE validation in PKCS#12 parsing (CVE-2026-22795)
ASN1_TYPE Type Confusion in the PKCS7_digest_from_attributes() function (CVE-2026-22796)
See https://openssl-library.org/news/secadv/ for additional details.
Approved by: so
Obtained from: OpenSSL
Security: FreeBSD-SA-26:01.openssl
Security: CVE-2025-68160
Security: CVE-2025-69418
Security: CVE-2025-69419
Security: CVE-2025-69420
Security: CVE-2025-69421
Security: CVE-2026-22795
Security: CVE-2026-22796
same as it is done for NDRESTART()
Fixes: e05e33041c
Reported and tested by: pho
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 58b2bd33af)
Before transitively including the base version of inttypes.h, define
__STDC_CONSTANT_MACROS and __STDC_LIMIT_MACROS, because the base
inttypes.h directly includes sys/stdint.h, instead of going through the
'regular' stdint.h.
The libc++ version of the latter does define those macros, to ensure
things like UINT64_C() and SIZE_MAX are defined even in C++98 or C++03.
MFC after: 3 days
(cherry picked from commit 3cdb6c9d92)
Building the LINT-NOIP kernel on amd64 with clang 21 results in a
-Werror warning similar to:
sys/dev/mxge/if_mxge.c:1846:44: error: variable 'sum' is uninitialized when passed as a const pointer argument here [-Werror,-Wuninitialized-const-pointer]
1846 | cksum_offset, sizeof(sum), (caddr_t)&sum);
| ^~~
Indeed, if both `INET` and `INET6` are undefined, `sum` is never
initialized. Initialize it to zero to silence the warning.
Reviewed by: jhibbits
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D54730
(cherry picked from commit 74cac745fe)
When compiling vchiq with clang 21, the following -Werror warning is
produced:
sys/contrib/vchiq/interface/vchiq_arm/vchiq_arm.c:728:27: error: default initialization of an object of type 'VCHIQ_QUEUE_MESSAGE32_T' with const member leaves the object uninitialized [-Werror,-Wdefault-const-init-field-unsafe]
728 | VCHIQ_QUEUE_MESSAGE32_T args32;
| ^
sys/contrib/vchiq/interface/vchiq_arm/vchiq_ioctl.h:151:40: note: member 'elements' declared 'const' here
151 | const /*VCHIQ_ELEMENT_T * */ uint32_t elements;
| ^
While the warning is formally correct, the 'args32' object is
immediately initialized after its declaration. Therefore, suppress the
warning.
MFC after: 3 days
(cherry picked from commit b39662fc38)
Currently, fetchTimeout works for non-SSL connections only, so does fetch -T.
Fix it applying specified timeout to SSL_read().
(cherry picked from commit 8f8a7f6fff)
We've gotten a report of this breaking a fixed no autoneg setup.
Since no link is worse than what this intends to fix (negotiating full
duplex at forced speed), revert for the undeway 15.0 release cycle
until this can be further reviewed.
PR: 288827
Differential Revision: https://reviews.freebsd.org/D47336
This reverts commit 645c45e297.
(cherry picked from commit 3ff0231c87)
Merge commit '7e59b238fcf32f3d365e78ddc702ca494e1ff68d'
This commit partially reverts the previous vendor import, given that the
"type" keyword has been historically mandatory and should not be removed
by "-R all". This was clarified in the man page.
Reported by: glebius
PR: 219467
MFC after: 1 week
(cherry picked from commit 4250d2ad99)
libarchive 3.8.3
Important bugfixes:
#2753 lib: Create temporary files in the target directory
#2768 lha: Fix for an out-of-bounds buffer overrun when using
p[H_LEVEL_OFFSET]
#2769 7-zip: Fix a buffer overrun when reading truncated 7zip headers
#2771 lz4 and zstd: Support both lz4 and zstd data with leading
skippable frames
Obtained from: libarchive
Vendor commit: 1368b08875351df8aa268237b882c8f4ceb0882d
MFC after: 1 week
(cherry picked from commit 007679a138)
On FreeBSD, linking the zfs kernel module with binutils ld 2.44 shows
the following warning:
ld: warning: aesni-gcm-avx2-vaes.o: missing .note.GNU-stack section implies executable stack
ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
Some of the `.S` files under `module/icp/asm-x86_64/modes` check whether
to emit the `.note.GNU-stack` section using:
#if defined(__linux__) && defined(__ELF__)
We could add `&& defined(__FreeBSD__)` to the test, but since all other
`.S` files in the OpenZFS tree use:
#ifdef __ELF__
it would seem more logical to use that instead. Any recent ELF platform
should support these note sections by now.
Reviewed by: emaste, kib, imp
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D54578
(cherry picked from commit eb1b6ec7a7)
Note that there are three variants of this MacBook. We only have the
stride and offset values for the 17" 1680x1050 model.
Reviewed by: vexeduxr
Pull Request: https://github.com/freebsd/freebsd-src/pull/1584
(cherry picked from commit be6ba97aae)
gfx_state.tg_private points to a EFI_GRAPHICS_OUTPUT_PROTOCOL only when
using GOP.
The firmware provided Blt functions on UGA platforms have been observed
to not work on old MacBooks, and are likley hit or miss anyways as UGA
has been deprecated since 2006.
Reviewed by: tsoome
PR: 291935
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D54432
(cherry picked from commit 9595055ae7)
Probe for UGA instead of returning early if we can't find GOP.
Reviewed by: tsoome
PR: 291935
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D54431
(cherry picked from commit 5d85dde27b)
When c is compared to sc->hotchar, both undergo integer promotion, which
can lead to c being sign extended. Fix this by casting c to an unsigned
char.
Reviewed by: kevans
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D54544
(cherry picked from commit 9b2478f60b)
When resolving references, assert that the type of the object we find
is what we expect. This will help prevent memory corruption if two
objects of different types somehow end up with the same identifier.
MFC after: 1 week
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D54454
(cherry picked from commit 4b0d5d1d6a)
We were using strtoul() to parse object identifiers, which are kernel
pointers. This works fine as long as the kernel and userland match,
but in a 32-bit libgeom on a 64-bit kernel this will return ULONG_MAX
for all objects, resulting in memory corruption when we later pick the
wrong object while resolving consumer-producer references.
MFC after: 1 week
PR: 292127
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D54452
(cherry picked from commit 27894e20f1)
+ Rewrite SYNOPSIS for consistency
+ Rewrite HARDWARE for HW Relnotes, and add some stragglers
+ Correct mdoc grammar, making sysctls aproposable and linking xrefs
+ Clean up TODO, cannonicalize to CAVEATS, a standard section
+ Editorial pass, tag SPDX
MFC after: 3 days
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D52125
(cherry picked from commit 52eb7e394a)
Similar to base 63d1c3c436, suppress -Wc++20-extensions for gcc.
Otherwise libc++ headers will lead to many -Werror warnings, due to our
use of -Wsystem-headers, which is not officially supported upstream.
MFC after: 3 days
(cherry picked from commit 62a7fdc13a)
Every commit earns me a dozen emails that LINT is broken. This should
stop that.
Fixes: eda1756d04 ipfilter: Verify frentry on entry into kernel
Sponsored by: Netflix
(cherry picked from commit ddec4209b1)
When a module the environment must be explicitly fetched.
Fixes: d9788eabff
PR: 291548
Noted by: markj
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D54242
MFC after: 3 days
(cherry picked from commit a6ea80bc91)
At the moment ipfs(8) is a tool that can be easily abused. Though the
concept is sound the implementation needs some work.
ipfs(8) should be considered experimental at the moment.
This commit also makes ipfs support in the kernel optional.
Reviewed by: emaste, glebius
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D53787
(cherry picked from commit 0ff0c19e7f)
Add a sysctl/tunable (net.inet.ipf.jail_allowed) to control whether a
jail can manage its own ipfilter rules, pools, and settings. A jail's
control over its own ipfilter rules and settings may not be desireable.
The default is jail access to ipfilter is denied.
The host system can stil manage a jail's rules by attaching the rules,
using the on keyword, limiting the rule to the jail's interface. Or
the sysctl/tunable can be enabled to allow a jail control over its own
ipfilter rules and settings.
Implementation note: Rather than store the jail_allowed variable,
referenced by sysctl(9), in a global area, storing the variable in the
ipfilter softc is consistent with ipfilter's use of its softc.
Discussed with: emaste, jrm
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D53623
(cherry picked from commit d9788eabff)
The ipnat struct is built by ipnat(8), specifically ipnat_y.y when
parsing the ipnat configuration file (typically ipnat.conf). ipnat
contains a variable length string field at the end of the struct. This
data field, called in_names, may contain various text strings such as
NIC names. There is no upper bound limit to the length of strings as
long as the in_namelen length field specifies the length of in_names
within the ipnat structure and in_size specifies the size of the ipnat
structure itself.
Reported by: Ilja Van Sprundel <[email protected]>
Reviewed by: markj
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D53843
(cherry picked from commit 821774dfbd)
The frentry struct is built by ipf(8), specifically ipf_y.y when parsing
the ipfilter configuration file (typically ipf.conf). frentry contains
a variable length string field at the end of the struct. This data field,
called fr_names, may contain various text strings such as NIC names,
destination list (dstlist) names, and filter rule comments. The length
field specifies the length of fr_names within the frentry structure and
fr_size specifies the size of the frentry structure itself.
The upper bound limit to the length of strings field is controlled by the
fr_max_namelen sysctl/kenv or the max_namelen ipfilter tuneable.
The initial concepts were discussed with emaste and jrm.
Reported by: Ilja Van Sprundel <[email protected]>
Reviewed by: markj
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D53843
(cherry picked from commit eda1756d04)
ipf_check_names_string will verify userland inputs in names strings
(fr.fr_names, in.in_names) for correctness.
Original concept of ipf_check_names_string() instead of macros by
markj.
Reviewed by: markj
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D53843
(cherry picked from commit 525c535d5a)
The __printflike macro sets the format to freebsd_kprintf which recent
clang understands and warns about. Fixes the following error:
`passing 'printf' format string where 'freebsd_kprintf' format string is expected [-Werror,-Wformat]`
MFC after: 1 week
(cherry picked from commit 4cd7be3e81)
The __printflike macro sets the format to freebsd_kprintf which recent
clang understands and warns about. Fixes the following error:
`passing 'printf' format string where 'freebsd_kprintf' format string is expected [-Werror,-Wformat]`
MFC after: 1 week
(cherry picked from commit 3c0ea1b629)
Mark `sigma` and `tau` as `__non_string`, to avoid warnings from clang
21 similar to:
sys/crypto/chacha20/chacha.c:53:31: error: initializer-string for character array is too long, array size is 16 but initializer has size 17 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
53 | static const char sigma[16] = "expand 32-byte k";
| ^~~~~~~~~~~~~~~~~~
sys/crypto/chacha20/chacha.c:54:29: error: initializer-string for character array is too long, array size is 16 but initializer has size 17 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
54 | static const char tau[16] = "expand 16-byte k";
| ^~~~~~~~~~~~~~~~~~
MFC after: 3 days
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D54364
(cherry picked from commit 710ec409df)
Increase the size of `assoc::from` to 8 bytes, to avoid warnings from
clang 21 similar to:
contrib/ncurses/progs/infocmp.c:702:10: error: initializer-string for character array is too long, array size is 4 but initializer has size 5 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
702 | DATA("\033[2J", "ED2"), /* clear page */
| ^~~~~~~~~
contrib/ncurses/progs/infocmp.c:716:10: error: initializer-string for character array is too long, array size is 4 but initializer has size 5 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
716 | DATA("\033[!p", "DECSTR"), /* soft reset */
| ^~~~~~~~~
Reviewed by: markj
Obtained from: https://invisible-island.net/archives/ncurses/6.5/ncurses-6.5-20241207.patch.gz
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D54371
(cherry picked from commit 667259b392)
We copyout &l_oval but do the conversions into &l_val, leaving us with
stack garbage. A build with an LLVM21 cross-toolchain seems to catch
this.
Reported by: Florian Limberger <flo purplekraken com>
Reviewed by: markj
Fixes: a1fd2911dd ("linux(4): Implement timer_settime64 syscall.")
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D52985
(cherry picked from commit 541a98d7e2)
Otherwise, these lead to many -Werror warnings in libc++ headers, due to
our use of -Wsystem-headers, which is not officially supported upstream:
Suppress -Wc++20-extensions, due to:
/usr/include/c++/v1/__algorithm/simd_utils.h:96:50: error: explicit template parameter list for lambdas is a C++20 extension [-Werror,-Wc++20-extensions]
96 | inline constexpr size_t __simd_vector_size_v = []<bool _False = false>() -> size_t {
| ^
Suppress -Wc++23-lambda-attributes, due to:
/usr/include/c++/v1/__format/format_functions.h:462:32: error: an attribute specifier sequence in this position is a C++23 extension [-Werror,-Wc++23-lambda-attributes]
462 | if (bool __is_identity = [&] [[__gnu__::__pure__]] // Make sure the compiler knows this call can be eliminated
| ^
Suppress -Wnullability-completeness, due to:
/usr/include/c++/v1/string:1068:80: error: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Werror,-Wnullability-completeness]
1068 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n) {
| ^
MFC after: 3 days
(cherry picked from commit 63d1c3c436)
Mark `optletter` and `t_op::op_text` as `__non_string`, to avoid
warnings from clang 21 similar to:
bin/sh/options.h:77:36: error: initializer-string for character array is too long, array size is 19 but initializer has size 20 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
77 | const char optletter[NSHORTOPTS] = "efIimnsxvVECabupTPh";
| ^~~~~~~~~~~~~~~~~~~~~
bin/test/test.c:153:3: error: initializer-string for character array is too long, array size is 2 but initializer has size 3 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
153 | {"==", STREQ},
| ^~~~
MFC after: 3 days
Reviewed by: jilles
Differential Revision: https://reviews.freebsd.org/D54362
(cherry picked from commit e6546807f4)
In commit cf1eaaf41c I added the WITH_LLVM_LINK_STATIC_LIBRARIES
src.conf(5) build knob, which also affects OptionalObsoleteFiles.inc.
However, the checks were incorrect: when WITH_LLVM_LINK_STATIC_LIBRARIES
is active, the OLD_LIBS libprivatellvm.so.19, libprivateclang.so.19 and
libprivatelldb.so.19 should always be cleaned up.
Fixes: cf1eaaf41c
MFC after: 1 week
(cherry picked from commit 160077a4d7)
In commit 2e47f35be5 libllvm, libclang and liblldb were converted into
private shared libraries. This allowed clang, lld, lldb, and other llvm
tools to be linked against these shared libraries, which makes them
smaller and avoids duplication.
However, this also comes at the cost of some performance, since the
dynamic libraries are quite large, and contain lots of long symbols
(mangled C++ identifiers).
Add a WITH_LLVM_LINK_STATIC_LIBRARIES build knob that can be used to go
back to the previous behavior: libllvm, libclang and liblldb are built
as internal static libraries, i.e. only available during buildworld, and
fully linked into the various executables such as clang, lld, etc.
PR: 287447
Reviewed by: emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D50956
(cherry picked from commit 8d5a11cd01)
This message will be included in any warning issued by the compiler
for use of the deprecated function.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D47701
(cherry picked from commit 6da04bcff9)
Add __deprecated decorator. This is for a deprecated interface. copystr
is tagged with this today in copy(9), but don't actually provide it or
use it. copystr is a #define so adding it will have to wait.
LinuxKPI was defining this away completely in compiler.h. Since this is
shared between Linux KPI consumers and OpenZFS, if it's already defined,
use the FreeBSD sys/cdefs.h version, otherwise define it away. For
OpenZFS this will retain it, while for Linux KPI it will tend to drop it
(I think always, but I didn't look at everything).
Sponsored by: Netflix
Reviewed by: jhb, emaste
Differential Revision: https://reviews.freebsd.org/D46137
(cherry picked from commit 16672453f1)
These macros provide the C++11 noexcept and noexcept(...) keywords if
we're compiling in a C++11 environment. Otherwise, they expand to an
empty string.
This will be used to add the required noexcept specifier to several libc
functions as required in C++11.
MFC after: 2 weeks
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1085
(cherry picked from commit 02b0d4b688)
bhyve accepts any MAC address even foreign as long it is a unicast one.
Reviewed by: ziaee
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D54372
(cherry picked from commit e1bfd541c7)
Mark `font_header::fh_magic` as `__non_string`, to avoid a warning from
clang 21 similar to:
/usr/src/usr.bin/vtfontcvt/vtfontcvt.c:763:15: error: initializer-string for character array is too long, array size is 8 but initializer has size 9 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
763 | .fh_magic = FONT_HEADER_MAGIC,
| ^~~~~~~~~~~~~~~~~
/usr/obj/usr/src/amd64.amd64/tmp/usr/include/sys/font.h:109:27: note: expanded from macro 'FONT_HEADER_MAGIC'
109 | #define FONT_HEADER_MAGIC "VFNT0002"
| ^~~~~~~~~~
MFC after: 3 days
(cherry picked from commit e2c93ed09f)
Mark `UTC` as `__non_string`, to avoid a warning from clang 21 similar
to:
usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c:339:29: error: initializer-string for character array is too long, array size is 3 but initializer has size 4 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
--- all_subdir_usr.sbin ---
339 | static const char UTC[3] = "UTC";
| ^~~~~
MFC after: 3 days
(cherry picked from commit 3054e22e45)
Mark `direntry::deName` as `__non_string`, to avoid warnings from clang
21 similar to:
usr.sbin/makefs/msdos/msdosfs_vnops.c:512:4: error: initializer-string for character array is too long, array size is 11 but initializer has size 12 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
512 | { ". ", /* the . entry */
| ^~~~~~~~~~~~~
usr.sbin/makefs/msdos/msdosfs_vnops.c:522:4: error: initializer-string for character array is too long, array size is 11 but initializer has size 12 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
522 | { ".. ", /* the .. entry */
| ^~~~~~~~~~~~~
MFC after: 3 days
(cherry picked from commit ba0a115122)
Mark `digits` as `__non_string`, to avoid warnings from clang 21 similar
to:
usr.bin/m4/misc.c:123:27: error: initializer-string for character array is too long, array size is 36 but initializer has size 37 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
123 | static char digits[36] = "0123456789abcdefghijklmnopqrstuvwxyz";
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MFC after: 3 days
(cherry picked from commit a3394b6a23)
Previously displaying INT_MIN resulted in an out of bounds access to
digits[-8]. In twos-complement -INT_MIN is still negative.
PR: 287013
Reviewed by: emaste
(cherry picked from commit ab4edcd552)
Mark `dot_name` and `dotdot_name` as as `__non_string`, to avoid
warnings from clang 21 similar to:
sbin/fsck_msdosfs/dir.c:466:39: error: initializer-string for character array is too long, array size is 11 but initializer has size 12 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
466 | static const u_char dot_name[11] = ". ";
| ^~~~~~~~~~~~~
sbin/fsck_msdosfs/dir.c:467:39: error: initializer-string for character array is too long, array size is 11 but initializer has size 12 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization]
467 | static const u_char dotdot_name[11] = ".. ";
| ^~~~~~~~~~~~~
MFC after: 3 days
(cherry picked from commit 98c3d868fb)
Summary:
The sys/cdefs.h in src is incompatible with glibc's sys/cdefs.h so
cross-building broke when the former was added to SYSINCS in 1c9ff80f06. This
commit adds a guard around that to only do that when building on FreeBSD. This
should fix github CI.
Test Plan:
Ran buildkernel using tools/build/make.py on linux in github CI and
locally on FreeBSD to double check nothing broke.
Reviewed by: dim
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D54385
(cherry picked from commit b6672803a1)
This is needed to let the legacy stage compile against newer versions of
sys/font.h, which transitively includes sys/cdefs.h, and requires the
new __nonstring macro from it.
Fixes: e2c93ed09f
MFC after: 3 days
(cherry picked from commit 1c9ff80f06)
This attribute can be used to annotate char arrays that are not supposed to
be terminated with a NUL char and is needed to silence clang's new
-Wunterminated-string-initialization warning. The name matches linuxkpi.
Reviewed by: emaste, jhb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D52565
(cherry picked from commit 802c6d5d61)
Initialize `tbfl` and `tofl` to NULL, and check whether they are
non-NULL before calling remove(3) on them, to avoid warnings from clang
21 similar to:
usr.sbin/pmcannotate/pmcannotate.c:746:3: error: variable 'tbfl' is uninitialized when used here [-Werror,-Wuninitialized]
746 | FATAL(exec, "%s: Impossible to locate the binary file\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
747 | exec);
| ~~~~~
usr.sbin/pmcannotate/pmcannotate.c:57:9: note: expanded from macro 'FATAL'
57 | remove(tbfl); \
| ^~~~
usr.sbin/pmcannotate/pmcannotate.c:695:12: note: initialize the variable 'tbfl' to silence this warning
695 | char *tbfl, *tofl, *tmpdir;
| ^
| = NULL
usr.sbin/pmcannotate/pmcannotate.c:746:3: error: variable 'tofl' is uninitialized when used here [-Werror,-Wuninitialized]
746 | FATAL(exec, "%s: Impossible to locate the binary file\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
747 | exec);
| ~~~~~
usr.sbin/pmcannotate/pmcannotate.c:58:9: note: expanded from macro 'FATAL'
58 | remove(tofl); \
| ^~~~
usr.sbin/pmcannotate/pmcannotate.c:695:19: note: initialize the variable 'tofl' to silence this warning
695 | char *tbfl, *tofl, *tmpdir;
| ^
| = NULL
MFC after: 3 days
(cherry picked from commit cd880010c4)
In commit 2e47f35be5 libllvm, libclang and liblldb were converted into
private shared libraries. This allowed clang, lld, lldb, and other llvm
tools to be linked against these shared libraries, which makes them
smaller and avoids duplication.
However, upstream builds the shared libraries using several visibility
options, which reduces the number of external symbols, and makes the
libraries a bit smaller.
On my test machine:
* libprivatellvm.so goes from 75643 to 34706 symbols (~54% reduction)
* libprivateclang.so goes from 53250 to 33531 symbols (~37% reduction)
* libprivatelldb.so goes from 27242 to 18798 symbols (~31% reduction)
Note: to get the full benefit, a clean build is required. Incremental
builds should still work, but I didn't want to force a full rebuild on
everybody.
MFC after: 1 week
(cherry picked from commit cf1eaaf41c)
When copying ipfs data from user space, don't just check that the payload
length is nonzero, but also that it does not exceed the size of the stack
buffer we're copying it into.
While we're at it, use a union to create a buffer of the exact size we
need instead of guessing that 2048 will be enough (and not too much).
Finally, check the size of the payload once it gets to where it's used.
MFC after: 3 days
Reported by: Ilja Van Sprundel <[email protected]>
Reviewed by: cy
Differential Revision: https://reviews.freebsd.org/D54194
(cherry picked from commit a34c50fbd2)
* Move the initialization of p_ktr into proc_init() and make the check
in proc_dtor() unconditional. Prior to this, it was possible to fail
and invoke proc_dtor() after the first thread had been created (which
was the condition for checking p_ktr in proc_dtor()) but before p_ktr
had been initialized.
* Move the p_klist initialization in fork1() past the last possible
failure point so we don't have to free it on failure. We didn't,
which meant we were leaking a knlist every time we failed to fork
due to hitting the resource limit.
PR: 291470
MFC after: 1 week
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D54215
(cherry picked from commit 026d962ef1)
Currently, we unconditionally zero the fsid before returning a struct
statfs to a jailed process. Move this into prison_enforce_statfs() so
it only happens if enforce_statfs is greater than 1, or enforce_statfs
is 1 but the mountpoint is outside the jail.
PR: 291301
MFC after: 1 week
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D54214
(cherry picked from commit d4f25d0c79)
First, a bit of background on some of the data structures netlink uses
to manage data associated with a netlink connection.
- struct linear_buffer contains a single virtually-contiguous buffer
of bytes. Regions of this buffer are suballocated via lb_allocz()
which uses a simple "bump" where the buffer is split into an
allocated region at the start and a free region at the end. Each
allocation "bumps" the boundary (lb->offset) forward by the
allocation size.
Individual allocations are not freed. Instead, the entire buffer is
freed once all of the allocations are no longer in use.
Linear buffers also contain an embedded link to permit chaining
buffers together.
- snl_state contains various state for a netlink connection including
a chain of linear buffers. This chain of linear buffers can contain
allocations for netlink messages as well as other ancillary data
buffers such as socket address structures. The chain of linear
buffers are freed once the connection is torn down.
- snl_writer is used to construct a message written on a netlink
connection. It contains a single virtually-contiguous buffer
(nw->base) allocated from the associated snl_state's linear buffer
chain. The buffer distinguishes between the amount of space
reserved from the underlying allocator (nw->size) and the current
message length actually written (nw->offset). As new chunks of data
(e.g. netlink attributes) are added to the write buffer, the buffer
is grown by snl_realloc_msg_buffer by reallocating a larger buffer
from the associated snl_state and copying over the current message
data to the new buffer.
Commit 0c511bafdd aimed to fix two bugs
in snl_realloc_msg_buffer.
The first bug is that snl_realloc_msg_buffer originally failed to
update nw->size after growing the buffer which could result in
spurious re-allocations when growing in the future. It also probably
could eventually lead to overflowing the buffer since each
reallocation request was just adding the new bytes needed for a chunk
to the original 'nw->size' while 'nw->offset' kept growing.
Eventually the new 'nw->offset' would be larger than 'nw->size + sz'
causing routines like snl_reserve_msg_data_raw() to return an
out-of-bounds pointer.
The second change in this commit I think was trying to fix the buffer
overflows due to 'nw->size' being wrong, but instead introduced a new
set of bugs. The second change ignored the returned pointer from
snl_allocz() and instead assumed it could use all of the
currently-allocated data in the current linear buffer. This is only
ok if the only data in the linear buffer chain for the associated
snl_state is the snl_writer's message buffer. If there is any other
data allocated from the snl_state, it could be earlier in the current
linear buffer, so resetting new_base to nw->ss->lb->base can result in
overwriting that other data. The second change was also
over-allocating storage from the underlying chain of linear buffers
(e.g. a writer allocation of 256 followed by 512 would end up using
the first 512 bytes, but 768 bytes would be reserved in the underlying
linear buffer).
To fix, revert the second change keeping only the fix for 'nw->size'
being wrong.
Reviewed by: igoro, markj
Fixes: 0c511bafdd ("netlink: fix snl_writer and linear_buffer re-allocation logic")
Sponsored by: AFRL, DARPA
Differential Revision: https://reviews.freebsd.org/D54148
(cherry picked from commit 255af72c80)
When a module the environment must be explicitly fetched.
Fixes: d9788eabff
PR: 291548
Noted by: markj
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D54242
(cherry picked from commit a6ea80bc91)
Reported by: Kevin Day <[email protected]>
Approved by: so
Security: FreeBSD-SA-25:12.rtsold
Security: CVE-2025-14558
(cherry picked from commit bf804f69dd)
Further explain that trim(8) is not for trimming free blocks
in populated file systems/ZFS pools, as people still take it wrong sometimes.
(cherry picked from commit dbc4a1c691)
(cherry picked from commit b2f8d46d89)
The barrier code was using semaphores which have been deprecated in
macOS and not working at all, causing a race condition. Since macOS
does not have pthread_barrier_*(), this change uses a condition
variable instead.
PR: 290958
Reported by: wosch
Reviewed by: imp, markj
Differential Revision: https://reviews.freebsd.org/D54018
(cherry picked from commit 732b4aa05d)
This isn't used by modern cards, but is needed for i915kms to load
on a system that has agp as a module not compiled into the kernel.
PR: 291214
Reviewed by: cy
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53906
(cherry picked from commit a87c1e2dd8)
(cherry picked from commit 8befd2d2b6)
(cherry picked from commit ae1f6fd47c)
This ensures we pick up -fuse-ld/--ld-path for external toolchains
rather than trying to use the default system linker, which may not
exist (e.g. on macOS).
This is a direct commit to stable/13 as mips no longer exists in main.
This has always been empty since e8dce5b9b3 ("Complete the integration
of tbemd branch into head.").
This is a direct commit to stable/13 as mips no longer exists in main.
Stop adding contrib/sqlite3 into the include path for usr.bin/kyua, take
headers from the install sysroot env. sqilte3 now has the VERSION file,
which clashes with c++ include <version>.
Submitted by: jrtc27 (see https://reviews.freebsd.org/D51217)
Tested by: kib
Fixes: 17f0f75308 ("sqlite3: Vendor import of sqlite3 3.50.2")
(cherry picked from commit 09d28419c6)
macOS added a native strchrnul in 15.4. There is not an easy way to
detect it at compile time, so use a macro to rename our local inline
version to avoid conflicts while also forcing its use during
bootstrap. The local version can be removed once macOS versions older
than 15.4 are no longer supported as build hosts.
Co-authored by: jrtc27
Reported by: kib
Reviewed by: jrtc27
Differential Revision: https://reviews.freebsd.org/D49893
(cherry picked from commit 4e2616b74c)
Prior to c86af2cc4c ("imgact_elf: Check note body sizes"), this was
note_name + n_namesz >= note_end, which checks that there is at least
one byte after the unpadded name (which could be either padding or
data), and given our notes always have data with them this was fine.
However, once we started checking the padded name (note that "FreeBSD\0"
is already a multiple of 4 bytes, so has no padding) and data, this
turned into checking that there is at least one byte after the unpadded
data, and since our ELF notes already have a multiple of 4 bytes for
their data and therefore have no padding, this means that we are now
checking that there is at least one byte after the ELF note, which is
not going to be the case for the last ELF note. Instead, switch this to
a strict greater than, as should be used when comparing one-past-the-end
pointers, which both sides of the inequality are.
For executables, this was generally not a problem in reality, since the
last of our ELF notes is NT_FREEBSD_NOINIT_TAG, which isn't read by the
kernel. However, ld-elf.so.1 (and libcompat variants), like shared
libraries, only has NT_FREEBSD_ABI_TAG, which meant the kernel did not
see this ELF note when directly executing it (e.g. as done by ldd), and
on RISC-V this is the only branding present, so doing so would fail with
ENOEXEC. This does also mean on non-RISC-V direct exec ld-elf.so.1 runs
with the wrong p_osrel, but given it sets kern.proc.osrel.PID to the
executable's NT_FREEBSD_ABI_TAG that it loads, this probably doesn't
matter in practice.
PR: 291446
Reported by: bdragon
Tested by: bdragon
Fixes: c86af2cc4c ("imgact_elf: Check note body sizes")
MFC after: 3 days
(cherry picked from commit 5d58198ccc)
These days most end users are likely using pre-built packages, not
locally-built ports. Thus be sure to mention this as an important case,
and put it ahead of ports.
Reviewed by: emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42968
(cherry picked from commit ced7461021)
Currently we only honour XNM and XOBJCOPY, but XSTRIPBIN is important
during install. Otherwise we end up using STRIPBIN for the host, not the
target, which is normally the same, but may not be, especially on
non-FreeBSD systems. In particular, cheribuild will build FreeBSD with
STRIPBIN=/usr/bin/strip XSTRIPBIN=strip (with the latter referring to
the bootstrap strip in PATH), which breaks for WITH_LIB32 when the
host's /usr/bin/strip is unable to process the lib32 binaries (e.g.
building arm64 FreeBSD's lib32 on an amd64 GNU/Linux system).
MFC after: 1 week
(cherry picked from commit ad13dc1ece)
Originally the relocations for RISC-V were partitioned into dynamic and
static (with those that are both being classed as dynamic), but they
were packed next to each other, and so as new relocations were added
they were allocated sequentially, at the end of the static block, even
if really dynamic, R_RISCV_IRELATIVE being the first such case (and only
one we currently have a definition for). Delete the misleading comments.
Fixes: 4b88ccbc79 ("Sync relocation definitions")
MFC after: 1 week
(cherry picked from commit d26f481bcd)
These scripts have not seen the necessary changes to keep them up to
date with current KPIs and coding practices. They use I/O ports directly
rather than any bus abstractions, use i386 (which is on the way out for
kernel configs) as the architecture of choice for generated kernel
configs, use ISA KPIs, use INTR_TYPE_FAST (renamed in 2000 to INTR_FAST
and removed in 2011), and likely have other issues too that render them
more harm than good for the uninitiated developer looking for a driver
template. If anyone wants to invest time in modernising them they can do
so and bring them back, but for now delete them.
Reviewed by: cperciva, imp, emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D50468
(cherry picked from commit 8f0a6a9aad)
This was applying a NetBSD fix to FreeBSD. However, the original code
was correct for FreeBSD. NetBSD's obj->tlsoffset is relative to the end
of the TCB, not the TCB itself, whilst ours is relative to the TCB[1]
itself. For example, our allocate_tls uses (char *)tcb + obj->tlsoffset
for the memcpy and memset calls.
Without this reverted, for dynamically loaded shared objects, Initial
Exec accesses to TLS variables on variant I architectures (non-x86) use
the correct address, whilst General Dynamic and dlsym(3) use the
incorrect address (TLS_TCB_SIZE past the start). Note that, on arm64,
LLVM only supports TLSDESC (including LLD) and TLSDESC will use the
static resolver if the variable ends up allocated to the static TLS
block, even in the presence of dlopen(3), so only dlsym(3) shows the
discrepancy there.
Whilst here, add a comment to explain this difference to try and avoid
the same mistake being made in future.
[1] In the case of variant II, it's the amount to subtract, so still
positive
This reverts commit e9a38ed2fa.
Reviewed by: kib (prior version)
Fixes: e9a38ed2fa ("rtld: fix allocate_module_tls() variant I fallback to static allocation")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D50565
(cherry picked from commit ccfb1c50e4)
The offset here is relative to the TCB, not whatever the thread pointer
points to, so as with powerpc and powerpc64 we need to account for that.
However, rather than using hard-coded offsets as they did, due to
predating machine/tls.h, we can just re-use _tcb_get().
Note that if libthr is used, and its initialiser has been called, it
will take a different path that uses _get_static_tls_base, which works
just fine on riscv (adding the offset to thr->tcb). This only affects
programs that aren't linked against libthr (or that are but manage to
dlopen before the initialiser is called, if that's even possible).
In future this code should be made MI by just reusing _tcb_get() and
checking the TLS variant (since the offset here is positive even for
variant II, where it should be subtracted), but this is a targeted fix
that makes it clear what's changing.
Reviewed by: kib
Fixes: 5d00c5a657 ("Fix initial exec TLS mode for dynamically loaded shared objects.")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D50564
(cherry picked from commit 0e3dbc64d9)
Provided you don't run out of extra static TLS space this should work,
but it's wholly unnecessary and not how things are supposed to be done.
Only static TLS relocations should allocate static TLS.
Reviewed by: kib
Fixes: 4b1859c0e9 ("Add support for RISC-V architecture.")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D50563
(cherry picked from commit 03801d449a)
For direct exec mode we reuse map_object, but tls_max_index is
initialised to 1. As a result, the executable ends up being assigned
module 2 (and the generation is pointlessly incremented, unlike in
digest_phdr for the normal case). For most architectures this is
harmless, since TLS linker relaxation will optimise General Dynamic
accesses to Initial Exec or Local Exec for executables, but on RISC-V
this relaxation does not exist, yet the linker will initialise the
tls_index in the GOT with module 1, and at run time the call to
__tls_get_addr will fail with:
ld-elf.so.1: Can't find module with TLS index 1
Fix this by making map_object use 1 for obj->tlsindex when it's loading
the main executable, and don't bother to increment tls_dtv_generation
either, matching digest_phdr (though that one is harmless).
(Note this also applies to MIPS on stable/13)
Reviewed by: kib
Fixes: 0fc65b0ab8 ("Make ld-elf.so.1 directly executable.")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D50186
(cherry picked from commit a08d92def2)
If no extra rtld arguments are provided, rtld_argc will be 1 (for
argv[0] and so we are shifting the entire memory range down by a single
pointer. However, unlike argv and envp, auxp's entries are two pointers
in size, not one, and so in this case the source and destination
overlap, meaning simple assignment is UB (C99 6.5.16.1p3). On many
architectures this ends up being harmless as the compiler will emit
double machine word loads and stores, or if it splits them it may still
schedule them such that it works in this case, but our RISC-V baseline
does not include such instructions and LLVM ends up picking a schedule
that copies the second word before the first word, thereby replacing the
first word with a copy of the second word. This results in direct exec
mode segfaulting on RISC-V when given no arguments.
Fix this by using a temporary in the source and let the compiler safely
elide its use.
Reviewed by: kib
Fixes: 0fc65b0ab8 ("Make ld-elf.so.1 directly executable.")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D50185
(cherry picked from commit 2b04ba6e08)
The implementation of dl_iterate_phdr abuses tls_get_addr_slow to get to
the start of the TLS block, inlining the implementation of
__tls_get_addr as if the tls_index's ti_offset were 0 (historically it
called __tls_get_addr itself but changed due to locking issues). For
most architectures, tls_index's ti_offset (relocated by DTPOFF/DTPREL
for GOT entries) is just the offset within that module's TLS block.
However, for PowerPC and RISC-V, which have a non-zero TLS_DTV_OFFSET
and thus are designed assuming DTV entries are biased by that value,
ti_offset normally has TLS_DTV_OFFSET pre-subtracted, but it's
__tls_get_addr's responsibility to compensate for that. By using an
offset of zero here, tls_get_addr_slow will return a pointer to the
start of the TLS block itself, so by adding TLS_DTV_OFFSET we will point
TLS_DTV_OFFSET past the module's TLS block.
Fix this by removing the extra bias (the alternative would be to pass
-TLS_DTV_OFFSET and keep the addition, which would more closely follow
what __tls_get_addr does, but this is more direct).
(Note this also applies to MIPS on stable/13)
Reviewed by: kib
Fixes: d36d681615 ("rtld dl_iterate_phdr(): dlpi_tls_data is wrong")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D50184
(cherry picked from commit c02aaba1b4)
The implementation here is meant to mirror what a GOT entry for the
given symbol would use for ti_offset. However, on PowerPC and RISC-V,
TLS_DTV_OFFSET is non-zero, and so the GOT entries are normally biased
by this, but we fail to do so here. As a result we end up getting a
pointer TLS_DTV_OFFSET past where the variable actually is.
(Note this also applies to MIPS on stable/13)
Reviewed by: kib
Fixes: 5ceeeba90c ("Import DragonFly BSD commit")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D50183
(cherry picked from commit 8ad9cec3a2)
The implementation of dl_iterate_phdr for statically-linked binaries
abuses __tls_get_addr to get to the start of the TLS block. For most
architectures, tls_index's ti_offset (relocated by DTPOFF/DTPREL for GOT
entries) is just the offset within that module's TLS block. However, for
PowerPC and RISC-V, which have a non-zero TLS_DTV_OFFSET and thus are
designed assuming DTV entries are biased by that value, ti_offset
normally has TLS_DTV_OFFSET pre-subtracted. By using an offset of zero
here we end up getting a pointer TLS_DTV_OFFSET past what __tls_get_addr
would return for the first TLS variable.
Fix this by using -TLS_DTV_OFFSET to mirror what the General Dynamic GOT
entry for the first TLS variable would be.
(Note this also applies to MIPS on stable/13)
Reviewed by: kib
Fixes: dbd2053026 ("libc dl_iterate_phdr(): dlpi_tls_data is wrong")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D50182
(cherry picked from commit 78b99f369f)
PowerPC and RISC-V have a non-zero TLS_DTV_OFFSET. The intent behind
this in the design is that DTV entries are biased by this, as are (in
the other direction) the DTPOFF/DTPREL entries in the GOT. However, this
is pretty pointless in practice, and both FreeBSD and glibc's run-time
linkers don't bother to bias DTV entries, instead just adding the bias
back on at the end in __tls_get_addr. In libc we also have a minimal
implementation of this for statically-linked binaries, which is only in
practice used for code compiled with -fPIC (not -fPIE) that is also
linked without TLS relaxation support. PowerPC supports linker
relaxation for TLS sequences, so this likely never gets hit there, but
RISC-V does not, and so easily does if you compile an executable with
-fPIC. In this implementation we add TLS_DTV_OFFSET both to the DTV
entries in __libc_allocate_tls and to the result of __tls_get_addr,
meaning that any TLS accesses using the General Dynamic model in static
binaries on RISC-V end up off by 0x800.
Historically this also did not matter as __tls_get_addr was a stub that
always returned NULL, so although 6e16d0bc43 ("Rework alignment
handling in __libc_allocate_tls() for Variant I of TLS layout.") added
this DTV implementation, nothing actually read the entries. However, now
it's a real implementation, and dl_iterate_phdr also now relies on it,
it does matter.
Fix this by not biasing the DTV entries, just like RTLD. We could
instead stop adding TLS_DTV_OFFSET in __tls_get_addr, but being
consistent between libc and RTLD seems better.
(Note this also applies to MIPS on stable/13)
Reviewed by: kib
Fixes: ca46b5698e ("libc: implement __tls_get_addr() for static binaries")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D50181
(cherry picked from commit d04c93a2ad)
In cpu_fork, we allocate sizeof(struct pcb) + sizeof(struct trapframe)
space on the stack, then round it for stack alignment. This not only
fails to include the space needed for TP but also doesn't round up the
trapframe allocation to be stack-aligned, yet TF_SIZE does, as is the
expectation of fork_trampoline and cpu_exception_handler. Given that
sizeof(struct pcb) + sizeof(struct trapframe) is a multiple of 16, this
causes the saved TP to be stored in the PCB's pcb_sp (the intended
trapframe padding aliasing pcb_ra), which is probably harmless in
practice as the PCB isn't expected to be current, but definitely not
intended.
In cpu_thread_alloc, we do include the 8 bytes for TP and then stack
align that. This again fails to include the padding for trapframe as
present in TF_SIZE, but sizeof(struct pcb) + sizeof(struct trapframe)
happens to be a multiple of 16, as above, so adding 8 then rounding to
stack alignment (16) includes an extra 8 bytes of padding, giving the
right result for the wrong reason (and could be broken by future struct
growth).
Extract the calculation into a shared function that rounds correctly
regardless of the struct layouts. Also introduce a new struct kernframe
to encapsulate and clearly document this shared state rather than using
magic constants, and also enable it to be easily extended in future, as
we intend to do downstream in CheriBSD.
Reviewed by: jhb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D48799
(cherry picked from commit 21c534b9f5)
Otherwise this matches any two-character status except for ok.
Fixes: e5e94d2de9 ("Expand OpenFirmware API with ofw_bus_node_status_okay method")
MFC after: 1 week
(cherry picked from commit e1060f6dfd)
When using the GICR Base Address field from each GICC structure instead
of GICR structures, the field gives the address of a single
redistributor page. However, that does not mean that they are not
contiguous, and so GICR_TYPER.Last could be clear on them. Thus we must
ignore GICR_TYPER.Last in this case and always treat each region as
having a single page. Normally we'd do that as a result of checking
against the rman's size (though that's a rather roundabout and iffy way
of achieving it), but for whatever reason this is bigger on the Qualcomm
Snapdragon X Elite (I assume the MADT reports GICv4 but TYPER doesn't
report VLPIS and so there is a mismatch between the rman size and the
stride used) and we end up walking off the region's mapping.
Reviewed by: andrew, phk
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D47560
(cherry picked from commit f8c90b7041)
All the other libutil section 3 manpages document this, and although
it's heavily implied by the libutil.h header in the synopsis, we should
still be explicit and consistent.
PR: 280078
Reviewed by: jrtc27
MFC after: 1 week
(cherry picked from commit 169e23d41f)
This block has a lot of nesting, not helped by two adjacent nested
blocks involving _POSIX_C_SOURCE, with only the inner one commented,
looking like it's the end of the outer one. Comment the outer one as
well so it's not quite so hard to figure out.
MFC after: 1 week
(cherry picked from commit 7a3af393d8)
Some architectures don't need any arguments, whilst others need auxargs,
which they get by passing in env thanks to INIT_RELOCS referencing the
local variable in __libc_start1(_gcrt) by name. This is unnecessarily
confusing, fragile (one has to look at INIT_IRELOCS's definition to see
that it uses env) and duplicates code between architectures.
Instead, implement it more like rtld-elf. Each architecture provides an
ifunc_init that takes the auxargs directly, and those that don't need it
can just ignore it.
Reviewed by: kib
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D47188
(cherry picked from commit 9684658e35)
This creates a circular dependency for OpenZFS's libspl in sys/uio.h,
and it shouldn't be needed since the system limits.h already defines
IOV_MAX, so delete it, and unconditionally assert that to be the case.
Otherwise the re-include of libspl's sys/uio.h tries to use PAGESIZE
before it has been defined by OpenZFS's own sys/param.h.
Fixes: 7a7741af18 ("zfs: merge openzfs/zfs@b10992582")
MFC after: 1 week
(cherry picked from commit 0bdf2535d4)
reloc.c is conditionally included by libc_start1.c so existing builds
don't feature it in the .depend file and won't know they need to rebuild
libc_start1.c.
MFC after: 1 week
(cherry picked from commit d41a40f484)
When adding support to rtld-elf I neglected the fact that static
binaries can have IFUNCs. Add support for this too.
Fixes: 729d2b16b7 ("rtld-elf: Support IFUNCs on riscv")
MFC after: 1 week
(cherry picked from commit 1363acbf25)
There is a long-standing issue on RISC-V around --gc-sections when
statically linking, which affects the bootstrap build of LLVM. Since
fixing this properly has remained a TODO for years, commit the
workaround with documentation so that building natively from source
works out of the box.
PR: 258358
MFC after: 1 week
(cherry picked from commit 7aa6667623)
sys/types32.h: Remove struct timeval32 from libspl's header (#16491)
macOS Sequoia's sys/sockio.h, as included by various bootstrap tools
whilst building FreeBSD, has started to include net/if.h, which then
includes sys/_types/_timeval32.h and provide a conflicting definition
for struct timeval32. Since this type is entirely unused within OpenZFS,
simply delete the type rather than adding in some kind of OS detection.
This fixes building FreeBSD on macOS Sequoia (Beta).
Signed-off-by: Jessica Clarke <[email protected]>
Reviewed-by: Rob Norris <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Tony Hutter <[email protected]>
MFC after: 1 week
(cherry picked from commit 796c6031cd)
This case is hit for the kernel itself on riscv64, and did not used to
be checked. Since the code here can already handle missing Elf_Rel
and/or Elf_Rela just delete the check.
Reviewed by: jhb, imp
Fixes: 0299afdff1 ("kldxref: Make use of libelf to be a portable cross tool")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D46517
(cherry picked from commit 05996f453d)
GNU/Linux has historically had the following two resolver prototypes:
1. Elf_Addr(uint64_t, void *)
2. Elf_Addr(uint64_t, void *, void *)
For the former, AT_HWCAP is passed in the first argument, and NULL in
the second. For the latter, AT_HWCAP is still passed, and the second
argument is a pointer to their home-grown __riscv_hwprobe function.
Should they want to use the third argument in future, they'll have to
introduce yet another prototype to allow for later expansion, and then
all users will have to check whether the second argument is NULL to know
if the third argument really exists. This is all rather silly and will
surely prove fun in the face of type-checking CFI.
Instead, be like arm64 and just define all 8 possible general purpose
register arguments up front. To naive source code that forgets non-Linux
OSes exist this will be compatible with prototype 1 above, since the
second argument will be 0 and it won't look further (though should we
start using the second argument for something that wouldn't be true any
more and it might think it's __riscv_hwprobe, but that incompatibility
is one we can defer committing to, and can choose to never adopt).
Until the standard interface for querying extension information[1] is
settled and implemented in FreeBSD there's not much you can do in a
resolver other than use HWCAP_ISA_B, but this gets the infrastructure in
place for when that day comes.
[1] https://github.com/riscv-non-isa/riscv-c-api-doc/pull/74
Reviewed by: kib, mhorne
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D46278
(cherry picked from commit 729d2b16b7)
This was ratified earlier this year as an alias for Zba_Zbb_Zbs. Whilst
we don't currently export multi-letter extensions, we can still export
this alias in AT_HWCAP.
Reviewed by: mhorne
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D46277
(cherry picked from commit 228a3e73e1)
Currently we pass the raw pointer to the on-stack auxargs. This can
legitimately have fewer than AT_COUNT entries, so the use of
__min_size(AT_COUNT), i.e. static AT_COUNT, is inaccurate, and also
needlessly forces the callee to iterate over the elements to find the
entry for a given type. Instead we can just pass aux_info like we use
for everything else.
Note that the argument has been left unused by every callee since its
introduction in 4352999e0e ("Pass CPUID[1] %edx (cpu_feature), %ecx
(cpu_feature2) and CPUID[7].%ebx (cpu_stdext_feature), %ecx
(cpu_stdext_feature2) to the ifunc resolvers on x86.")
Reviewed by: kib
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D46276
(cherry picked from commit 33658afd4e)
This was true at time of commit, but the path was changed 2 weeks later
to just be the /dev/flash/spiN name, without updating the manpage.
Reported by: David Gilbert <[email protected]>
Fixes: 68dd779577 ("Give the mx25l device sole ownership of the name /dev/flash/spi* ...")
MFC after: 1 week
(cherry picked from commit 703768a235)
This used to be name = mktemp followed by fd = open downstream,
replacing upstream's crude PID-based sprintf, but in 1.4.7 this was
changed upstream to this buggy code, which we then picked up in the
1.5.0 import. Presumably nobody's actually used ee's ispell function
in the past 15 years; that or it's just ended up using junk file names
as temporary files if name's happened to be a valid address to something
that can be interpreted as a string.
Reported by: Dapeng Gao <[email protected]>
Fixes: 96b676e999 ("Update ee(1) in the base system to version 1.5.0.")
MFC after: 1 week
(cherry picked from commit 25a33bfe9c)
If cnt == 0 we access element 0 unconditionally, which is out of bounds,
and then if that doesn't crash and happens to be 0 we will access
element - 1, also out of bounds, and then if that doesn't crash will add
1 to whatever junk is there and use that for the variable. On CHERI,
though, this does crash. This code is also overly complicated, with
unnecessary special cases and tracking more state than needed.
Rewrite it in a more general manner that doesn't need those special
cases and naturally works for cnt == 0.
Found by: CHERI
Reviewed by: imp
Fixes: 1285bcc833 ("Import Netflix's efibootmgr to help manage UEFI boot variables")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D44029
(cherry picked from commit 09cb8031b4)
This isn't inherently an error. It is if you're attempting to download
dist tarballs or later install packages, but a FreeBSD system with no
NIC is a reasonable setup to have, especially in a throwaway VM setting,
so we shouldn't say it is one.
Leaving the exit code as 1 is still fine, since auto will ignore it, and
avoids breaking other uses.
MFC after: 1 week
(cherry picked from commit 7414d14bd5)
The script uses [ -z "$INTERFACES" ] to check if the list of interfaces
is empty and will exit early if so, but INTERFACES always contains at
least a space due to the way it appends the list of wireless devices.
Fix this by only adding the space when there are devices to append,
mirroring the behaviour for non-wireless devices above (both will result
in a redundant leading space when the list is non-empty, but that one is
harmless).
Fixes: 159ca5c844 ("Adapt to new wireless scheme where base wlan interfaces do not show up in ifconfig anymore.")
MFC after: 1 week
(cherry picked from commit b809c7d6a2)
Not all of the tree is happy for realinstall to be done in parallel. In
particular, Makefile.inc1 uses .WAIT to force etc to be installed after
earlier subdirectories, since etc calls into share/man's makedb to run
makewhatis on the tree and needs all manpages to have been installed.
Also, libexec/Makefile doesn't set SUBDIR_PARALLEL, and the link from
ld-elf32.1 to ld-elf.1 relies on rtld-elf having been installed before
rtld-elf32, otherwise creating the link will fail.
In general, core behavioural differences like this between NO_ROOT and
"normal" builds are also dangerous and confusing.
If this optimisation is deemed important, it should be reintroduced in a
more limited and robust manner that doesn't break the above situations.
Until then value correctness over slight efficiency gains on high core
count machines, the same machines where you're more likely to encounter
issues from this optimisation.
This reverts commits cd19ecdbdc ("Similar to r296013 for NO_ROOT,
force SUBDIR_PARALLEL for buildworld WORLDTMP staging.") and
b9c6f31681 ("Add more STANDALONE_SUBDIR_TARGETS.").
Found by: CheriBSD Jenkins
Reviewed by: bdrewery, brooks
Fixes: cd19ecdbdc ("Similar to r296013 for NO_ROOT, force SUBDIR_PARALLEL for buildworld WORLDTMP staging.")
Fixes: b9c6f31681 ("Add more STANDALONE_SUBDIR_TARGETS.")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43705
(cherry picked from commit fbae308319)
This is a repeat of 63bf2d735c ("Remove the unused arm64_cpu driver.")
for RISC-V, which copied the defunct code from arm64 with no changes
beyond substituting riscv64 for arm64, and made no use of it elsewhere.
It has thus always been entirely superfluous.
Reviewed by: mhorne
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43672
(cherry picked from commit 722b403771)
1. The definition lists struct nameidata as the type of the first
argument. However, the actual probes always pass a variable of type
struct nameidata* to SDT_PROBE3.
2. The third argument (args[2]) is actually enum cache_fpl_status.
Reviewed by: markj
Approved by: markj (mentor)
Fixes: 07d2145a17 vfs: add the infrastructure for lockless lookup
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D51315
(cherry picked from commit 6567623f83)
We bump the object reference count prior to mapping it into the kernel
map, at which point the vm_map_entry owns the reference. Then, if
vm_map_wire() fails, vm_map_remove() will release the reference, so we
should avoid decrementing it in the error path.
Reported by: Ilja van Sprundel <[email protected]>
Reviewed by: vmaffione
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D53066
(cherry picked from commit dfc1041c08)
This avoids blocking forever when invoked on a fifo.
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D54084
(cherry picked from commit 69e041521a)
In the non-INVARIANTS case, return 0 rather than stack garbage if
reading an ivar fails (in the INVARIANTS case, we still panic).
MFC after: 1 week
Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D54078
(cherry picked from commit 4c2295c158)
pf was too strict when validating SCTP tags. When a server receives a
retransmitted INIT it will reply with a random initiate tag every time.
However, pf saves the first initiate tag and expects every subsequent INIT_ACK
retransmission to have the same tag. This is not the case, leading to endless
INIT/INIT_ACK cycles.
Allow the tag to be updated as long as we've not gone past COOKIE_WAIT.
Add a test case to verify this.
MFC after: 2 weeks
See also: https://redmine.pfsense.org/issues/16516
Sponsored by: Rubicon Communications, LLC ("Netgate")
(cherry picked from commit bc3b72ff48)
ipfilter options are erased and reset to default when ipfilter is
disabled. This results in nullifying options from rc.conf that were
previously set.
8d6feaaaa2, which added this code, was incorrect as it was for a bug in
ipfilter 4.2.28 and no longer applies to ipfilter 5.1.2.
Fixes: 8d6feaaaa2
(cherry picked from commit cc1e4aae5a)
During pfsync_clone_destroy() we clean up pending packets. This
may involve calling pfsync_undefer() or callout_drain(). We may not
hold the bucket lock during callout_drain(), but must hold it during
pfsync_undefer().
We incorrectly always released the lock, leading to assertion failures
during cleanup if there were pending deferred packets.
MFC after: 1 week
Sponsored by: Orange Business Services
(cherry picked from commit 639e65144a)
This prevents dumping the memory layout of setugid processes.
MFC after: 3 days
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D54033
(cherry picked from commit 5242bcff20)
If the locale's positive_sign and negative_sign values would both be
returned by localeconv() as empty strings, strfmon() shall behave as if
the negative_sign value was the string "-".
This occurs with the C locale. The implementation previously assigned
"0" to sign_posn (parentheses around the entire string); now it assigns
it to "1" (sign before the string) when it is undefined (CHAR_MAX).
Austin Group Defect 1199[1] is applied, changing the requirements for
the '+' and '(' flags.
[1]: https://www.austingroupbugs.net/view.php?id=1199
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D53913
(cherry picked from commit cf85e7034a)
Add tests for The Open Group Base Specifications Issue 8[1], Austin
Group Defect 1199[2].
Items marked with XXX represent an invalid output. These items will be
fixed in subsequent commits.
Notice that an existing test is now considered invalid.
Our locale definitions do not include int_p_sep_by_space nor
int_n_sep_by_space[3]. Those will be addressed in a subsequent commit.
However, the CLDR project defines them as "0", which causes the output
to appear as "USD123.45". If our locale definitions were to set the
international {n,p}_sep_by_space to "1", the output would display as the
expected "USD 123.45".
While here, use the SPDX license identifier and add my name to the
file.
[1]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/strfmon.html
[2]: https://www.austingroupbugs.net/view.php?id=1199
[3]: https://unicode-org.atlassian.net/browse/CLDR-237
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D53911
(cherry picked from commit 19e153004f)
As a safety precaution df381bec2d limits ippool hash table size to 1K.
This causes any legitimely large hash table to fail to load. The
htable_size_max ipf tuneable adjusts this but the adjustment is made
in the ipfilter rc script, invoked after the ippool script (because it
depends on ippool). Let's load the ipfilter_optionlist in ippool as well.
ipfilter_optionlist load will also occur in the ipfilter rc script in case
the user uses ipfilter without ippool.
Fixes: df381bec2d
(cherry picked from commit d5d005e9bf)
In 986e05bc2a I revamped the build for all the llvm subprojects. Among
others I added objects under contrib/llvm-project/llvm/lib/TableGen, but
I missed that upstream explicitly removes these when building the shared
llvm library:
https://github.com/llvm/llvm-project/blob/llvmorg-19.1.7/llvm/tools/llvm-shlib/CMakeLists.txt#L23
In 2e47f35be5 I converted libllvm to a shared library. From that point
onwards, some of the global command line option objects registered in
llvm/lib/TableGen/Main.cpp conflict with similar objects in tools like
llvm-cov, llvm-as, etc.
This results in an error when running these tools: "CommandLine Error:
Option 'o' registered more than once!", followed by a fatal exit.
Fix this by removing the TableGen objects from libllvm. Note that we no
longer install any of the tblgen binaries, these are only used during
buildworld, and then in a statically linked form.
PR: 291233
MFC after: 3 days
(cherry picked from commit 9978553d01)
In a divert setup pf_test_state() may return PF_PASS, but not set the state
pointer. We didn't handle that, and as a result crashed immediately afterwards
trying to dereference that NULL state pointer.
Add a test case to provoke the problem.
PR: 260867
MFC after: 2 weeks
Submitted by: Phil Budne <[email protected]>
Sponsored by: Rubicon Communications, LLC ("Netgate")
(cherry picked from commit 66f2f1c832)
Sort usage and man page options, mention possible minimum and maximum
values, fix punctuation marks, and cleanup the man page.
PR: 291092
Reviewed by: pauamma_gundo.com, christos
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D53827
(cherry picked from commit 55d98b024f)
Add a fix to apply scrubbing of unsolicited NS RRSets (and their
respective address records) for YXDOMAIN and nodata non-referral
answers. This prevents a malicious actor from exploiting a possible
cache poison attack.
Obtained from: NLnet Labs
Security: FreeBSD-SA-25:10.unbound
Security: CVE-2025-11411
(cherry picked from commit 2a3a6a1771)
Use [[:space:]] rather than a white space character to delimit the keys
and the values in the resolv.conf file.
PR: 236079
Reviewed by: des
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D53811
(cherry picked from commit 0628400590)
[Driver] Enable outline atomics for FreeBSD/aarch64 (#156089)
The compiler_rt helper functions have been built since 12.4, 13.1, 14
and anything newer.
This reverts commit bd27bd1f51.
Only some people (including the release manager, unfortunately) ran into
build issues with the previous iteration of this commit, because they
were bootstrapping the compiler, either via the WITHOUT_SYSTEM_COMPILER
src.conf(5) setting, or because the build system determined that their
base system compiler was out of date.
The bootstrapped compiler would then enable outline atomics and compile
libgcc_s with these, but because libgcc_s is linked with -nodefaultlibs,
it could not find the helper routines in libcompiler_rt.a.
In contrast, people who did not bootstrap the compiler never saw any
issues, because libgcc_s was built using their 'old' base system
compiler, and so libgcc_s would not contain any calls to those helper
routines.
Fix this by ensuring that libgcc_s is linked against libcompiler_rt.a
explicitly, similar to some other binaries and libraries that are built
with -nodefaultlibs.
Also, bump FREEBSD_CC_VERSION to ensure that everybody gets the updated
compiler with outline atomics enabled. (This should have been done in
the first iteration of this commit, because the error would have shown
up right away then.)
MFC after: 3 days
(cherry picked from commit 3289bace53)
When iterating over known addresses for the requested target host name,
skip those that are not supported by the running kernel.
MFC after: 1 week
PR: 195231
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D53588
(cherry picked from commit 5818b6ee55)
Use the protype socket to obtain the IP address for an error message.
Using the resultant socket address, a NULL because create_interface()
had failed, results in SIGSEGV.
To reproduce this bug,
ifconfig bridge100 create
ifconfig bridge100 10.10.10.10/24
ifconfig bridge101 create
ifconfig bridge101 10.10.10.10/24
ntpd -n
PR: 291119
(cherry picked from commit ac1f48b4a7)
This truncation is mostly harmless today, but fix it anyway to avoid
pain later down the road.
Reviewed by: olce, kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D50417
(cherry picked from commit 0d224af399)
Otherwise NAMEILOOKUP is cleared. More generally it seems quite
surprising that the flags set by vn_open_cred() callers are not
automatically preserved. Modify open2nameif() such that it takes
already-set namei flags into account.
Reviewed by: olce, kib
Fixes: 7587f6d484 ("namei: Make stackable filesystems check harder for jail roots")
Differential Revision: https://reviews.freebsd.org/D50531
(cherry picked from commit e05e33041c)
Suppose a process has its cwd pointing to a nullfs directory, where the
lower directory is also visible in the jail's filesystem namespace.
Suppose that the lower directory vnode is moved out from under the
nullfs mount. The nullfs vnode still shadows the lower vnode, and
dotdot lookups relative to that directory will instantiate new nullfs
vnodes outside of the nullfs mountpoint, effectively shadowing the lower
filesystem.
This phenomenon can be abused to escape a chroot, since the nullfs
vnodes instantiated by these dotdot lookups defeat the root vnode check
in vfs_lookup(), which uses vnode pointer equality to test for the
process root.
Fix this by extending nullfs and unionfs to perform the same check,
exploiting the fact that the passed componentname is embedded in a
nameidata structure to avoid changing the VOP_LOOKUP interface. That
is, add a flag to indicate that containerof can be used to get the full
nameidata structure, and perform the root vnode check on the lower vnode
when performing a dotdot lookup.
PR: 262180
Reviewed by: olce, kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D50418
(cherry picked from commit 7587f6d484)
The in-tree ZFS test suite is somewhat outdated and I see a number of
failures there. I tend to think that we want to integrate the OpenZFS
test suite somehow, replacing the legacy one, though it's also possible
to run that as a separate test suite.
In any case, if one wants to run the OpenZFS test suite separately, it's
useful to be able to disable installation of the legacy ZFS test suite,
so let's provide a src.conf option to do that.
Reviewed by: asomers
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D46476
(cherry picked from commit 24affded3d)
The existing parser was needlessly complicated and wildly inconsistent
in how it handled invalid input. Rewrite using getline() and treat
invalid input consistently: silently ignore lines that don't begin with
a number, and print a warning if the inode number is out of range.
PR: 290992
MFC after: 1 week
Reviewed by: obrien
Differential Revision: https://reviews.freebsd.org/D53726
(cherry picked from commit fa272a5276)
(cherry picked from commit 179fa1d81c)
To facilitate the task, we change the comparison function so that users
with equal filesystem usage are sorted by UID, and add an undocumented
option that prevents quot from replacing numerical UIDs with names. We
also switch from getfsfile(3) to getmntpoint(3) so the first line is
identical regardless of whether we pass quot a mountpoint or a device.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D53133
(cherry picked from commit aa870a1935)
(cherry picked from commit b5f3f1a661)
(cherry picked from commit b41551753a)
PR: 250593
Reviewed by: bcr, ziaee
Thanks to: imp, markj
MFC after: 1 week
Fixes: 3843eba85d Add unmapped BIO support to GEOM ZERO
Fixes: 24e1fdcd1a Allow to specify the byte which will be used for filling read buffer
Fixes: 565bc10111 Add a very simple and small GEOM class - ZERO
(cherry picked from commit 39acb7fd86)
File descriptor lookup routines typically take a set of capsicum rights
as input to the lookup, so that the fd's rights can be atomically
checked. This set should be qualified with const.
No functional change intended.
Reviewed by: olce, oshogbo, brooks, kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D50419
(cherry picked from commit 5319cb2161)
Since the introduction of permission masks, cd9660_getattr() returns a
size of zero for all symbolic links, because the code to retrieve the
length of the link target (as required by POSIX) is dead, since we strip
away the type bits before we try to use them to identify the file as a
link. Address this by checking the vnode type instead.
PR: 290556
MFC after: 3 days
Fixes: 82f2275b73 ("cd9660: Add support for mask,dirmask,uid,gid options")
Reviewed by: olce
Differential Revision: https://reviews.freebsd.org/D53598
(cherry picked from commit 978aaa72f3)
ipf_htable_create() trusts a user-supplied iph_size from iphtable_t
and computes the allocation size as iph->iph_size * sizeof(*iph->iph_table)
without checking for integer overflow. A sufficiently large iph_size
causes the multiplication to wrap, resulting in an under-sized allocation
for the table pointer array. Subsequent code (e.g., in ipf_htent_insert())
can then write past the end of the allocated buffer, corrupting kernel
memory and causing DoS or potential privilege escalation.
This is not typically a problem when using the ipfilter provided
userland tools as calculate the correct lengths. This mitigates a
rogue actor calling ipfilter ioctls directly.
Reported by: Ilja Van Sprundel <[email protected]>
Reviewed by: markj
Differential revision: https://reviews.freebsd.org/D53286
(cherry picked from commit df381bec2d)
Add an ipfilter runtime option (ipf -T) to adjust the default
maximum hash table size. Default it to 1024 entries. It will be
used by a subsequent commit to limit any damage due to excessively
large hash table input by the user.
Reviewed by: markj
Differential revision: https://reviews.freebsd.org/D53284
(cherry picked from commit f3b94f47f5)
This is in preparation for addition of a hash table max size.
Reviewed by: markj
Differential revision: https://reviews.freebsd.org/D53283
(cherry picked from commit c57262716b)
It serves no purpose to manually manage the IPF_NUM_ERRORS count.
Calculate it instead.
Reviewed by: emaste, markj
Differential revision: https://reviews.freebsd.org/D53308
(cherry picked from commit ab3c985328)
I did not bump the date here as the manual page looks more like a draft
and I'm not sure if it is actually up-to-date considering that it's
current Dd dates back to 1998.
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D52770
(cherry picked from commit fc7f5452c6)
[Driver] Enable outline atomics for FreeBSD/aarch64 (#156089)
The compiler_rt helper functions have been built since 12.4, 13.1, 14
and anything newer.
This reverts commit 51e8e8b0f3.
MFC after: immediately
(cherry picked from commit bd27bd1f51)
Fix the htons byteorder of vxlan packets after
`vxlan_pick_source_port` picks a source port during encapsulation.
Reviewed by: zlei, kp, adrian
Differential Revision: https://reviews.freebsd.org/D53022
(cherry picked from commit 1cc316727e)
The first argument to nmount(2) is an nvlist in the form of an iovec,
which truss already knows how to decode. Set the correct flag so
this happens automatically.
MFC after: 1 week
PR: 290667
(cherry picked from commit b9f848ecba)
Update the blacklistd-helper script, it provides a better mechanism for
detecting the active packet filter.
This is a direct commit to stable/13, as blacklist has been renamed to
blocklist.
PR: 290645
This update fixes a few bugs:
- Improper response to double SIGINT with editline.
- Not letting libedit handle terminal size changes.
- A dc crash from improperly handling an error.
- A duplicate check for reference arrays.
- Build failures with GCC 15.
Add extra defines required for bc-7.1.0 to the Makefiles.
The “all.sh” script in version 7.1.0 accepts one less parameter for
selecting the tests to be run.
(cherry picked from commit 4c178fe36e)
(cherry picked from commit ab36487a79)
The NVMe spec allows the Table BIR (TBIR) and PBA DIR (PBIR) to
be 0, 4, or 5. The existing NVMe driver basically only has support
for 4, perhaps under the assumption that BAR4 is 64-bit and also
occupies BAR5.
This change adds support for BAR5, covering the case where BAR4
and BAR5 might both be present and 32-bit, where the Table BIR
might be 4 and the PBA BIR might be 5, or vice versa.
The NVMe spec (in the SR-IOV section) also permits VFs to use BIR=2,
so I haven't added stricter checks on which BIR will be permitted
by the driver.
This enables FreeBSD on Google Compute Engine C4 Machines.
MFC after: 3 days
Reviewed by: imp
Sponsored by: Google
Co-authored-by: Matt Delco <[email protected]>
Signed-off-by: Jasper Tran O'Leary <[email protected]>
Differential Revision: https://reviews.freebsd.org/D53140
(cherry picked from commit 7b32f4f0a7)
m_pullup() here will have freed the mbuf chain, but we pass back an
IP_FW_DENY without any signal that the outer loop should finish. Thus,
rule processing continues without an mbuf and there's a chance that we
conclude that the packet may pass (but there's no mbuf remaining)
depending on the rules that follow it.
PR: 284606
Reviewed by: ae
(cherry picked from commit c0382512bf)
Update libarchive to 3.8.2
Important bugfixes:
#2477 tar writer: fix replacing a regular file with a dir for
ARCHIVE_EXTRACT_SAFE_WRITES
#2659 lib: improve filter process handling
#2664 zip writer: fix a memory leak if write callback error early
#2665 lib: archive_read_data: handle sparse holes at end of file correctly
#2668 7zip: Fix out of boundary access
#2670 zip writer: fix writing with ZSTD compression
#2672 lib: fix error checking in writing files
#2678 zstd write filter: enable Zstandard's checksum feature
#2679 lib: handle possible errors from system calls
#2707 lib: avoid leaking file descriptors into subprocesses
#2713 RAR5 reader: fix multiple issues in extra field parsing function
#2716 RAR5 reader: early fail when file declares data for a dir entry
#2717 bsdtar: Allow filename to have CRLF endings
#2719 tar reader: fix checking the result of the strftime (CVE-2025-25724)
#2737 tar reader: fix an infinite loop when parsing V headers
#2742 lib: parse_date: handle dates in 2038 and beyond if time_t is big
enough
Obtained from: libarchive
Vendor commit: 7f53fce04e4e672230f4eb80b219af17975e4f83
Security: CVE-2025-25724
PR: 290303 (exp-run, main)
(cherry picked from commit 401026e482)
Unterminated strings in the anchor or name could cause crashes.
Validate them, and add a test case.
Reported by: Ilja Van Sprundel <[email protected]>
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")
(cherry picked from commit 1da3c0ca5b)
Both for the DIOCADDSTATE ioctl and for states imported through pfsync packets.
Add a test case to exercise this code path.
Reported by: Ilja Van Sprundel <[email protected]>
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")
(cherry picked from commit faacc0d968)
There is no reason to not allow kern.geom.zero.byte and
kern.geom.zero.clear to be settable as a tunable.
Reviewed by: imp, markj
Approved by: markj (mentor)
MFC after: 1 week
Event: EuroBSDCon 2025
Differential Revision: https://reviews.freebsd.org/D52763
(cherry picked from commit ae17bca63f)
The handlers were not checking that the group names are nul-terminated.
Add checks for this.
Reported by: Ilja Van Sprundel <[email protected]>
Reviewed by: zlei
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D53344
(cherry picked from commit 32919a34f1)
These structures are copied out to userspace, and it's possible to leak
uninitialized stack bytes since these routines and their callers weren't
careful to clear them first. Add memsets to avoid this.
Reported by: Ilja Van Sprundel <[email protected]>
Reviewed by: kp, emaste
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D53342
(cherry picked from commit ff08916e9a)
The direction of the data transfer in uio(9) can be confusing,
so state explicitly the difference between UIO_READ and UIO_WRITE.
Reviewed by: ziaee
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D52996
(cherry picked from commit 0625f470e0)
While here, fix the ordering of the elements in the copyright header per
style(9) and remove the text of the license as we already have the SPDX
tag here.
MFC after: 3 days
(cherry picked from commit 3cc7d67155)
We live in the SPDX world now and our example manual pages should
reflect that.
Also, fix the order of the SPDX and copyright lines as per style(9).
Reviewed by: ziaee
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D53335
(cherry picked from commit 83ac79599f)
[Driver] Enable outline atomics for FreeBSD/aarch64 (#156089)
The compiler_rt helper functions have been built since 12.4, 13.1, 14
and anything newer.
MFC after: 3 days
(cherry picked from commit 51e8e8b0f3)
When producing formatted output, trim leading whitespace and trailing
commas from the human-readable time and uptime before emitting them.
The text output remains unchanged.
PR: 290089
Fixes: 6e6febb54d ("w: Fix idle time in json output, add login/idle times to json output")
Reviewed by: marius.h_lden.org
Differential Revision: https://reviews.freebsd.org/D53167
(cherry picked from commit 4d5789532a)
Without this setting, Unbound 1.24.0 and newer will attempt to set the
socket buffer size to 4 MB to mitigate issues that mostly affect servers
with large numbers of clients on local networks, which is not a scenario
local-unbound is intended for. This is not only a waste of resources,
it can also fail, resulting in a warning message on daemon startup.
Fixes: b2efd602ae ("unbound: Vendor import 1.24.0")
Reviewed by: jlduran, cy
Differential Revision: https://reviews.freebsd.org/D52977
(cherry picked from commit de3faa85d8)
ipf_nat_getent() allocates a variable-sized nat_save_t buffer with
KMALLOCS() (which does not zero memory) and then copies only a subset
of fields into it before returning the object to userland using
ipf_outobjsz(). Because the structure is not fully initialized on all
paths, uninitialized kernel heap bytes can be copied back to user space,
resulting in an information leak.
We fix this by zeroing out the data structure immediately after
allocation.
Reported by: Ilja Van Sprundel <[email protected]>
Reviewed by: emaste
Differential revision: https://reviews.freebsd.org/D53274
(cherry picked from commit 6535e9308a)
ipf_htable_stats_get() constructs an iphtstat_t on the stack and only
initializes select fields before copying the entire structure to
userland. The trailing padding array iphs_pad[16] is never initialized,
so ~128 bytes of uninitialized kernel stack memory can be leaked to user
space on each call. This is a classic information disclosure
vulnerability that can reveal pointers and other sensitive data.
We fix this by zeroing out the data structure prior to use.
Reported by: Ilja Van Sprundel <[email protected]>
Reviewed by: emaste
Differential revision: https://reviews.freebsd.org/D53275
(cherry picked from commit 0d589ecbc7)
Our versions of these functions (originally taken from BIND) simply
don't work correctly for AF_INET6. These were removed from BIND itself
quite a while ago, but OpenBSD has made several fixes in the mean time,
so import their code.
Add tests for both functions.
PR: 289198
Reported by: Nico Sonack <[email protected]>
MFC after: 1 week
Reviewed by: des
Obtained from: OpenBSD (lib/libc/net)
Sponsored by: https://www.patreon.com/bsdivy
Differential Revision: https://reviews.freebsd.org/D52629
(cherry picked from commit 8f4a0d2f7b)
inet_net_test: Compare pointers against nullptr
GCC does not like passing NULL (__null) to std::ostringstream::operator<<
inside of ATF_REQUIRE_EQ:
lib/libc/tests/net/inet_net_test.cc: In member function 'virtual void {anonymous}::atfu_tc_inet_net_ntop_invalid::body() const':
lib/libc/tests/net/inet_net_test.cc:306:9: error: passing NULL to non-pointer argument 1 of 'std::__1::basic_ostream<_CharT, _Traits>& std::__1::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::__1::char_traits<char>]' [-Werror=conversion-null]
306 | ATF_REQUIRE_EQ(ret, NULL);
| ^~~~~~~~~~~~~~
In file included from /usr/obj/.../amd64.amd64/tmp/usr/include/c++/v1/sstream:317,
from /usr/obj/.../amd64.amd64/tmp/usr/include/atf-c++/macros.hpp:29,
from /usr/obj/.../amd64.amd64/tmp/usr/include/atf-c++.hpp:29,
from lib/libc/tests/net/inet_net_test.cc:33:
/usr/obj/.../amd64.amd64/tmp/usr/include/c++/v1/__ostream/basic_ostream.h:338:81: note: declared here
338 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long __n) {
| ~~~~~^~~
...
Fixes: 8f4a0d2f7b ("libc: Import OpenBSD's inet_net_{ntop,pton}")
(cherry picked from commit aa358ce3ca)
inet_net_test: Use int to hold expected return values from inet_net_pton
GCC warns about the sign mismatch in comparisons:
lib/libc/tests/net/inet_net_test.cc: In member function 'virtual void {anonymous}::atfu_tc_inet_net_inet4::body() const':
lib/libc/tests/net/inet_net_test.cc:86:17: error: comparison of integer expressions of different signedness: 'int' and 'const unsigned int' [-Werror=sign-compare]
86 | ATF_REQUIRE_EQ(bits, addr.bits);
| ^~~~~~~~~~~~~~
lib/libc/tests/net/inet_net_test.cc: In member function 'virtual void {anonymous}::atfu_tc_inet_net_inet6::body() const':
lib/libc/tests/net/inet_net_test.cc:205:17: error: comparison of integer expressions of different signedness: 'int' and 'const unsigned int' [-Werror=sign-compare]
205 | ATF_REQUIRE_EQ(bits, addr.bits);
| ^~~~~~~~~~~~~~
Fixes: 8f4a0d2f7b ("libc: Import OpenBSD's inet_net_{ntop,pton}")
(cherry picked from commit e1aeb58cbb)
(cherry picked from commit b4871be349)
ISO 8601 allows use of "Z" as the time zone designator. Update the
strptime parser to allow this usage.
While we are at it, update the manpage to reflect that both UTC and Z
are now valid options.
Reviewed by: des
Differential Revision: https://reviews.freebsd.org/D53083
(cherry picked from commit 79e57ea662)
While TCP disallows connect()ing a socket with SO_REUSEPORT_LB, UDP does
not. As a result, a connected UDP socket can be placed in the lbgroup
hash and thus receive datagrams from sources other than the connected
host.
Reported by: Amit Klein <[email protected]>
Reported by: Omer Ben Simhon <[email protected]>
Reviewed by: glebius
Approved by: so
Security: FreeBSD-SA-25:09.netinet
Security: CVE-2025-24934
(cherry picked from commit 320ad3dec5)
In parse_notes we validate that the note name fits within the note
buffer, but we do not do the same for the note data, so there is some
potential for an OOB read in the note handler. Add a bounds check.
Reported by: Ilja Van Sprundel <[email protected]>
Reviewed by: kib, emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D53063
(cherry picked from commit c86af2cc4c)
A string array is represented by a set of nul-terminated strings
concatenated together. For each string, we check to see if there's a
nul terminator at the end, taking care to avoid going past the end of
the buffer. However, the code fails to handle the possibility that
size == 0 at the end of an iteration, leading to underflow.
Fix the length check.
Reported by: Ilja van Sprundel <[email protected]>
Reviewed by: emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D53069
(cherry picked from commit 937693fc9e)
Note, it looks like this code may be unused since commit 4a77657cbc
("ipfw: migrate ipfw to 32-bit size rule numbers"). In particular, it
looks like the ipfw_nat_*_ptr pointers are unused now.
Reviewed by: ae
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D53068
(cherry picked from commit 2df39ce5d4)
If it encounters an inode whose owner does not have a pw entry, quot
allocates a 7-byte buffer (8 in practice, since that is the minimum
allocation size) and uses it to store the numeric uid preceded by a
hash character. This will overflow the allocated buffer if the UID
exceeds 6 decimal digits. Avoid this by using asprintf() instead.
While here, simplify the common case as well using strdup().
Reported by: Igor Gabriel Sousa e Souza <[email protected]>
MFC after: 3 days
Reviewed by: obiwac, emaste
Differential Revision: https://reviews.freebsd.org/D53129
(cherry picked from commit 5854d1cbab)
Allow umask to be configurable.
Being able to set the umask via an rc variable is useful when setting:
security.bsd.unprivileged_read_msgbuf=0
As it allows a user to configure:
dmesg_umask="066"
Without modifying the rc script, and preventing the contents of the
$dmesg_file (/var/run/dmesg.boot) from being publicly readable.
PR: 272552
Reviewed by: netchild
MFC after: 2 days
Differential Revision: https://reviews.freebsd.org/D53169
(cherry picked from commit edadbc6ee9)
The manpages of linprocfs(5) and linsysfs(5) document incomplete names without
"fs" suffix. Make them identical to other filesystems.
PR: 283079
MFC after: 3 days
Reviewed by: ziaee, markj
Differential Revision: https://reviews.freebsd.org/D53155
(cherry picked from commit 88b9ca860e)
The kern.ipc.somaxconn sysctl has been replaced with
kern.ipc.soacceptqueue since FreeBSD 10.0.
Reviewed by: emaste
MFC after: 1 hour
Differential Revision: https://reviews.freebsd.org/D34598
(cherry picked from commit 84333aada4)
Make sure the entirety of x is zero before flipping the sign bit.
Otherwise the sign would be wrong for small values of x when x is
negative and |n*y| > |x|
Reported by: alfredo
PR: 251091
Reviewed by: kargl
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D53023
(cherry picked from commit 25cca51ed2)
As with 7531c434a5, which dumped ippool table data in the "new"
format, print dstlist data in the "new" format.
MFC after: 1 week
(cherry picked from commit eee36ffa0d)
Add a brief sleep to give tail time to start following the file before
we rename it.
PR: 289902
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D52887
(cherry picked from commit a9c72543d2)
Buildworld failed when objcopy tried to overwrite itself, with `objcopy:
open objcopy failed: Text file busy`. The PATH ended up with `::`,
effectively including the current directory, and we found the wrong
objcopy.
PR: 261215
Sponsored by: The FreeBSD Foundation
(cherry picked from commit ac7ed266dc)
(cherry picked from commit e425d433c5)
and the last acquired file and line to witness object.
For recursable locks, unfortunately current implementation records only
the recurse count and the last acquired file and line, but does not
restore the previous acquired file and line on unlock. Hence it is
possible to report false acquired file and line, and that may mislead
developers and make the report by users a little harder to analyse.
Since subsequent recurse locks do not affect how witness order check,
record the first acquired file and line so that the logic is much clear.
Reported by: bz
Reviewed by: kib (previous version), markj
See also: https://lists.freebsd.org/archives/freebsd-current/2025-June/007944.html
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D52496
(cherry picked from commit 2d85bc8929)
(cherry picked from commit 3dc9f96a48)
(cherry picked from commit 7838ad85fb)
This follows the commit 4cdc1f5421, which introduces the IFCAP_HWSTATS
capability.
This is a direct commit to stable/13.
Fixes: 4cdc1f5421 There are some high performance NICs that count statistics in hardware
Historically this capability is IFCAP_NOMAP but it was renamed to
IFCAP_MEXTPG. Catch up with the change 3f43ada98c.
This is a direct commit to stable/13.
PR: 289545
Fixes: 3f43ada98c Catch up with 6edfd179c8: mechanically rename IFCAP_NOMAP to IFCAP_MEXTPG
and the macro EN_SWABIPS.
The macro EN_SWABIPS is identical to IFF_LINK0 (also historically
IFF_LLC0) and we already have the parameter link0 to toggle IFF_LINK0.
These were inherited from 386BSD 0.1 and have never been used since
the very first FreeBSD release.
Reviewed by: adrian, #network
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D51368
(cherry picked from commit 8632e4e73a)
(cherry picked from commit 878d3bdb59)
The two sysctls net.inet.tcp.hostcache.list and net.inet.tcp.hostcache.histo
are readonly and are to operate hostcache of vnet jails. Add CTLFLAG_VNET
flag to them since they are per-vnet sysctls.
This change does not have any impact on reading the two sysctls, but
`sysctl -ANV net.inet.tcp.hostcache` will report them correctly.
Reviewed by: tuexen, #transport, #network
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D52693
(cherry picked from commit b1f96169cf)
(cherry picked from commit 032918dfd1)
(cherry picked from commit ccbc722a19)
A jailed process, `sysctl -j foo` or `jexec foo sysctl`, do not have
privilege to write to non-vnet sysctls but only to those marked as jail
writable, aka sysctls those marked with CTLFLAG_VNET flag.
Without this change we will get EPERM when trying to expire and purge
hostcache entries of vnet jails via the net.inet.tcp.hostcache.purgenow
sysctl. Fix that by adding a CTLFLAG_VNET flag.
Reviewed by: tuexen, #transport, #network
Fixes: 2645638064 Add a new sysctl net.inet.tcp.hostcache.purgenow=1 to expire ...
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D52692
(cherry picked from commit 33ceb31e25)
(cherry picked from commit fa30199a3d)
(cherry picked from commit 79d114544f)
struct sysinit's func pointer requires its address, thus a real function
is generated in every translation unit when the source file has SYSINITs
declared. That results in plenty of identical sysinit_tslog_shim in the
final kernel file, in which only one is used and others are left useless.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D52413
(cherry picked from commit 5f9a05e574)
(cherry picked from commit bd721f6e80)
(cherry picked from commit 112d1a5f5d)
It is more natural to read the speed in decimal format than hexadecimal
one.
Spotted this while diagnosing PR 287445,
```
[__ecore_configure_pf_max_bandwidth:6864(qlnx-0)]Configured MAX bandwidth to be 000061a8 Mb/sec
[__ecore_configure_pf_min_bandwidth:6922(qlnx-0)]Configured MIN bandwidth to be 750 Mb/sec
```
Reviewed by: kbowling
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D52376
(cherry picked from commit e1c5e04396)
(cherry picked from commit 6fb046515e)
(cherry picked from commit 94d3be2b54)
ifconfig(8) will try SIOCGIFXMEDIA first and then retry SIOCGIFMEDIA if
that fails. Since the driver reports extended media types, support
SIOCGIFXMEDIA ioctl directly rather than doing another round.
Reviewed by: kbowling
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D52375
(cherry picked from commit 6e3c8c0f70)
(cherry picked from commit 817bc70092)
(cherry picked from commit ac4b48b6ad)
Those extended media types are available since about 2015 [1]. All
supported branches already have them defined.
No functional change intended.
[1] eb7e25b22f ifmedia changes: Extend the number of available subtypes for Ethernet media ...
Reviewed by: kbowling
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D52374
(cherry picked from commit 08356a733e)
(cherry picked from commit 5aa49c98ed)
(cherry picked from commit 2cb20b25a5)
The following up advertising of IFCAP_HWCSUM capability unconditionally
overwrite IFCAP_LINKSTATE.
Reviewed by: kbowling
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D51450
(cherry picked from commit c18860339d)
(cherry picked from commit cdd97f3aac)
The pre-load, aka linker_preload() runs at the order of SI_SUB_KLD, but
a pre-loaded module may have SYSINITs that have startup order prior to
SI_SUB_KLD, e.g. TUNABLE_INT() / TUNABLE_LONG(), hence it is possible
that we run into abnormal orders.
Without this change, the subsystem of the pre-loaded kernel modules
will be melted into previous one. That is mostly harmless but confusing.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D47904
(cherry picked from commit 11f1dd193a)
(cherry picked from commit b2293f7f60)
so that we do not discard EtherIP packets ( over IPv6 network ) when
net.inet6.ip6.fw.deny_unknown_exthdrs is set to 1 ( which is the default
value ).
PR: 227450
Reviewed by: ae, #network
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D52566
(cherry picked from commit 0418e6690e)
(cherry picked from commit b1c96e54b9)
(cherry picked from commit b4c6c3db03)
Ideally this manpage shall have examples for the EtherIP setup, but
there has been one in if_bridge(4) since the introduction of EtherIP [1],
so direct the setup to if_bridge(4) at this moment.
While here, add RFC 3378 to the reference section.
[1] 73ff045c57 Add RFC 3378 EtherIP support
Reviewed by: meta
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D51781
(cherry picked from commit bf6027df09)
(cherry picked from commit 1b42526ce9)
Given IPPROTO_IPV4, IPPROTO_IPV6 and IPPROTO_ETHERIP have different
protocol numbers, then it is perfect valid to tunnel IPv4, IPv6 and
Ethernet traffic over IPv[46] by the same interface. Since gif(4) has
already utilized the inbound csum_data field to carry address family,
also teach if_bridge(4) to do that, rather than checking if a gif(4)
interface is member of a if_bridge(4) interface.
Without this fix, tunnel IPv[46] over IPv[46] will not work when the
gif(4) interface is member of a if_bridge(4) interface, aka the EtherIP
setup, as the address family passed from gif_output() will be overwritten
with the wrong one AF_LINK by gif_transmit(), and end up with incorrectly
encapsulated packets.
PR: 227450
Reviewed by: kp
Tested by: meta
Fixes: 8a03087223 gif(4): Assert that gif_output() isn't called for EtherIP
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D51682
(cherry picked from commit f4744b8acb)
(cherry picked from commit aeb8f341ad)
Tunnel IPv[46] traffic over IPv[46] should still function when the
gif(4) interface is member of a if_bridge(4) interface, aka the
EtherIP setup.
PR: 227450
Reviewed by: kp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D51682
(cherry picked from commit 04d0dc4c0c)
(cherry picked from commit e5f01421dd)
While here, rename basic to 4in4 to be consistent with other tests.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D51566
(cherry picked from commit 62439516cc)
(cherry picked from commit c2806cddc6)
When an asterisk is encountered inside a C-style comment, we first check
if there is at least one more character left in the buffer, and if that
character is a slash, which would terminate the comment. If that is not
the case, the next two characters are consumed without being inspected.
If one of those is a double quote, or the initial asterisk of an
asterisk-slash pair, we end up misparsing the comment.
MFC after: 3 days
Reviewed by: kevans, bofh
Differential Revision: https://reviews.freebsd.org/D52808
(cherry picked from commit b5e2bd5ef3)
- Add FREEBSD-upgrade instructions
- Add FREEBSD-Xlist file
- Remove all unnecessary files which are not required for in-tree build
Approved by: bapt
Differential Revision: https://reviews.freebsd.org/D50472
Event: Oslo Hackathon 202508
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 2326db40a1)
A race can occur in gpioc_ioctl when it is called with GPIOCONFIGEVENTS
closely followed by GPIOSETCONFIG. GPIOSETCONFIG can alter the
priv->pins list, making it no longer empty and opening the door for
access to priv->events while we are reallocating it. Fix this by holding
priv->mtx while handling GPIOCONFIGEVENTS.
Reported by: Qiu-ji Chen
PR: 289120
Reviewed by: mmel
MFC after: 1 day
Differential Revision: https://reviews.freebsd.org/D52783
(cherry picked from commit d000adfe41)
memcpy should copy to the current mbuf, otherwise we're copying to the
first mbuf in the chain over and over.
Reported by: kevans
Reviewed by: glebius
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D52713
(cherry picked from commit e05521121f)
Stop incrementing m_data so the callee can read the mbuf.
MFC after: 3 days
Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D52702
(cherry picked from commit 57d5a8feda)
When MSI or legacy interrupt is used driver controls wheter
queues can trigger an interrupt with the Interrupt Linked List.
While processing traffic first index of the list is set to EOL
value to stop queues from triggering interrupts. This index was
not reset to the correct value when driver attempted to re-enable
interrupts from queues, what prevented driver from processing any
traffic. Fix that by setting correct first index in the
ixl_if_enable_intr function.
While at that fix the comments style and make ixl_if_enable_intr
and ixl_if_disable_intr more consistent.
Signed-off-by: Krzysztof Galazka <[email protected]>
PR: 288077
Suggested by: Mike Belanger <[email protected]>
Approved by: kbowling (mentor), erj (mentor)
Tested by: gowtham.kumar.ks_intel.com,
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D51331
(cherry picked from commit 6f41c1fc39)
It is referred to in the documentation as the system crontab, not root's
crontab.
PR: 289099
Reviewed by: emaste
Approved by: emaste (mentor)
Fixes: d33daab934 ("Call /etc/crontab the "system crontab", not "root's crontab". While here, fix some other wording issues")
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D52503
(cherry picked from commit c806defe8f)
Upgrading from 14.x to 15.x with freebsd-update broke because libc
depends on the new libsys library; freebsd-update installed the new
libc before creating libsys, and every step after that failed because
all the tools (including gunzip and install) are dynamically linked
and need a working libc.
Enforce ordering when installing shared objects: First libsys, then
libc, then libthr, and then all the rest of the shared object files.
This is a candidate for an Errata Notice since the issue this fixes
breaks upgrades.
PR: 289769
Reported by: Graham Perrin
Reviewed by: kib
MFC after: 3 days
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D52688
(cherry picked from commit 7ece602e00)
This change creates a static inline function, BN_check_prime, for
pre-3.0 use which is implemented with the previous (1.1) compatible call
under the covers, `BN_is_prime_ex`.
The `nchecks` parameter value is maintained, even though it has no
noticable behavior change, given that the documentation clearly states
that at least 64 or 128 rounds are executed on the backend, depending on
how many bits there are in the given number being factored out.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D40305
(cherry picked from commit dcf5d5603b)
This change ports the BN APIs to an OpenSSL 3 compatible set of APIs.
This removes the need for requesting OpenSSL 1.1 compatible APIs.
MFC after: 1 week
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D40298
(cherry picked from commit 537cd76643)
This will help ensure that the change following this
one to support OpenSSL 3 is sane.
MFC after: 1 week
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D40297
(cherry picked from commit c60be9ea6b)
OpenSSL's BN_zero API has had a void return value since 1.1.x: chase the
change to unbreak the build on OpenSSL 3.x with MK_GH_BC == no.
MFC after: 2 weeks
Reviewed by: emaste, kevans
Differential Revision: https://reviews.freebsd.org/D41410
(cherry picked from commit c45e66dca3)
The variable's definition was removed with texinfo in
2d2813618c, but the reference to the
variable was left behind.
This is effectively a no-op cleanup.
MFC after: 3 days
(cherry picked from commit de3e5dbea1)
If SRCCONF is not defined and src.conf exists at the top level of the
source tree, use that instead of /etc/src.conf.
MFC after: 3 days
Reviewed by: kevans, imp
Differential Revision: https://reviews.freebsd.org/D52470
(cherry picked from commit dd8c666d8b)
UPDATING: mention the src.conf change
Fixes: dd8c666d8b ("src.sys.mk: Support src.conf in SRCTOP")
(cherry picked from commit ab2fea3f9a)
Add a -l option which causes man to interpret all arguments as paths to
open directly rather than man pages to search for in MANPATH. See the
PR for a detailed rationale.
PR: 289245
MFC after: 1 week
Reviewed by: ziaee, emaste
Differential Revision: https://reviews.freebsd.org/D52385
(cherry picked from commit 14b61b2e93)
Currently the idle time will show as `true` part of the time in the json
output and quoting depends on what is being printed. Make sure it's
always printed correctly and for consistency treated as a string in the
json output.
Login time delta and since times are currently exposed in the xml
output, expose these times in the json output as well.
In the json and xml outputs expose the number of seconds idle as a new
field or attribute respectively.
MFC after: 1 week
Sponsored by: Modirum MDPay
Event: Oslo Hackathon 202508
Differential Revision: https://reviews.freebsd.org/D52237
(cherry picked from commit 6e6febb54d)
Based on the spec the STIP bit of SIP register is read-only.
To clear STIP bit from supervisor we have to do an SBI call to firmware.
Upon reception of SBI request, the machine-mode firmware clears the STIP
bit in the MIP register.
This fixes operation on Codasip A730.
Reviewed by: mhorne
Differential Revision: https://reviews.freebsd.org/D49487
(cherry picked from commit 6d58c67006)
From the SSTC spec:
"If the stimecmp (supervisor-mode timer compare) register is implemented,
then STIP is read-only in mip and reflects the supervisor-level timer
interrupt signal resulting from stimecmp. This timer interrupt signal
is cleared by writing stimecmp with a value greater than the current time
value."
This fixes operation in Spike with sstc extension enabled.
Example:
spike --isa RV64IMAFDCH_zicntr_zihpm_sstc
Reviewed by: mhorne
Differential Revision: https://reviews.freebsd.org/D45226
(cherry picked from commit ddd0d4f4cd)
make(1)'s -D flag does not allow for setting the value of the variable.
It just defines the variable and sets its value to 1. In fact, make(1)
treats "=" as just another character in the variable name:
```
$ make -DA=2 -V A # Output is just an empty line.
$ make -DA=2 -V A=2 # Variable "A=2" is defined and set to "1".
1
```
Fixes: d25f7d324a ports.7: Document DEBUG_FLAGS and the process of debugging ports
MFC after: 3 days
(cherry picked from commit 9365a32859)
All datasets on zroot pool are compressed by default since FreeBSD 11.0 [1],
no need to mention that on some specific datasets these days.
[1] 47206692f2
Reviewed by: jrm (mentor), ziaee
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D52304
(cherry picked from commit f304c5bb8b)
Originally ixgbe_if_update_admin_status() only handled 1G and 10G speeds,
causing any other speeds to display as "1 Gbps" in link status logs.
This issue is fixed by adding link speed to string conversion logic through
the introduction of a helper function, ixgbe_link_speed_to_str(), which
corrects the misleading logs to reflect accurate link speeds.
Signed-off-by: Yogesh Bhosale [email protected]
PR: 288960
Reported by: Mike Belanger - QNX
Differential Revision: https://reviews.freebsd.org/D52442
(cherry picked from commit 46347b3619)
The exports.5 man page is a bit of a monster.
One place of common confusion is the use of
the "V4:" line(s) for defining the location of the
root of the NFSv4 export subtree.
This patch adds a paragraph in an attempt to
clarify this.
This is a content change.
(cherry picked from commit 200730f29d)
If the user specified a prefix length with either the internal or
external prefix, we'd jump to check_prefix where we'd dereference p
which was most likely uninitialized.
Instead, store the various prefix lengths separately and check them
all after the loop.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D50597
(cherry picked from commit 64bc9ac8cd)
* ISO 8601 defines two formats: basic and extended, clarify that we
output the extended format only.
* Clarify that ISO 8601 is only aware of timezone /offsets/, not timezones,
it has no relation to the Olson timezone database (TZ environment variable).
Reviewed by: otis (mentor), des
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D52314
(cherry picked from commit 21628c79d5)
Also move num initialization for clarity.
We still need to check num in ng_unparse_composite (reported by des@ in
D52151) but this is another incremental improvement in netgraph input
validation.
Reviewed by: des
PR: 267334
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D52151
(cherry picked from commit 375527545c)
(cherry picked from commit 4407e10fdc)
This is an interim robustness improvement; further improvements as
described in the PR and/or Phabricator review are still needed.
PR: 267334
Reported by: Robert Morris <[email protected]>
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37229
(cherry picked from commit ae4f39464c)
(cherry picked from commit 0e0329c6db)
[PowerPC] Do not merge TLS constants within PPCMergeStringPool.cpp (#94059)
This patch prevents thread-local constants to be merged within
PPCMergeStringPool.cpp.
The PPCMergeStringPool pass primarily merges non-thread-local constants
together, and thread-local constants should not be mixed together with
other (non-thread-local) constants. In the event that thread-local and
other non-thread-local constants are pooled together, the
llvm.threadlocal.address intrinsic can fail as it expects its argument
to be a thread-local global value, but the merged string structure
created by the PPCMergeStringPool pass is not thread-local as a whole.
This fixes an error "llvm.threadlocal.address first argument must be a
GlobalValue" when building the math/nauty port on PowerPC architectures.
PR: 289122
Reported by: pkubaj
MFC after: 3 days
(cherry picked from commit cb2887746f)
If the mntfromname of a mountpoint is not a device (e.g. nullfs, tarfs,
procfs) we shouldn't compare st_rdev, as any match will be spurious.
MFC after: 1 week
Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D51945
(cherry picked from commit 8073a5137f)
Fsyncing each file we install slows us down significantly and adds
little to no safety.
MFC after: 1 week
PR: 287897
(cherry picked from commit 20f0996700)
As pointed out in the PR and the article linked below, the switch to
insertion sort in the BSD qsort code is based on a misunderstanding of
Knuth's TAOCP and is actually a pessimization. As demonstrated by the
added test, it is trivially easy to construct pathological input which
results in quadratic runtime. Without that misguided optimization, the
same input runs in nearly linearithmic time.
https://www.raygard.net/2022/02/26/Re-engineering-a-qsort-part-3
PR: 287089
MFC after: 1 week
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D51907
(cherry picked from commit 5205b32de3)
if the syscall muxes are used, up to two additional arguments
may be required. This means that the 8 required for mmap increases
up to 10 (for __syscall).
Sponsored by: Juniper Networks, Inc.
(cherry picked from commit 740b879c6a)
Follow-up commit d180086e6e by fixing the left shift of signed integer
entities through the use of a helper function. Specific per file changes
are:
* lib/msun/src/e_fmodf.c:
* lib/msun/src/s_remquof.c:
. Eliminate now unused variable 'i'.
. Sort declaration statement.
. Use subnormal_ilogbf() to avoid left shift of signed integer.
* lib/msun/src/math_private.h b/lib/msun/src/math_private.h:
. Implement subnormal_ilogbf() to extract an exponent of a subnormal
float. This avoids left shifts of signed integers.
. Update nearby comment.
* lib/msun/src/s_ilogbf.c
. Fix declaration of the function statement in accordance with style(9).
. Use subnormal_ilogbf() to avoid left shift of signed integer.
PR: 288850
MFC after: 1 week
(cherry picked from commit c58c77246f)
The patch fixes a few instances of left shifts on
signed integer entities. A 'static inline' helper function
'subnormal_ilogb()' has been added to math_private.h. This
function is then used e_fmod.c, s_ilogb(), and s_remquo.c.
The change in s_remquo.c has only been compile tested.
The change to e_fmod.c has been test on over 3 billion pairs
of subnormal numbers where testing included x > y and x < y
pairs. The test compared the output from fmod() with the
output from mpfr_fmod() from MPFR. There were no difference.
The change to s_ilogb() has had limited testing where its
output was compared against frexp(). In this testing, no
differences in output were detected.
PR: 288778
MFC after: 1 week
(cherry picked from commit d180086e6e)
* lib/msun/src/s_ccosh.c:
. Update Copyright years.
. sin() and cos() are needed at the same time, so use sincos() to
compute values. This does argument reduction once instead of twice.
. Replace '* 0.5' with '/ 2'. This reduces diff with s_ccoshf.c.
. For (LDBL_MANT_DIG == 53), add weak references for ccoshl and ccosl.
* lib/msun/src/s_ccoshf.c:
. Update Copyright years.
. sin() and cos() are needed at the same time, so use sincos() to
compute values. This does argument reduction once instead of twice.
. Replace '* 0.5F' with '/ 2'. This reduces diff with s_ccoshf.c.
* lib/msun/src/s_csinh.c:
. Update Copyright years.
. sin() and cos() are needed at the same time, so use sincos() to
compute values. This does argument reduction once instead of twice.
. Replace '* 0.5' with '/ 2'. This reduces diff with s_csinhf.c.
. For (LDBL_MANT_DIG == 53), add weak references for csinhl and csinl.
* lib/msun/src/s_csinhf.c:
. Update Copyright years.
. sin() and cos() are needed at the same time, so use sincos() to
compute values. This does argument reduction once instead of twice.
. Replace '* 0.5F' with '/ 2'. This reduces diff with s_ccoshf.c.
PR: 288740
MFC after: 1 week
(cherry picked from commit a1d051bc87)
There are two problems here, really:
1.) If -G is specified, the egid of the runner will get clobbered by
the first supplemental group
2.) If both -G and -g are specified, the first supplemental group will
get clobbered by the -g group
Ideally our users shouldn't have to understand the quirks of our
setgroups(2) and the manpage doesn't describe the group list as needing
to contain the egid, so populate the egid slot as necessary.
I note that this code seems to have already been marginally aware of the
historical behavior because it was allocating NGROUPS_MAX + 1, but this
is an artifact of a later conversion to doing dynamic allocations
instead of pushing NGROUPS_MAX arrays on the stack -- the original code
did in-fact only have an NGROUPS_MAX-sized array, and the layout was
still incorrect.
Reviewed by: olce
(cherry picked from commit 48fd05999b)
(cherry picked from commit babab49eee)
This is still required on stable/13 because of the RCS tags defined at
the top of each source file.
This is a direct commit to stable/13.
Fixes: 0947920999 ("files: add new IPFILTER_C rule for netpfil/ipfilter sources")
This target checks that every page mentioned in MLINKS exists and that
every link corresponds to a (possibly commented-out) name entry in the
page it links to.
MFC after: 1 week
Reviewed by: bcr
Differential Revision: https://reviews.freebsd.org/D51862
(cherry picked from commit 18a9f83630)
The function used to create a backup of the input before starting work
used a static buffer and did not check that the file name it constructed
did not overflow. Switch to using asprintf(), clean up the rest of the
function, and update some comments that still referred to an earlier
version of the code.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: bnovkov
Differential Revision: https://reviews.freebsd.org/D51796
(cherry picked from commit eb41613d22)
Much of the test script was concerned with working around RCS tags and
dealing with cases which don't apply to indent.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D51795
(cherry picked from commit 0ecc679fd3)
The data size check, as currently written, can be defeated by providing
a very large number that rounds up to 0, which will pass the check
(because zero plus the size of the header and name is smaller than the
size of the message) but cause a segfault later when used to index the
data array.
Rewrite the data size check to take rounding into account, and add a
cast to ensure the name size can't round up to zero.
MFC after: 1 week
PR: 266827
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D51615
(cherry picked from commit 3caee2a93f)
MFC after: 1 week
Reviewed by: olce, imp, emaste
Differential Revision: https://reviews.freebsd.org/D51706
(cherry picked from commit 22afc76786)
libutil: Remove manual link for nonexistent function
I believe quota_statfs() was the original name of the function now
called quota_check_path(). I must have forgotten to update the MLINK
when I renamed it.
MFC after: 1 week
Fixes: 5666aadb3d ("Further extend the quotafile API.")
Fixes: 22afc76786 ("libutil: Add missing MLINKs")
Reviewed by: bcr
Differential Revision: https://reviews.freebsd.org/D51863
(cherry picked from commit 7400d04407)
libutil: Fix manlint failures
MFC after: 1 week
Reviewed by: ziaee
Differential Revision: https://reviews.freebsd.org/D51864
(cherry picked from commit d0cc09fcdb)
ObsoleteFiles: Remove bogus manlink
Fixes: 7400d04407 ("libutil: Remove manual link for nonexistent function")
(cherry picked from commit 46f9056367)
If the calling process has used SIG_IGN as handler or set the
SA_NOCLDWAIT flag for SIGCHLD, processes will be automatically reaped on
exit and calls to waitpid(3) will therefore fail with ECHILD.
We waitpid primarily to reap our child so that the caller does not have
to worry about it. ECHILD indicates that there is no child to reap, so
we can just treat that as a success and move on.
Signed-off-by: Kenny Levinsen <[email protected]>
Tested by: Jan Beich
Pull Request: https://github.com/freebsd/freebsd-src/pull/1675
(cherry picked from commit da9e73e5d4)
If a file with bad memory addresses is configured but that file is
empty (0 lines, 0 bytes), when loading it we end up returning an end
pointer that is just _before_ the start of the (empty) file content.
Adjust the code to make it clear what pre-condition are required to set
the *list / *end pointers correctly, and explicitly set them to NULL
when they are not matched.
Reported by: [email protected]
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D51717
(cherry picked from commit f90940ce6e)
malloc() outside of a write lock will reduce potential contention.
MFC after: 3 days
This reverts commit 7f5e3b9fa3.
(cherry picked from commit cf9b685754)
No functional change is intended.
Missing parentheses around sizeof operands have been added with
a coccinnele patch:
@disable paren@
expression E;
@@
(
sizeof(E)
|
sizeof
+(
E
+)
)
Spaces between sizeof and a parenthesis have been removed with sed.
Discussed with: imp
(cherry picked from commit 150834f8fa)
It cannot be used safely, and Kyua doesn't even pretend to try.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: igoro
Differential Revision: https://reviews.freebsd.org/D51680
(cherry picked from commit 65bae451c2)
It cannot be used safely, though libarchive goes to ridiculous lengths
to attempt to do so.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D51679
(cherry picked from commit 01e42ce81f)
Failing to reset the cookie between messages can lead to an attempt
to interpret a zeroed buffer as a struct nlattr, causing a length
calculation to underflow, resulting in a memcpy() call where the
length exceeds the actual size of the buffer.
MFC after: 1 week
PR: 283797
Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D51634
(cherry picked from commit a8d90e3213)
For me, this fixes a problem with using eMMC storage in MMCCAM
configuration with dwmmc driver (on Rock64).
The problem appeared after commit 07da3bb5d5 "mmc: support for SPI
bus type".
The problem was caused by the said commit changing the layout of struct
mmc_ios which is embedded into struct ccb_trans_settings_mmc with the
latter being embedded into struct ccb_trans_settings, a member of
union ccb.
The layout mattered for two reasons:
1. dwmmc sets cmd.error only in case of an error;
2. mmc_da's sdda_start_init uses the same ccb for different transaction
types without explicitly clearing the object between transactions.
As a result, cmd.error could start out with a non-zero value and dwmmc
would keep that value which would then be interpreted as a failure.
Such a failure happened in mmc_set_timing resulting in incorrect timing
settings and subsequent complete failure to communicate with the eMMC
module.
Reviewed by: pkelsey
(cherry picked from commit 10db2ad861)
The function is unused since 5aedb8b1d4.
For information, in MMC CAM both XPT_GET_TRAN_SETTINGS and XPT_PATH_INQ
obtain data using MMC_SIM_GET_TRAN_SETTINGS. So, "overlapping"
information like ccb_trans_settings_mmc::host_max_data and
ccb_pathinq::maxio is derived from the same source.
That's why sdda_get_max_data was redundant.
Reported by: bz
(cherry picked from commit ad0c3859a9)
The garbage resulted from reading the value from a ccb which was
originally populated by XPT_PATH_INQ operation but then overwritten by
XPT_GET_TRAN_SETTINGS operation.
The problem could probably be fixed by re-ordering the
XPT_GET_TRAN_SETTINGS operation, but it seems like the operation was
redundant. Besides, the ccb is declared not as union ccb but as struct
ccb_pathinq, so using it for XPT_GET_TRAN_SETTINGS was questionable.
I opted for replacing a call to sdda_get_max_data (which uses
XPT_GET_TRAN_SETTINGS internally) with using maxio provided by the
XPT_PATH_INQ operation.
This also required fixing mmc_cam_sim_default_action as controllers
return maximum I/O size in sectors, but maxio value should be in bytes.
(cherry picked from commit 5aedb8b1d4)
rk_i2c_send_stop is modified so that it sends a stop condition, like it
always did, if there is no IIC_M_NOSTOP flag.
But if the flag is set then the function completely resets the control
register and sets the driver state to transfer completed.
Something like this was previously done for a write with IIC_M_NOSTOP.
Now it is done for a read with IIC_M_NOSTOP as well.
Linux code says that the hardware does not support the repeated start
condition and the documentation, indeed, does not mention it.
But according to the Linux driver clearing the control register and then
sending a start condition acts as if it were a repeated start.
While here, add braces around a single-line 'if' branch to balance it
with a multi-line 'else' branch.
Tested with max44009(4).
(cherry picked from commit 0deaf4be34)
When processing a notification, instead of accepting any file name
that doesn't begin with a slash, accept only file names that don't
contain any slashes at all. This makes it possible to notify a
user about a mailbox that doesn't bear their name, as long as they
are permitted to read it, but prevents comsat from reading files
outside the mail spool.
PR: 270404
MFC after: 1 week
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D51580
(cherry picked from commit 4a4338d944)
comsat: Don't return from the child
Fixes: 91629228e3
MFC after: 1 week
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D51581
(cherry picked from commit e40a2c4927)
Just return from jkfprintf if either (a) user lookup fails (that is,
getpwnam fails) or (b) setuid() to the user's uid fails. If comsat is
invoked from inetd using the default of tty:tty we will now return due
to setuid() failing rather than fopen() failing.
PR: 270404
Reviewed by: kevans
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47823
(cherry picked from commit 062b69ba04)
comsat: Use initgroups and setgid not just setuid
PR: 270404
Reviewed by: jlduran
Obtained from: NetBSD
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47828
(cherry picked from commit d4dd9e22c1)
comsat: move uid/gid setting earlier
It's good to reduce privilege as early as possible.
Suggested by: jlduran
Reviewed by: jlduran
Obtained from: NetBSD
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47869
(cherry picked from commit 91629228e3)
Since it's not possible to pass more than {ARG_MAX} bytes on the command
line, it's also not possible to pass more than {ARG_MAX} individual
arguments. Therefore, {ARG_MAX} is a reasonable upper bound for the -n
option. This resolves both the arithmetic overflow issue and the CI OOM
issue, so we can safely re-enable the test.
Fixes: eab91d0081
Fixes: 2682a15527
MFC after: 1 week
Reviewed by: jlduran, emaste
Differential Revision: https://reviews.freebsd.org/D51536
(cherry picked from commit a7fa987abe)
This script references variables beloning to the nfsd and zfs services,
therefore it needs to load their configurations.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D51473
(cherry picked from commit aa183bc7f9)
Description of net.inet.ip.fw.one_pass tunable refers only to dummynet(4),
while in reality is applicable on any divert-like packet action like
in-kernel nat, netgraph, reass, or similar.
Reviewed by: ae
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D51436
When loading bad memory addresses from a file, we are passed an end
pointer that points on the first byte after the buffer. We want the
buffer to be null-terminated (by changing the last byte to \0 if it is
reasonable to do so), so adjust the end pointer to be on that byte.
Approved by: kib, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D51433
(cherry picked from commit 202f8bde83)
The rx_buf_tag should be checked when destroying rx dma mappings.
PR: 288309
Reviewed by: zlei
Submitted by: Mike Belanger <[email protected]>
MFC after: 3 days
(cherry picked from commit f46e95ae3a)
(cherry picked from commit 337c3e9859)
The variable eaddr_found is declared as bool. This change improves
readability a little.
No functional change intended.
MFC after: 3 days
(cherry picked from commit 2fc051d090)
(cherry picked from commit 97d5f16c69)
${.ALLSRC} can include the dependency OptParser.td, which causes
llvm-tblgen to fail since it only accepts a single input argument.
Use ${TDFILE} directly instead, which matches the other invocations
of tblgen in the LLVM Makefiles.
Fixes: d3c06bed2c ("clang: install clang-scan-deps")
MFC after: 3 days
Reviewed by: dim
Differential Revision: https://reviews.freebsd.org/D51569
(cherry picked from commit ad023bc26e)
Replace "cannot mount root" (which is no longer a panic) with a brief
description of the mountroot> prompt, and recommend using "system
install media" rather than the fixit floppy.
Remove "timeout table full" entirely since this panic no longer exists.
MFC after: 3 days
Reviewed by: ziaee
Differential Revision: https://reviews.freebsd.org/D51512
(cherry picked from commit c9868af774)
Reported by: markj
Reviewed by: christos, markj (earlier version), ziaee
Obtained from: Mark Johnston, DTrace, FreeBSD Journal, May 2014
Obtained from: https://wiki.freebsd.org/DTrace/One-Liners
MFC after: 2 weeks
Relnotes: yes
(cherry picked from commit 9388c28878)
Do not mention dtrace_kinst(4) as it is not available on FreeBSD 13.
Setting multiple pf_fallback_rules in /etc/rc.conf as per the
documentation produces invalid pf syntax due to the lack of echo
quoting $pf_fallback_rules in /etc/rc.d/pf. Adding quotes around
the $pf_fallback_rules echo maintains newlines needed for valid
pfctl syntax. Provided patch resolves the issue
Also updating rc.conf(5) to reflect that multi-line pf_fallback_rules
should not include a trailing backslash (\) as line breaks are
needed when passing rules to pfctl via stdin.
PR: 288197
Reviewed by: kp
MFC after: 2 weeks
(cherry picked from commit 9e8c1f9576)
- Removes duplicate E825C printout
- Fixes a package download issue with E830
- Updates mentions of E830-XXV to E830-L
- Fix FW logging on load issue by limiting the setting of FW log masks
and other global configuration to just the first PF of the controller
- Update ice_hw_autogen.h with timesync registers (unused in this
driver)
- Fix possible overflow condition in NVM access function
- Blocks RDMA load on E830 devices
Signed-off-by: Eric Joyner <[email protected]>
Tested by: Jeffrey Pieper <[email protected]>
Relnotes: yes
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D46950
(cherry picked from commit 440addc642)
(cherry picked from commit 5f92347a9b)
Fix a mistake in a log message that leaked from my preliminary patch.
PR: 287873
MFC after: 3 days
X-MFC-with: bd4a4e46ce
(cherry picked from commit 044febb24a)
Fetch vm_guest on startup in case we're running under a hypervisor.
Co-authored-by: eugen@
PR: 287873
Sponsored by: Netflix
(cherry picked from commit bd4a4e46ce)
Summary:
- Adds E830 device support
- Adds pre-release E825C support (for the Ethernet device included in
an upcoming Xeon D platform)
- Add sysctl for E810 devices to print out PHY debug statistics (mostly
for FEC debugging)
- Adds per-TX-queue tso counter sysctl to count how many times a TSO offload
was requested for a packet, matching other Intel drivers
- Various bug fixes
Signed-off-by: Eric Joyner <[email protected]>
Tested by: Jeffrey Pieper <[email protected]>
Relnotes: yes
Sponsored by: Intel Corporation
Differential Revisison: https://reviews.freebsd.org/D46949
(cherry picked from commit f2635e844d)
Primarily adds support for E830 devices, unlocking all of their
functionality.
As well, update the README and remove the non-FreeBSD sections
from it.
Signed-off-by: Eric Joyner <[email protected]>
Sponsored by: Intel Corporation
(cherry picked from commit f68513e7a4)
Prior to the 2022g import, tzloadbody() returned -1 on error. Now it
returns an errno code. When I updated the time zone change detection
logic to match, I improperly returned errno in all cases, which means
that if the time zone file has not changed since we last loaded it,
tzloadbody() returns a random errno value instead of 0.
Fixes: bc42155199
MFC after: 1 week
Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D51405
(cherry picked from commit d63ffdd1ef)
tzcode: Add an explicit "the timezone file has changed" case
This is required for the WITHOUT_DETECT_TZ_CHANGES case, since there the
value being tested is a numeric literal.
Fixes: d63ffdd1ef ("tzcode: Fix time zone change detection.")
(cherry picked from commit 0bf113e904)
The existing code frequently assigns unsigned 64-bit values to variables
that are signed and / or shorter without checking for overflow. Try to
deal with these cases.
While here, fix two structs that used single-element arrays in place of
flexible array members.
PR: 287896
MFC after: 1 week
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D51339
(cherry picked from commit 55f80afa17)
When recursing into a directory to delete it, start by chmod'ing it to
0700. This fixes an issue where kyua is able to run, but not debug, a
test case that creates unwriteable directories, because when debugging
it tries (and fails) to delete the directory after the test completes.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: igoro
Differential Revision: https://reviews.freebsd.org/D51229
(cherry picked from commit 9bf14f2a47)
[Clang][NFCI] Cleanup the fix for default function argument substitution (#104911)
(This is one step towards tweaking `getTemplateInstantiationArgs()` as
discussed in https://github.com/llvm/llvm-project/pull/102922)
We don't always substitute into default arguments while transforming a
function parameter. In that case, we would preserve the uninstantiated
expression until after, e.g. building up a CXXDefaultArgExpr and
instantiate the expression there.
For member function instantiation, this algorithm used to cause a
problem in that the default argument of an out-of-line member function
specialization couldn't get properly instantiated. This is because, in
`getTemplateInstantiationArgs()`, we would give up visiting a function's
declaration context if the function is a specialization of a member
template. For example,
```cpp
template <class T>
struct S {
template <class U>
void f(T = sizeof(T));
};
template <> template <class U>
void S<int>::f(int) {}
```
The default argument `sizeof(U)` that lexically appears inside the
declaration would be copied to the function declaration in the class
template specialization `S<int>`, as well as to the function's
out-of-line definition. We use template arguments collected from the
out-of-line function definition when substituting into the default
arguments. We would therefore give up the traversal after the function,
resulting in a single-level template argument of the `f` itself. However
the default argument here could still reference the template parameters
of the primary template, hence the error.
In fact, this is similar to constraint checking in some respects: we
actually want the "whole" template arguments relative to the primary
template, not those relative to the function definition. So this patch
adds another flag to indicate `getTemplateInstantiationArgs()` for that.
This patch also consolidates the tests for default arguments and removes
some unnecessary tests.
This fixes a crash or assertion failure while building tests for the
devel/hpx port.
PR: 288352
MFC after: 3 days
(cherry picked from commit ffc5ee0f57)
The error -1 is actually ERESTART in the context of syscall. It is for
kernel mode only and will not be passed to user mode. When the kernel
sees this error it will restart the syscall.
When the the SFP module data is not available, e.g. the SFP module is
not present, the ioctl handler returns ERESTART and kernel will retry
infinitely, hence the userland `ifconfig -v ql0` will hang forever until
get interrupted. That is apparently wrong.
Fix that by returning error ENODEV to indicate the SFP module data is
not available.
As for the case that ecore_ptt_acquire() fails, it appears to be quite
safe to restart, so keep returning ERESTART.
Reported by: Steve Wheeler
See also: https://redmine.pfsense.org/issues/16248
Reviewed by: kbowling
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D51351
(cherry picked from commit 12fea46407)
(cherry picked from commit f40f6374f3)
This addresses the problems encountered when parsing options in bluetooth-config.
- the optional parameters were not properly shifted after consumption
- the command line parameter count was checked before getopts and not after
Reported by: sjg
Approved by: kp
MFC after: 7 days
Event: Berlin Hackathon 202507
Differential Revision: <https://reviews.freebsd.org/D51281>
(cherry picked from commit 5031da2059)
sshd doesn't require these flags, and including them makes outgoing
connections (e.g., port forwarding) restricted to the family of the
inbound connection, which is not usually desirable and also not how
standalone sshd works.
MFC after: 3 days
Reviewed by: kevans
Approved by: kevans (mentor)
Differential Revision: https://reviews.freebsd.org/D51296
(cherry picked from commit 6738882248)
Per https://wiki.freebsd.org/DeprecationPlan, deprecate RIP in 15.0R,
with the intention of removing it in 16.0R.
Add a note to the manpages of routed(8), rdisc(8), rtquery(8),
route6d(8) and rip6query(8) noting that they will be removed
in a future release.
RIP has been obsolete for over 20 years and no one is running it on
modern networks. If someone really needs RIP, there are alternatives
such as 'bird' or 'quagga' available from ports; there is no need to
ship it in base.
Relnotes: yes
Reviewed by: des
Approved by: des (mentor)
Differential Revision: https://reviews.freebsd.org/D50292
(cherry picked from commit 4b7cdb5a42)
Replace "ifconfig -ul" with "ifconfig -n" because netlink-enabled
/sbin/ifconfig utility has sub-optimal performance for listing.
Combined with the commit b1b17432aa,
these changes mostly eliminate performance regression of the command
"service devd start" for a system having hundreds of network interfaces
created before devd starts, after FreeBSD 14+ switched
/sbin/ifconfig to netlink(4)
PR: 287872
(cherry picked from commit 6d3bc576ab)
(cherry picked from commit 24e8ed535f)
After applying FreeBSD-SA-24:05.pf, a problem with ICMP ECHO passing
through PF NAT was raised: two or more Windows workstations cannot ping
the same destination address at the same time. More precisely, only one
workstation pings normally, while the pings of the others are rejected
by the packet filter.
The thing is that Windows always uses the same ICMP ID (1). Therefore,
the state is created only for the workstation that started pinging
earlier.
In the pf_get_sport() function, we compare *nport with the ICMP_ECHO constant,
while icmptype (virtual_type actually) is passed in the pd->ndport parameter.
MFC after: 2 weeks
Reviewed by: kp
(cherry picked from commit e7abf8829d)
clang-scan-deps is used to generate dependency information from C++20
modules according to proposed standard ISO/IEC WG21 P1689R5[0]. It is
required by common build tools (e.g., CMake) to build C++ sources
that use modules.
Since this is a core build tool, install it by default, not gated
behind MK_CLANG_EXTRAS.
[0] https://www.open-std.org/JTC1/SC22/WG21/docs/papers/2022/p1689r5.html
MFC after: 3 days
Reviewed by: kevans, dim
Approved by: kevans (mentor)
Requested by: jbo
Differential Revision: https://reviews.freebsd.org/D51044
(cherry picked from commit d3c06bed2c)
This prevents a potential race that the ioctl threads see NULL or
uninitialized buckets.
Reviewed by: kp
Fixes: 4fc65bcbe3 pfsync: Performance improvement
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D51064
(cherry picked from commit edc307eca9)
(cherry picked from commit 8cc376735c)
So that the associated data with them will be freed.
Reviewed by: kp
Fixes: 4fc65bcbe3 pfsync: Performance improvement
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D51063
(cherry picked from commit 8213c07c20)
(cherry picked from commit efbaf14c5b)
On initializing the interface, if_alloc(IFT_PFSYNC) has set if_type
already.
No functional change intended.
MFC after: 1 week
(cherry picked from commit 48af70e7c8)
(cherry picked from commit 082a6da890)
ether_ifattach() no longer sets if_type to IFT_ETHER and keeps it as is
since the change [1].
[1] fc74a9f93a Stop embedding struct ifnet at the top of driver softcs
No functional change intended.
MFC after: 1 week
(cherry picked from commit a07604e626)
(cherry picked from commit 193f0bde3b)
That is unnecessary since change [1], as if_alloc(IFT_PROPVIRTUAL) has
set if_type already.
[1] fc74a9f93a Stop embedding struct ifnet at the top of driver softcs
No functional change intended.
MFC after: 1 week
(cherry picked from commit c43d6dadf7)
(cherry picked from commit 3da0853d71)
ether_ifattach() does not touch if_type, so it is not mandatory to fix
the if_type after ether_ifattach(). Without this change, the event
listeners, e.g. netlink, will see wrong interface type IFT_ETHER rather
than the correct one IFT_L2VLAN. There is also a potential race that
other threads see inconsistent interface type, i.e. initially IFT_ETHER
and eventually IFT_L2VLAN.
As a nice effect, this change eliminates the memory allocation for
if_hw_addr, as vlan(4) interfaces do not support setting or retrieving
the hardware MAC address yet [1].
[1] ddae57504b Persistently store NIC's hardware MAC address, and add a way to retrive it
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D50914
(cherry picked from commit a19b353d35)
(cherry picked from commit ff54b68038)
Ethernet drivers should respect IFF_PROMISC rather than IFF_PPROMISC.
The latter is for user-requested promisc mode, it implies the former
but not vice versa. Some in-kernel components such as if_bridge(4) and
bpf(4) will set promisc mode for interfaces on-demand.
While here, update the debugging message to be not confusing.
This was spotted while reviewing markj@ 's work D46524.
Test from Franco shows that the interface seems to be unconditionally
initialized to promisc mode regardless of this fix. That needs further
investigation.
Reviewed by: markj, Franco Fichtner <[email protected]>
Tested by: Franco Fichtner <[email protected]>
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D46794
(cherry picked from commit c7a2636889)
Bisecting identified the redacted send/receive as the source of the bug
for issue #12014. Specifically the call to
dsl_dataset_hold_obj(&fromds) has been replaced by
dsl_dataset_hold_obj_flags() which passes a DECRYPT flag and creates
a key mapping. A subsequent dsl_dataset_rele_flag(&fromds) is missing
and the key mapping is not cleared. This may be inadvertedly used, which
results in arc_untransform failing with ECKSUM in:
arc_untransform+0x96/0xb0 [zfs]
dbuf_read_verify_dnode_crypt+0x196/0x350 [zfs]
dbuf_read+0x56/0x770 [zfs]
dmu_buf_hold_by_dnode+0x4a/0x80 [zfs]
zap_lockdir+0x87/0xf0 [zfs]
zap_lookup_norm+0x5c/0xd0 [zfs]
zap_lookup+0x16/0x20 [zfs]
zfs_get_zplprop+0x8d/0x1d0 [zfs]
setup_featureflags+0x267/0x2e0 [zfs]
dmu_send_impl+0xe7/0xcb0 [zfs]
dmu_send_obj+0x265/0x360 [zfs]
zfs_ioc_send+0x10c/0x280 [zfs]
Fix this by restoring the call to dsl_dataset_hold_obj().
The same applies for to_ds: here replace dsl_dataset_rele(&to_ds) with
dsl_dataset_rele_flags().
Both leaked key mappings will cause a panic when exporting the
sending pool or unloading the zfs module after a non-raw send from
an encrypted filesystem.
Contributions-by: Hank Barta <[email protected]>
Contributions-by: Paul Dagnelie <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Richard Yao <[email protected]>
Reviewed-by: Rob Norris <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: George Amanakis <[email protected]>
Closes#12014Closes#17340
(cherry picked from commit ea74cdedda)
After importing the latest libarchive into FreeBSD, Shawn Webb @
HardenedBSD noted that the test build is broken when FORTIFY_SOURCE=2
while building the base system. Braced initializer lists are a special
case that need some extra fun parentheses when we're dealing with the
preprocessor.
While it's not a particularly common setup, the extra parentheses don't
really hurt readability all that much so it's worth fixing for wider
compatibility.
This corresponds to libarchive PR #2660
Reported by: Shawn Webb (HardenedBSD)
(cherry picked from commit e2a605e7ab)
libarchive 3.8.1
New features:
#2088 7-zip reader: improve self-extracting archive detection
#2137 zip writer: added XZ, LZMA, ZSTD and BZIP2 support
#2403 zip writer: added LZMA + RISCV BCJ filter
#2601 bsdtar: support --mtime and --clamp-mtime
#2602 libarchive: mbedtls 3.x compatibility
Security fixes:
#2422 tar reader: Handle truncation in the middle of a GNU long linkname
(CVE-2024-57970)
#2532 tar reader: fix unchecked return value in list_item_verbose()
(CVE-2025-25724)
#2532 unzip: fix null pointer dereference (CVE-2025-1632)
#2568 warc: prevent signed integer overflow (CVE-2025-5916)
#2584 rar: do not skip past EOF while reading (CVE-2025-5918)
#2588 tar: fix overflow in build_ustar_entry (CVE-2025-5917)
#2598 rar: fix double free with over 4 billion nodes (CVE-2025-5914)
#2599 rar: fix heap-buffer-overflow (CVE-2025-5915)
Important bugfixes:
#2399 7-zip reader: add SPARC filter support for non-LZMA compressors
#2405 tar reader: ignore ustar size when pax size is present
#2435 tar writer: fix bug when -s/a/b/ used more than once with b flag
#2459 7-zip reader: add POWERPC filter support for non-LZMA compressors
#2519 libarchive: handle ARCHIVE_FILTER_LZOP in archive_read_append_filter
#2539 libarchive: add missing seeker function to archive_read_open_FILE()
#2544 gzip: allow setting the original filename for gzip compressed files
#2564 libarchive: improve lseek handling
#2582 rar: support large headers on 32 bit systems
#2587 bsdtar: don't hardlink negative inode files together
#2596 rar: support large headers on 32 bit systems
#2606 libarchive: support @-prefixed Unix epoch timestamps as date strings
#2634 tar: Support negative time values with pax
#2637 tar: Keep block alignment after pax error
#2642 libarchive: fix FILE_skip regression
#2643 tar: Handle extra bytes after sparse entries
#2649 compress: Prevent call stack overflow
#2651 iso9660: always check archive_string_ensure return value
CVE: CVE-2024-57970, CVE-2025-1632, CVE-2025-25724,
CVE-2025-5914, CVE-2025-5915, CVE-2025-5916,
CVE-2025-5917, CVE-2025-5918
PR: 286944 (exp-run on main, libarchive 3.8.0)
(cherry picked from commit 2e113ef824)
Someone should really do a vendor import, but it's non-trivial, as we
have local modifications. In the meantime, here's a nine-year-old
upstream patch which allows service names to be used instead of port
numbers.
MFC after: 1 week
Obtained from: OpenBSD
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D50348
(cherry picked from commit 6d3d1fc3a3)
Many if not most ports that install PAM modules install them into
${LOCALBASE}/lib/security instead of just ${LOCALBASE}/lib, because
all the world is Linux. Rather than try to fix the ports, add that
directory to the search path.
MFC after: 1 week
Relnotes: yes
Reviewed by: delphij
Differential Revision: https://reviews.freebsd.org/D50626
(cherry picked from commit bb625fc2ac)
We (correctly) NULL out sk and nk before calling pf_return(), but that
function still tried to use them to undo NAT transformations.
Store the old port numbers and use those rather than sk/nk.
This is a partial import of e11dacbf84
(osport/odport), and the missing parts of
bdea9cbcf2.
Direct commit to stable/14.
PR: 287254
(cherry picked from commit 6f6ca52880)
Some of ARC statistic sysctls changed years ago, but those tools
are still using legacy shims, that are going to be removed.
MFC after: 3 days
(cherry picked from commit 8aad1e6148)
In /usr/include/c++/v1/__locale_dir/locale_base_api.h, xlocale.h is
included without first including stdio.h and stdlib.h, which causes
functions like strtoll_l() or sscanf_l() to not be declared.
When compiling with -fmodules, locale_base_api.h is processed separately
due to a declaration in /usr/include/c++/v1/module.modulemap, and this
will cause errors due to the above undeclared symbols.
Meanwhile, upstream has substantially reorganized this part of libc++'s
headers, so apply a minimalistic workaround: specifically when compiling
with -fmodules, add includes of stdio.h and stdlib.h.
PR: 286342
MFC after: 1 week
(cherry picked from commit c809b0184d)
The commit teaching the build to install tzdata.zi for libcxx also
instals version. It turns out this makes at least one piece of third
party software cry: rubygem-tzinfo expects any file in zoneinfo to be at
least 44 bytes long. Clearly this is a bug in rubygem-tzinfo but since
nothing actually uses version, we may as well not install it ... as we
did previously.
Reported by: delphij
Fixes: 91506dba7f zoneinfo: also install tzdata.zi and version
MFC after: 1 day
(cherry picked from commit 23a0c88b03)
Currently, service(8) requires the user to provide a command to the
rc service script. For example,
service cron
does not even run the cron rc service script but
instead shows the usage message of service(8).
This patch makes it so running the rc service script with no arguments
via service(8) is closer to running the rc service script directly
(e.g., /etc/rc.d/cron).
Long story short, for most of the rc service scripts this change means
that running "service FOO" now shows the usage message of FOO instead of
the usage message of service(8).
PR: 255115
Reviewed by: bnovkov, christos, imp, lme, markj
Approved by: bnovkov (mentor), christos (mentor), markj (mentor)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D47328
(cherry picked from commit 7ffedfe14c)
instead of accepting any character as a delimiter, only accept ':', '.'
and '-', and only permit a single delimiter in an address.
this prevents accepting bizarre addresses like:
ifconfig epair2a link 10.1.2.200/28
... which is particularly problematic on an INET6-only system, in which
case ifconfig defaults to the 'link' family, meaning that:
ifconfig epair2a 10.1.2.200/28
... changes the Ethernet address of the interface.
bump __FreeBSD_version so link_addr() consumers can detect the change.
Reviewed by: kp, des
Approved by: des (mentor)
Differential Revision: https://reviews.freebsd.org/D49936
(cherry picked from commit a121509041)
previously these _KERNEL functions were inconsistent, with some having
parameter names and some not. fix this by giving them all names, per
style(9).
Reviewed by: thj, des
Approved by: des (mentor)
Differential Revision: https://reviews.freebsd.org/D50219
(cherry picked from commit 8c7d193e3c)
this is a re-entrant version of link_ntoa. use an in-out parameter for
the buffer size, so the user requires at most two calls to determine the
needed size.
reimplement link_ntoa using link_ntoa_r with a static buffer.
Reviewed by: des
Approved by: des (mentor)
Differential Revision: https://reviews.freebsd.org/D50202
(cherry picked from commit da509c2908)
for now, since link_addr() has no way to indicate an error, these are
only positive tests which check the outcome of valid inputs.
Reviewed by: ngie, des, adrian
Approved by: des (mentor)
Differential Revision: https://reviews.freebsd.org/D50062
(cherry picked from commit 757e973fb2)
link_addr_test: use <cstddef>, not <sys/stddef.h>
<cstddef> is the correct header; this fixes the GCC build.
while here, sort the headers.
Fixes: 757e973fb2 ("libc tests: add tests for link_addr(3) and link_ntoa(3)")
Reviewed by: des
Approved by: des (mentor)
Differential Revision: https://reviews.freebsd.org/D50189
(cherry picked from commit bbffdfef3b)
column(1): add tests
Reviewed by: des
Approved by: des (mentor)
Differential Revision: https://reviews.freebsd.org/D49911
(cherry picked from commit 6f2b1b56ac)
column(1): add -l flag
the '-l <tblcols>' flag limits the number of columns that column(1) will
produce in -t mode. this is syntax-compatible with the same option in
util-linux's column(1), but due to existing differences between the two
implementations, it's not semantically compatible.
as a side-effect, fix a pre-existing bug where empty fields could cause
incorrect output:
% echo ':' | column -ts:
(null)
while here, also fix a couple of minor existing issues.
Reviewed by: des
Approved by: des (mentor)
Differential Revision: https://reviews.freebsd.org/D50290
(cherry picked from commit 313713b24c)
__nodiscard adds the [[nodiscard]] attribute to a function, type or
constructor in C or C++, causing a value so marked to issue a compiler
warning if it is discarded (i.e., not used or assigned) other than by
casting it to void.
this replaces the existing __result_use_or_ignore_check, which has a
similar purpose but different semantics. since __nodiscard provides
more functionality (at least in GCC) and __result_use_or_ignore_check
only had a single user, remove __result_use_or_ignore_check.
[[nodiscard]] has been supported in C++ since C++17, but only in C since
C23; however, both LLVM and GCC implement it even in older language
versions, so it should always be available with a relatively modern
compiler.
for Clang, [[nodiscard]] in C is only available since LLVM 17, but we
can fall back to __attribute__((__warn_unused_result__)) which has the
same semantics and provides support back to (at least) LLVM 11.
GCC supports [[nodiscard]] in both C and C++ since at least GCC 11.
for GCC, we can't provide a fallback as the semantics of its
warn_unused_result are different, but since __result_use_or_ignore_check
isn't defined for GCC anyway, we don't lose anything here.
MFC after: 2 weeks
Reviewed by: des, emaste
Approved by: des (mentor)
Differential Revision: https://reviews.freebsd.org/D50217
(cherry picked from commit 7e0c5e0128)
Update the xen(4) man page to reflect the current support status.
Reported by: kevans
Reviewed by: bcr kevans imp
Differential revision: https://reviews.freebsd.org/D43373
(cherry picked from commit 82126ef92f)
ether_vlanid_t is a type to represent a VLAN ID, for example inside a
.1q tag. since this is specific to Ethernet, put it in net/ethernet.h.
change bridge to use the new type instead of uint{16,32}_t.
Reviewed by: adrian, kp
Differential Revision: https://reviews.freebsd.org/D49836
(cherry picked from commit 96f830456f)
Using a local socket circumvents the issue of needing any Internet
protocol (PF_INET or PF_INET6) support.
We only use interface ("i" group) ioctls on this socket so we can get
away with using PF_LOCAL instead of requring any Internet protocol
(PF_INET or PF_INET6) support on the system. This simplifies the
patch from 8c7149c73f.
PR: 286259
Noted by: kevans
Fixes: 8c7149c73f
Reviewed by: kevans, philip,
zarychtam_plan-b.pwste.edu.pl (mzar)
Differential revision: https://reviews.freebsd.org/D50050
(cherry picked from commit 6aeec6a741)
Currently, wpa_supplicant fails when legacy IP support is disabled
in FreeBSD (i.e., the world built with WITHOUT_INET and nooptions
INET in the kernel config). The proposed patch allows running
wpa_supplicant and connecting to wireless networks without INET
support when INET6 is available.
Reviewed by: cy, adrian, philip, roy_marples.name
Differential Revision: https://reviews.freebsd.org/D49959
(cherry picked from commit 8c7149c73f)
Patch supplied by mi@ through a private email.
Bump __FreeBSD_version for ports that might need this.
PR: 280025
(cherry picked from commit d5c8041388)
In 2e47f35be5, libllvm, libclang and liblldb became shared libraries,
so make sure the binaries that depend on these libraries get rebuilt.
MFC after: 2 weeks
(cherry picked from commit d4dab32448)
This allows clang, lld, lldb, and other llvm tools to be linked against
these shared libraries, which makes them smaller and avoids duplication.
Since these are not quite the same as the shared libraries shipped by
the upstream llvm build system, and we do not want to expose the ABI to
external programs such as ports, make them private libraries.
Note that during the cross-tools stage they are still built as static
libraries, so the cross compiler and linker are static binaries, as they
have always been.
This also requires a depend-cleanup.sh kludge which will be added in a
follow-up commit, to ensure binaries are rebuilt against the shared
libraries in case of incremental builds.
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D49967
(cherry picked from commit 2e47f35be5)
include <sys/_types.h> for u_char and u_short.
to avoid including <sys/types.h>, remove the caddr_t cast from LLADDR.
we are trying to get rid of caddr_t anyway, and since sdl_data is
already an array of char, the cast is unnecessary. this also makes
LLADDR const-correct, i.e. passing a const sockaddr_dl will return a
const pointer.
Reviewed by: des
Approved by: des (mentor)
Differential Revision: https://reviews.freebsd.org/D50065
(cherry picked from commit 70b5c91857)
to avoid strange precedence errors, enclose the macro body in
parentheses. this fixes constructs like: if (VLANTAGOF(m) == i)
Reviewed by: kp
(cherry picked from commit f36292f010)
this prevents the file being overwritten every time FreeBSD-runtime is
upgraded.
Reviewed by: des
Approved by: des (mentor)
Differential Revision: https://reviews.freebsd.org/D49907
(cherry picked from commit eef0c78e43)
Build and install the shrunk version of the time zone database required
by libc++ 19 std::chrono::current_zone (etc). While here, also install
the tzdata 'version' file to align more closely with other vendors.
PR: 282377
Reviewed by: dim, emaste, imp
Differential Revision: https://reviews.freebsd.org/D49577
(cherry picked from commit 91506dba7f)
When object files for programs are built using bsd.prog.mk, and WITH_PIE
is enabled, the extension used is still plain ".o". To be consistent
with bsd.lib.mk, and to allow changes in WITH_PIE settings to propagate
correctly, the extension should be ".pieo" instead.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D49966
(cherry picked from commit 245bb01106)
Mountd reloads the exports(5) file(s) when it receives a SIGHUP
and then compares the old and new exports, updating any ones that
have changed in the kernel.
Without this patch, mountd failed to recognize that a network/host(s)
had changed, if there was no other change to the exports line.
As such, the change of network/hosts(s) did not take effect until
the mountd daemon was (re)started.
This patch fixes the code so that it checks for changes in
the network/host(s) list for an exports line.
PR: 286260
(cherry picked from commit 68daa781c1)
Changes since 2.8.0:
Bug Fixes:
* Fix LLQ normal width misconfiguration
* Check for errors when detaching children first, not last
Minor Changes:
* Remove \n from sysctl description
Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.
Differential Revision: https://reviews.freebsd.org/D50041
(cherry picked from commit 59b30c1a86)
Patch 0a33c047a443 introduced new values to
hw.ena.force_large_llq_header. The default value of 2 means no
preference, while 0 and 1 act as the previous false and true
respectively, which allowed forcefully setting regular or large LLQ.
There are 2 ways to force the driver to select regular LLQ:
1. Setting hw.ena.force_large_llq_header = 0 via sysctl.
2. Turning on ena express, which makes the recommendation by the FW to
be regular LLQ.
When the device supports large LLQ but the driver is forced to
regular LLQ, llq_config->llq_ring_entry_size_value is never initialized
and since it is a variable allocated on the stack, it stays garbage.
Since this variable is involved in calculating max_entries_in_tx_burst,
it could cause the maximum burst size to be zero. This causes the driver
to ignore the real maximum burst size of the device, leading to driver
resets in devices that have a maximum burst size (Nitro v4 and on. see
[1] for more information).
In case the garbage value is 0, the calculation of
max_entries_in_tx_burst divides by 0 and causes kernel panic.
The patch modifies the logic to take into account all use-cases and
ensure that the relevant fields are properly initialized.
[1]: https://docs.aws.amazon.com/ec2/latest/instancetypes/ec2-nitro-instances.html
Fixes: 0a33c047a443 ("ena: Support LLQ entry size recommendation from device")
Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.
Differential Revision: https://reviews.freebsd.org/D50040
(cherry picked from commit 56c45700f2)
Any events left over from boot firmware, etc. are not meaningful so
clear pending events during attach. If they are still pending they
should remain asserted when the slot status register is re-read.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D49950
(cherry picked from commit ff45e4759a)
At least some PCI-express bridges exposed by Intel Volume Management
Devices report bogus power faults in their slot status register. As a
workaround, ignore the power fault detected flag if the slot
capability register does not indicate support for a power controller.
While the PCI-e spec does not explicitly state that the PFD flag
should always be zero if a power controller is not present, parts of
the spec do seem to assume this. For example, the flag is included in
the "Power Controller Registers" register group in 6.7.2.4, and the
definition of the value for this flag seems to presume the presence of
a power controller:
If a Power Controller that supports power fault detection is
implemented, this bit is Set when the Power Controller detects a
power fault at this slot. Note that, depending on hardware
capability, it is possible that a power fault can be detected at
any time, independent of the Power Controller Control setting or
the occupancy of the slot. If power fault detection is not
supported, this bit must not be Set.
PR: 285993
Reported by: Jim Long <[email protected]>
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D49949
(cherry picked from commit 4c8b9f40cd)
The Secure RPC authenticator for telnet prompts the local user for the
username to use for authentication. Previously it was using sprintf()
into a buffer of 256 bytes, but the username received over the wire
can be up to 255 bytes long which would overflow the prompt buffer.
Fix this in two ways: First, use snprintf() and check for overflow.
If the prompt buffer overflows, fail authentication without prompting
the user. Second, add 10 bytes to the buffer size to account for the
overhead of the prompt so that a maximally sized username fits.
While here, replace a bare 255 in the subsequent telnet_gets call with
an expression using sizeof() the relevant buffer.
PR: 270263
Reported by: Robert Morris <[email protected]>
Tested on: CHERI
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D49832
(cherry picked from commit 5737c2ae06)
We need to pass this to cloudware builds, not just VM builds.
MFC after: 4 days
Fixes: 81ca663642 ("release: Pass PKG_INSTALL_EPOCH to vmimage.subr")
Sponsored by: Amazon
(cherry picked from commit d14036ea42)
This value, if not already set, comes from the timestamp of the most
recent git commit (which is now also available in src/release code as
GITEPOCH) or 0 if git is not installed.
This should allow /var/db/pkg/local.sqlite to be reproducible in VM
images which have packages installed (e.g. cloudware).
Reviewed by: emaste, bapt
MFC after: 5 days
Sponsored by: Amazon
Differential Revision: https://reviews.freebsd.org/D49760
(cherry picked from commit 81ca663642)
To make it possible to use the .SUFFIXES list and suffix-transformation
rules from bsd.lib.mk in other places, move them to a separate file,
bsd.suffixes-extra.mk.
Note that we cannot add the list and rules to bsd.suffixes.mk, since
that file also gets included by sys.mk, which applies to non-source
builds. That would require a whole ports exp-run.
No functional change intended.
Reviewed by: brooks, emaste
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D49965
(cherry picked from commit 9c4f1497da)
This is not harmful when making a static library apparently, but will
result in duplicate symbol errors when making a dynamic library.
MFC after: 3 days
(cherry picked from commit 160a2ba804)
In general we are working towards making public headers self-contained.
cdefs.h is included for __packed; just assume that types.h includes
cdefs.h as that's a very common assumption.
PR: 285924
Reviewed by: emaste
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D49735
(cherry picked from commit 31d3a94bdd)
When WITH_CLANG_BOOTSTRAP and WITHOUT_CLANG are both set, the
cross-tools stage does not build a cross clang binary. This is because
the Makefile in usr.bin/clang checks for WITHOUT_CLANG, and skips
building the binary.
To fix this, ensure that WITH_CLANG is set for the cross-tools phase
whenever WITH_CLANG_BOOTSTRAP is set. While here, skip using the
Makefile in usr.bin/clang, and directly use the Makefile in
usr.bin/clang/clang instead.
PR: 286154
Reported by: avg
Reviewed by: avg, emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D49886
(cherry picked from commit ea231471d0)
Until July 2024, dhclient kept track of time as seconds-since-epoch as
a time_t. This was a problem because (a) we wanted sub-second timeouts
and (b) timeouts didn't always do the right thing if the system clock
changed.
Switching to using CLOCK_MONOTONIC and struct timespec fixed those
issues but introduced a new problem: CLOCK_MONOTONIC values were being
intepreted as seconds-since-epoch and written to the dhclient.leases
file, causing confusion with DHCP leases expiring in early 1970.
Attempt to compromise between these by keeping track of both times;
any type within dhclient which is a time_t now refers to seconds past
the epoch, while any struct timespec value is a CLOCK_MONOTONIC time.
PR: 283256
Reviewed by: dch
Fixes: f0a38976b0 ("dhclient: Use clock_gettime() instead of time()")
Sponsored by: Amazon
Differential Revision: https://reviews.freebsd.org/D49720
(cherry picked from commit 43d19e6a4c)
Just as for nat anchors we can't print counters for rule anchors. Remove the
incorrect print call.
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
(cherry picked from commit 0fc3c29fb3)
When printing a nat anchor we don't have rule information, or rule
counters. Do not attempt to print them. The information is nonsensical
anyway, and this can cause a crash converting the timestamp to a string,
as years in the very distant future use more digits, and we exceed the
30 byte buffer allocated for this.
MFC after: 2 weeks
Sponsored by: Orange Business Services
(cherry picked from commit 168d873ae4)
After the pf_state_insert() call we may not use these pointers again.
Explicitly NULL them to ensure we don't.
Also NULL them out if we free the keys directly.
Reviewed by: glebius, markj
MFC after: 3 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D49553
(cherry picked from commit 5924183433)
pf_state_insert() may free the state keys, it's not safe to access these
pointers after the call.
Introduce osrc/odst (similar to osport/odport) to store the original source and
destination addresses. This allows us to undo NAT transformations without having
to access the state keys.
Reviewed by: glebius, markj
MFC after: 3 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D49551
(cherry picked from commit bdea9cbcf2)
If we fail to attach the stack key that means we've already attached the wire
key. That means the state could be found by other cores, and given that we then
free it, be used after free.
Fix this by not releasing the ID hashrow lock and key locks until after we've
removed the inserted key again, ensuring the state cannot be found by other
cores.
Reported by: markj
Submitted by: glebius
Reviewed by: glebius, markj
MFC after: 3 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D49550
(cherry picked from commit 8efd2acf07)
Renumber the private flags so there is a sizeable gap between them and
the public flags, making it easier to add public flags in the future.
These private flags are only ever set or read by FTS itself, so there
is no compatibility issue.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D49711
(cherry picked from commit 80e06d621a)
This adds a basic test that __cxa_atexit works, and also adds some tests
for __cxa_atexit handlers registered in the middle of __cxa_finalize.
PR: 285870
(cherry picked from commit ee9ce1078c)
science/dlib-cpp reveals an interesting scenario that works fine on
other platforms but not on FreeBSD; notably, it ends up creating a new
global object from some destructor which is called during
__cxa_finalize. This breaks when libdlib is dlopen()ed and then
subsequently dlclose()ed, as we never end up invoking the created
object's dtor until program exit when the shlib is already unmapped.
Fix it by noting when we're in the middle of __cxa_finalize for a dso,
and then restarting the search if __cxa_atexit() was called in the
middle somewhere.
We wait until we've processed the initial set before starting over and
processing the newly added handlers as if it were a complete set of
handlers added during runtime. The alternative is calling them as
they're added to maintain a LIFO in terms of total ordering, but in
theory a constructor could add another global object that also needs to
be destroyed, and that object needs to be destroyed after the one that
constructed it to avoid creating unexpected lifetime issues.
This manifests in the pdlib PHP extension for dlib crashing, see [0].
[0] https://github.com/goodspb/pdlib/issues/39
PR: 285870
Reviewed by: kevans (also supplied commit message)
(cherry picked from commit 23427c8e1f)
pfctl_show_nat() is called recursively to print nat anchors. This passes the
anchor path, but this path was modified by pfctl_show_nat(), leading to issues
printing the anchors.
Make a copy of the path ('npath') before we modify it. Ensure we do this
correctly by sprinking in 'const', and add a test case to verify that we do now
print things correctly.
Reported by: Thomas Pasqualini <[email protected]>
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
(cherry picked from commit 58164dcb55)
This option was documented as disabling X11 and agent forwarding but it
failed to do so. Spotted by Tim Rice.
Obtained from: OpenBSD d31ec64016fc
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 3620d70511)
(cherry picked from commit fcda475ccf)
Check if CTS bit is set in the mailbox message before waiting for ACK.
Otherwise ACK will never be received causing the function to timeout. Add
a note for ixgbe_write_mbx that it should be called while holding a lock.
Fixes: 6d243d2 ("net/ixgbe/base: introduce new mailbox API")
Cc: [email protected]
Signed-off-by: Norbert Ciosek <[email protected]>
Signed-off-by: Anatoly Burakov <[email protected]>
Acked-by: Bruce Richardson <[email protected]>
Obtained from: DPDK (1f119e4)
(cherry picked from commit 1580f8d9c1)
Summary:
The device IDs for these were in the driver's list of PCI ids to attach
to, but igc_set_mac_type() had never been setup to set the correct mac
type for these devices. Fix this by adding these IDs to the switch block
in order for them to be recognized by the driver instead of returning an
error.
This fixes the igc(4) attach for the I226-K LOM on the ASRock Z790
PG-ITX/TB4 motherboard, allowing it to be recognized and used.
Signed-off-by: Eric Joyner <[email protected]>
Reviewed by: kbowling@
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D49147
(cherry picked from commit 7ee310c80e)
pfInterfacesIfRefsState was described as 'Null', which upset bsnmpwalk's attempt
to resolve OIDs to symbolic names:
> bsnmpwalk: Error adding leaf pfInterfacesIfRefsState to list
This was done back in d6d3f01e0a, because we don't return this value any
more. Return it to 'Unsigned32', which fixes things, even if we still don't
actually return this value.
While here update the ORGANIZATION to reflect current ownership.
Reviewed by: philip
MFC after: 2 weeks
Event: Tokyo Hackathon 202503
Differential Revision: https://reviews.freebsd.org/D49413
(cherry picked from commit 712309a645)
- Prune headers and tests no longer installed after the upgrade.
- Remove GoogleTest-related files when MK_GOOGLETEST == no.
- Disable `-Werror` with gcc to unbreak the gcc12 CI run with
`lib/googletest`. Any issues found by g++ will be filed
upstream and hopefully resolved in a future version.
- Remove clang -Werror issues which are resolved in version 1.14.0 to
avoid masking valid issues.
Conflicts:
ObsoleteFiles.inc
tools/build/mk/OptionalObsoleteFiles.inc
MFC after: 1 week
MFC with: 28f6c2f292
(cherry picked from commit 0c785f0602)
This test case verifies that grep detects symlink loops when traversing
a directory hierarchy.
Fixes: fc12c191c0 ("grep: Default to -p instead of -S.")
Reviewed by: ngie, jhb
Reported by: Jenkins
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D46544
(cherry picked from commit a700bef1e4)
After commit 389a3fa693, uma_reclaim_domain(UMA_RECLAIM_DRAIN_CPU)
calls uma_zone_reclaim_domain(UMA_RECLAIM_DRAIN_CPU) twice on each zone
in addition to globally draining per-CPU caches. This was unintended
and is unnecessarily slow; in particular, draining per-CPU caches
requires binding to each CPU.
Stop draining per-CPU caches when visiting each zone, just do it once in
pcpu_cache_drain_safe() to minimize the amount of expensive sched_bind()
calls.
Fixes: 389a3fa693 ("uma: Add UMA_ZONE_UNMANAGED")
MFC after: 1 week
Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.
Reviewed by: gallatin, kib
Differential Revision: https://reviews.freebsd.org/D49349
(cherry picked from commit f506d5af50)
If the `setlocale()` call fails, emit a warning and sleep briefly so the
user has a chance to see the warning before we redraw the screen. Note
that we have no way of knowing exactly what is wrong, but at least we
can suggest that they check their environment.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D49230
(cherry picked from commit 180065eb09)
This change modifies dumpon to print out the last error from OpenSSL
when `PEM_read_RSA_PUBKEY` fails. This allows end-users to diagnose why
reading in RSA pubkey files fails so they can adjust the usage to meet
the needs of the command.
MFC after: 1 week
(cherry picked from commit 52b63df9b6)
Per the "Intel® 64 and IA-32 Architectures Software Developer’s Manual
Combined Volumes: Vol. 3B 17-7", the Green and Yellow threshold
indicators are mutually exclusive. Add the missing `break` statements so
they're treated that way.
MFC after: 1 week
Reported by: Coverity
Differential Revision: https://reviews.freebsd.org/D48722
(cherry picked from commit 36d7d2044b)
This change officially documents the fact that the `volume cache
enabled` and `volume cache disabled` are also supported.
While here, remove an unnecessary newline at the end of a warn*(3) call.
warn*(3) adds a newline automatically.
MFC after: 1 week
(cherry picked from commit 9a49a37929)
Normalize on hard tabs.
I didn't catch this before pushing the previous commit.
No functional changes intended.
MFC after: 2 weeks
MFC with: 8ef8da882f
(cherry picked from commit 61b15e6dfc)
This change is being done first so any functional changes from the tests
will be clearer to reviewers.
No functional change intended.
MFC after: 2 weeks
Ref: https://reviews.freebsd.org/D47826
(cherry picked from commit 991bd46162)
io.cc relies on `std::setw(..)`, which is exported by the iomanip C++
header. Newer versions of GoogleTest don't export this header, so add
the explicit include.
This unbreaks the build with GoogleTest 1.15.2.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D47194
(cherry picked from commit 0077477f21)
GoogleTest 1.14.0 now requires C++14 to build. Change
`googletest.test.inc.mk` to reflect this requirement.
Adjust the build integration logic to handle the new version of
GoogleTest (add/remove headers/sources as needed).
Tighten down warnings via `CXXFLAGS.clang` instead of ignoring all
warnings. Some new warnings snuck in after I did my last round of fix
submissions upstream.
Also address some overlinking added in the previous version import by
removing superfluous libraries.
===============================
Expect WhenDynamicCastToTest.AmbiguousCast to fail
This change reapplies the expected failure from 1.10.0.
Ref: https://github.com/google/googletest/issues/2172
MFC after: 2 weeks
Reviewed by: asomers, emaste
Differential Revision: https://reviews.freebsd.org/D41399
Merge commit '8ef491440fcaec96f899d73e08873426c78583a4' into googletest-v1.14.0-import
(cherry picked from commit 28f6c2f292)
`INSTANTIATE_TEST_CASE_P` has been replaced with `INSTANTIATE_TEST_SUITE_P`.
Replace all uses of the former macro with the latter macro.
While here, address the fact that the latter macro doesn't permit some
of the constructions that the former macro did, e.g., empty parameters,
etc.
Conflicts:
tests/sys/fs/fusefs/fallocate.cc (fix applied manually)
tests/sys/fs/fusefs/io.cc (change reverted)
MFC after: 2 weeks
Reviewed by: asomers
Differential Revision: https://reviews.freebsd.org/D41398
(cherry picked from commit 811e0a31ac)
dialog4ports has been replaced with portconfig for several years.
It was marked as deprecated and broken in ports:61e4a788ecab.
While here, tag SPDX.
MFC after: 3 days
Reported by: Community Discord
Reviewed by: bapt (previous version), mhorne
Approved by: mhorne (mentor)
Differential Revision: https://reviews.freebsd.org/D49204
(cherry picked from commit 3bf433f141)
98e34e8e25 circumvented an upstream patch which caused an IPv6
pool regresson. This patch removes the circumvention and replaces
it with an upstream patch planned for the new release of ntp.
(cherry picked from commit bc02e65587)
98e34e8e25 circumvented an upstream patch which caused an IPv6
pool regression. This patch, discussed in
https://bugs.ntp.org/show_bug.cgi?id=3958, addresses another
unworkable combination of link-local local address with
non-link-local server.
(cherry picked from commit c1767cf87c)
Upstream bug 3943 (https://bugs.ntp.org/show_bug.cgi?id=3943) discusses:
Starting with 4.2.8p18 ntp does not synchronize or even connect to the
configured NTP server any more. ntp stays in .INIT. state indefinitely
and checking the network traffic shows that ntp does not attempt to
contact the NTP server.
This is regression introduced by the fix for upstream bug 3913. This
is a similar bug I reported upstream (ntp bug 3841).
(cherry picked from commit 381956e267)
Starting with POSIX-1.2008, "The SA_RESETHAND, SA_RESTART, SA_SIGINFO,
SA_NOCLDWAIT, and SA_NODEFER constants are moved from the XSI option to
the Base." Make them so visible.
PR: 275328
Sponsored by: Netflix
(cherry picked from commit 06af7bd12a)
The length of key data is specified via sadb_key_bits field.
Use specified size for buffer allocation and key copying.
Also add a check that the value of sadb_key_bits is not zero,
as explicitly required in RFC 2367.
PR: 241010
Submitted by: jean-francois.hren at stormshield eu
(cherry picked from commit 04207850a9)
Use correct indent number to dump registered socket options.
It is not currently in use but can be used for debugging.
PR: 283970
(cherry picked from commit b405250c77)
Using the ntpd -u option to set the credentials ntpd is to run under
while still using rc(8) to invoke causes some FreeBSD installs to fail
to load mac_ntp. The fact that that can_run_nonroot() does not
indicate why failures occur leaves people on the mailing lists
guessing as to why there are failures. Let's revert back to using
the rc(8) provided su. The ntpd rc script will be rewritten when
the ntpd chroot will be implemented.
Reported on: freebsd-stable@
This reverts commit 521f66715a.
(cherry picked from commit 5ca7754519)
sin_addr of a `struct sockaddr_in` is stored in network byte order, but
IN_LOOPBACK() and IN_LINKLOCAL() want the host order.
Reviewed by: melifaro, #network
Fixes: 7e5bf68495 netlink: add netlink support
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D49226
(cherry picked from commit 0e096bb3fc)
(cherry picked from commit 057165012b)
While here, add one additional IPv4 link-local address to test_46_nofilter
to cover the IPv4 RT_SCOPE_LINK case.
Reviewed by: melifaro, #network
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D49226
(cherry picked from commit 5d8b48487a)
(cherry picked from commit e84a17db1c)
Clean up style and make more consistent.
Replace test with if-then-else to make the script more legible.
Replace the call to dirname with the shell %/* operator avoiding a
fork & exec.
Reorder the test for $var_run_autosave before the test for /var/run on
tmpfs. This avoids gratuitously scanning the mount table for a tmpfs
/var/run.
Initial concept by and in discussion with:
Harry Schmalzbauer <[email protected]>
No functional change intended.
MFC after: 2 weeks
Differnential revision: https://reviews.freebsd.org/D47773
(cherry picked from commit ed9712f894)
1000Base-BX uses two wavelengths, commonly 1310nm, 1490nm, 1550nm, or
1590nm, in a Coarse Wavelength Division Multiplexing (CWDM) arrangement
so that a single fiber strand may carry both upstream and downstream.
It is sometimes referred to as BiDi for bi-directional usage of one
fiber.
Optics must be paired such that the RX and TX wavelengths cross over,
with one side often called U(pstream) and the other D(ownstream).
This technology is useful for increasing link density or working around
construction issues, and is also frequently used as a last mile delivery
technology for FTTx.
Sponsored by: BBOX.io (review/commits)
Pull Request: https://github.com/freebsd/freebsd-src/pull/1518
(cherry picked from commit 78c63ed260)
The 'while' part corresponding to the 'do' was missing.
Did not notice the problem as later commits using it have been stashed
and never reworked up to now, and it is currently unused in the tree.
While here, fix spacing after the '#define' in the !(_KERNEL &&
INVARIANS) part.
Fixes: 34740937f7 ("queue: New debug macros for STAILQ")
MFC after: 1 minute
Sponsored by: The FreeBSD Foundation
(cherry picked from commit d3c4b002d1)
It was reported on freebsd-fs@ that unrolling a tarball
failed to set the correct modify time if delegations
were being issued.
This patch fixes the problem.
This bug only affects NFSv4 mounts where delegations
are being issued. Not running the nfscbd or disabling
delegations on the NFSv4 server avoids the problem.
(cherry picked from commit b616d997cb)
In version 9.8, the server was split into a listener binary, sshd(8),
and a per-session binary "sshd-session".
Our blacklistd changes also have to be moved from sshd.c to
sshd-session.c.
Reviewed by: emaste
Approved by: emaste (mentor)
Fixes: 0fdf8fae8b ("openssh: Update to 9.8p1")
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D49116
(cherry picked from commit 61d8af38bf)
(cherry picked from commit 707ac59c2b)
Using the rc plumbing to setuid(2) is preferred as it allows the user
to use the -i option in ntpd_flags to chroot ntpd.
Chrooting ntpd by default will be a 2025 project.
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D48191
(cherry picked from commit 521f66715a)
This uses DES and it's likely that nobody uses that in 2025.
If somebody uses this we help them by deprecating and removing this.
Reviewed by: bapt, emaste
Differential Revision: https://reviews.freebsd.org/D30682
(cherry picked from commit 723425f837)
(cherry picked from commit 9197c04a25)
Recently-reported bugs in this driver should be fixed, but also the
hardware it supports is obsolete so mark it for deprecation.
PR: 284876
Reviewed by: bz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D49045
(cherry picked from commit 7f8a5c5a15)
(cherry picked from commit eb3be1cb9f)
If rule was added in compact form and rule body is empty, print
'proto ip' opcode to be compatible with ipfw(8) syntax parser.
Before:
$ ipfw add allow proto ip
000700 allow
After:
$ ipfw add allow proto ip
000700 allow proto ip
(cherry picked from commit 706a03f61b)
This release exists primarily to fix two security bugs. The fixes have
been independently imported into FreeBSD. This import serves to update
the ssh and sshd version number.
A few minor bug fixes are also included; see the upstream release notes
for full details of the 9.9p2 release
(https://www.openssh.com/releasenotes.html).
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 0ae642c7dd)
Approved by: re (accelerated MFC)
(cherry picked from commit 059b786b7d)
Highlights from the release notes are reproduced below. Bug fixes and
improvements that were previously merged into FreeBSD have been elided.
See the upstream release notes for full details of the 9.9p1 release
(https://www.openssh.com/releasenotes.html).
---
Future deprecation notice
=========================
OpenSSH plans to remove support for the DSA signature algorithm in
early 2025.
Potentially-incompatible changes
--------------------------------
* ssh(1): remove support for pre-authentication compression.
* ssh(1), sshd(8): processing of the arguments to the "Match"
configuration directive now follows more shell-like rules for
quoted strings, including allowing nested quotes and \-escaped
characters.
New features
------------
* ssh(1), sshd(8): add support for a new hybrid post-quantum key
exchange based on the FIPS 203 Module-Lattice Key Enapsulation
mechanism (ML-KEM) combined with X25519 ECDH as described by
https://datatracker.ietf.org/doc/html/draft-kampanakis-curdle-ssh-pq-ke-03
This algorithm "mlkem768x25519-sha256" is available by default.
* ssh(1), sshd(8), ssh-agent(1): prevent private keys from being
included in core dump files for most of their lifespans. This is
in addition to pre-existing controls in ssh-agent(1) and sshd(8)
that prevented coredumps. This feature is supported on OpenBSD,
Linux and FreeBSD.
* All: convert key handling to use the libcrypto EVP_PKEY API, with
the exception of DSA.
Bugfixes
--------
* sshd(8): do not apply authorized_keys options when signature
verification fails. Prevents more restrictive key options being
incorrectly applied to subsequent keys in authorized_keys. bz3733
* ssh-keygen(1): include pathname in some of ssh-keygen's passphrase
prompts. Helps the user know what's going on when ssh-keygen is
invoked via other tools. Requested in GHPR503
* ssh(1), ssh-add(1): make parsing user@host consistently look for
the last '@' in the string rather than the first. This makes it
possible to more consistently use usernames that contain '@'
characters.
* ssh(1), sshd(8): be more strict in parsing key type names. Only
allow short names (e.g "rsa") in user-interface code and require
full SSH protocol names (e.g. "ssh-rsa") everywhere else. bz3725
* ssh-keygen(1): clarify that ed25519 is the default key type
generated and clarify that rsa-sha2-512 is the default signature
scheme when RSA is in use. GHPR505
---
Reviewed by: jlduran (build infrastructure)
Reviewed by: cy (build infrastructure)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48947
(cherry picked from commit 3d9fd9fcb4)
Approved by: re (accelerated MFC)
(cherry picked from commit 802386cd37)
Highlights from the release notes are reproduced below. Some security
and bug fixes were previously merged into FreeBSD and have been elided.
See the upstream release notes for full details
(https://www.openssh.com/releasenotes.html).
---
Future deprecation notice
=========================
OpenSSH plans to remove support for the DSA signature algorithm in
early 2025.
Potentially-incompatible changes
--------------------------------
* sshd(8): the server will now block client addresses that
repeatedly fail authentication, repeatedly connect without ever
completing authentication or that crash the server. See the
discussion of PerSourcePenalties below for more information.
Operators of servers that accept connections from many users, or
servers that accept connections from addresses behind NAT or
proxies may need to consider these settings.
* sshd(8): the server has been split into a listener binary, sshd(8),
and a per-session binary "sshd-session". This allows for a much
smaller listener binary, as it no longer needs to support the SSH
protocol. As part of this work, support for disabling privilege
separation (which previously required code changes to disable) and
disabling re-execution of sshd(8) has been removed. Further
separation of sshd-session into additional, minimal binaries is
planned for the future.
* sshd(8): several log messages have changed. In particular, some
log messages will be tagged with as originating from a process
named "sshd-session" rather than "sshd".
* ssh-keyscan(1): this tool previously emitted comment lines
containing the hostname and SSH protocol banner to standard error.
This release now emits them to standard output, but adds a new
"-q" flag to silence them altogether.
* sshd(8): (portable OpenSSH only) sshd will no longer use argv[0]
as the PAM service name. A new "PAMServiceName" sshd_config(5)
directive allows selecting the service name at runtime. This
defaults to "sshd". bz2101
New features
------------
* sshd(8): sshd(8) will now penalise client addresses that, for various
reasons, do not successfully complete authentication. This feature is
controlled by a new sshd_config(5) PerSourcePenalties option and is
on by default.
* ssh(8): allow the HostkeyAlgorithms directive to disable the
implicit fallback from certificate host key to plain host keys.
Portability
-----------
* sshd(8): expose SSH_AUTH_INFO_0 always to PAM auth modules
unconditionally. The previous behaviour was to expose it only when
particular authentication methods were in use.
* ssh(1), ssh-agent(8): allow the presence of the WAYLAND_DISPLAY
environment variable to enable SSH_ASKPASS, similarly to the X11
DISPLAY environment variable. GHPR479
---
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48914
(cherry picked from commit 0fdf8fae8b)
(cherry picked from commit b4bb480ae9)
(cherry picked from commit e95979047a)
(cherry picked from commit dcb4ae528d)
Approved by: re (accelerated MFC)
(cherry picked from commit ff2fd01609)
It is used only by scp and sftp, and already included directly in their
Makefiles. It does not belong in libssh.
Fixes: d8b043c8d4 ("Update for 3.6.1p1; also remove Kerberos IV shims.")
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48871
(cherry picked from commit c0af329525)
(cherry picked from commit 8a02eb2c1e)
XAUTH_PATH is normally set (in the upstream build infrastructure) in
config.h. We previously set it in ssh and sshd's Makefiles if LOCALBASE
is set, and over time have sometimes also defined it in config.h.
Leave it unset in config.h and move the CFLAGS logic to to ssh.mk so
that it will be set when building all ssh libraries and programs but
still be set by LOCALBASE.
Reviewed by: jlduran
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48907
(cherry picked from commit a63701848f)
(cherry picked from commit 73dd56ffcd)
In 2000 (commit a95c122521) we changed the CheckHostIP default to
"no". We added text to ssh_config(5) documenting FreeBSD's default.
In 2021 OpenSSH made the same change, released with OpenSSH 8.5p1.
When we imported the update the added text remained, resulting in:
If the option is set to no (the default), the check will not be
executed. The default is no.
Remove the now-redundant text.
Fixes: 206be79acb ("Vendor import of OpenSSH 8.5p1")
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 06016adacc)
(cherry picked from commit 2c97e33316)
vtfontcvt requires that all glyphs are 1x or 2x a common width,
reporting for example "bitmap with unsupported DWIDTH 27 0 on line xxx"
if the font is expected to be 32 pixels wide.
Add the expected / permitted values to the error message to make the
issue more clear - for the same example,
"bitmap with unsupported DWIDTH 27 0 (not 32 or 64)".
Reviewed by: ziaee
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 3433daae0d)
(cherry picked from commit 036ce9b76e)
The "kde5" package no longer exists; KDE goes to 6.
Note: Depending on the size of 13.5-BETA3 DVD images, KDE might end
up being removed from this list in the near future.
With hat: re@
MFC after: 30 seconds
Sponsored by: Amazon
(cherry picked from commit 0d7b98c06c)
Make it clear that the 'freebsd-configure.sh' and 'freebsd-namespace.sh'
scripts are run from the crypto/openssh directory.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 6834ca8a43)
Obtained from: OpenSSH 38df39ecf278
Security: CVE-2025-26465
Approved by: so
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 170059d6d3)
(cherry picked from commit 4ad8c195cf)
Obtained from: OpenSSH 5e07dee272c3
Security: CVE-2025-26466
Approved by: so
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 8a16d0831e)
(cherry picked from commit 34798cb576)
Fragment reassembly finishes when no holes are left in the fragment
queue. In certain overlap conditions, the hole counter was wrong
and pf(4) created an incomplete IP packet. Before adjusting the
length, remove the overlapping fragment from the queue and insert
it again afterwards. pf_frent_remove() and pf_frent_insert() adjust
the hole counter automatically.
bug reported and fix tested by Lucas Aubard with Johan Mazel, Gilles
Guette and Pierre Chifflier; OK claudio@
MFC after: 1 week
Obtained from: OpenBSD, bluhm <[email protected]>, 9915416fe8
Sponsored by: Rubicon Communications, LLC ("Netgate")
(cherry picked from commit 8b2feafb53)
The reassembly state will be dropped after timeout, all related
fragments are dropped until that. This is conforming to RFC 5722.
- Sort pf_fragment fields while there.
- If the fr_queue is empty, we had overlapping fragments, don't add
new ones.
- If we detect overlapping IPv6 fragments, flush the fr_queue and
drop all fragments immediately.
- Rearrange debug output, to make clear what happens.
- An IPv4 fragment that is totaly overlapped does not inclease the
bad fragment counter.
- Put an KASSERT into pf_isfull_fragment() to make sure that the
fr_queue is never emtpy there.
discussed with Fernando Gont; ok henning@
Obtained from: OpenBSD, bluhm <[email protected]>, 8b45f36762
Sponsored by: Rubicon Communications, LLC ("Netgate")
(cherry picked from commit 6a3266f72e)
pf.conf expects <=, not ≤ (and the same applies to ≥ and >=).
Make sure the man page reflects this.
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
(cherry picked from commit 85c333a947)
Prior to change [1] this flag is useless but harmless. After the change
plat_name[] will be fetched from kernel environment after invoking the
platform probe function `platform_probe_and_attach()`. The probe function
runs at early boot stage prior to `mi_startup()` thus it is too late and
pointless to set plat_name[] after the probe.
Nathan mentioned that the logic to specify the platform pre-dates the
powerpc64 work, and is from the original pre-FDT Book-E bringup from
like 2008, so it's irrelevant these days. Instead of fixing setting the
sysctl knob hw.platform, let's clean it up now.
[1] 3da1cf1e88 Extend the meaning of the CTLFLAG_TUN flag to ...
Discussed with: nwhitehorn
Reviewed by: olce (previous version), jhibbits, #powerpc
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D48897
(cherry picked from commit b61fbbed73)
(cherry picked from commit 7775f4c5c7)
This is a direct commit to the stable/13 branch, cherry-picking commit
5b7f73ce16 ("mtree: Add missing directories generated by certctl"),
because the "untrusted" directory is called "blacklisted" on stable/13.
PR: 255639
Reviewed by: imp
Approved by: emaste (mentor)
Differential Revision: https://reviews.freebsd.org/D49037
This is a direct commit to the stable/14 and stable/13 branch.
Reviewed by: emaste
Approved by: emaste (mentor)
Fixes: bceabe277e ("flua: initial support for "require" in the base system")
Differential Revision: https://reviews.freebsd.org/D49011
We don't use legacy receive descriptors and masking out the vlan ID
isn't necessary since the tag is in the standard format, so remove it.
(cherry picked from commit 124b7722aa)
GCC 14 warned about transposed arguments to calloc, but these cases
are better served by more abstract string functions.
(cherry picked from commit f94513a3a3)
In case a variable string which is not null-terminated is passed in,
strlen() may report a length exceeding the max length, hence it is
possible to leak a portion of kernel memory to the userland.
Harden that by using strnlen() to limit the length to the max length.
While here, refactor the code a little to improve readability.
Note that, when calculating the out length, the null terminator '\0' of
the string is taken into account if available. This is not really
necessary but userland applications may have already relied on this
behavior.
Reviewed by: avg, kib, olce
Fixes: 210176ad76 sysctl(9): add CTLFLAG_NEEDGIANT flag
MFC after: 4 days
Differential Revision: https://reviews.freebsd.org/D48881
(cherry picked from commit 1951235537)
(cherry picked from commit 8ca77f9f9e)
A string loader tunable requires setting the len parameter to a nonzero
value, typically the size of the string, to have the flag CTLFLAG_TUN
work correctly [1] [2].
Without this fix security.mac.{biba,lomac}.trusted_interfaces would
have no effect at all.
[1] 3da1cf1e88 Extend the meaning of the CTLFLAG_TUN flag to automatically ...
[2] 6a3287f889 Fix regression issue after r267961. Handle special string case ...
Reviewed by: olce, kib
Fixes: af3b2549c4 Pull in r267961 and r267973 again ...
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D48898
(cherry picked from commit 7d4c0fac8c)
(cherry picked from commit 04f360b782)
This fixes a warning from "make delete-old" about a non-empty directory
on aarch64.
Reviewed by: dim
Fixes: 0fca6ea1d4
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D48904
(cherry picked from commit 09b435d3dc)
findsym() is intended for use while parsing input, so it should not be
called from addsym2() or indirectsym(), which are called before any
input is processed.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D48733
(cherry picked from commit c63af363c2)
Using the same random jitter for multiple rate limits allows an
attacker to use one rate limiter to figure out the current jitter
and then use this knowledge to de-randomize the other rate limiters.
This can be mitigated by using a separate randomized jitter for each
rate limiter.
This issue was reported as issue number 10 in Keyu Man et al.:
SCAD: Towards a Universal and Automated Network Side-Channel
Vulnerability Detection
Reviewed by: rrs, Peter Lei, glebius
MFC after: 3 days
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D48804
(cherry picked from commit 923c223f27)
Actually check the conditions that are enforced by the error checking
code instead of a condition which is
* checking a number to be non-negative instead of positive
* depending on a random number
Perform the checks consistently for ICMPv4 and ICMPv6.
Reviewed by: glebius, rrs, cc
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D48001
(cherry picked from commit c9febea3dc)
Zero means limit is disabled, so the value doesn't need to be checked
against jitter value.
Fixes: ac44739fd8
Fixes: a03aff88a1
(cherry picked from commit 4399e055ea)
Use counter_ratecheck() instead of racy and slow ppsratecheck. Use a
separate counter for every currently known type of ICMPv6. Provide logging
of ratelimit events. Provide jitter to counter open UDP port detection.
With minor tweaks from tuexen@ to fix merge problems.
Reviewed by: tuexen, zlei
Differential Revision: https://reviews.freebsd.org/D44482
(cherry picked from commit a03aff88a1)
The generation of ICMP6_ECHO_REPLY bypasses icmp6_error(), thus rate
limit was not applied.
Reviewed by: tuexen, zlei
Differential Revision: https://reviews.freebsd.org/D44480
(cherry picked from commit 32aeee8ce7)
Instead of fixing up invalid values set by a user in badport_bandlim()
which is a fast path function, provide a sysctl handler
sysctl_icmplim_and_jitter(), that will check that jitter is less than the
limit.
Provide jitter initilization function icmplim_new_jitter() used at boot,
in the sysctl handler and when we actually hit the limit. This also fixes
no jitter on a fresh booted system until first limit hit.
Instead of CVE number provide link the the actual paper that explains what
and why we are doing here. The CVE number isn't very informative, it will
just tell you what RedHat version you need to upgrade to.
Reviewed by: kp, tuexen, zlei
Differential Revision: https://reviews.freebsd.org/D44478
(cherry picked from commit ac44739fd8)
The limiting of the very last second has been done using certain jitter
value. We update the jitter for the next second. But the logging should
report the jitter before the change.
Reviewed by: kp, tuexen, zlei
Differential Revision: https://reviews.freebsd.org/D44477
(cherry picked from commit b508545ce0)
The uninitialization may be executed only on a kernel with VIMAGE.
Reviewed by: kp, tuexen, zlei
Differential Revision: https://reviews.freebsd.org/D44476
(cherry picked from commit 9d7f17d746)
We need per-VNET struct counter_rate, but we don't need per-VNET set of
const char *. Also, identical word "response" can go into the format
string instead of being stored 7 times.
Reviewed by: kp, zlei, tuexen
Differential Revision: https://reviews.freebsd.org/D44475
(cherry picked from commit 7142ab4790)
Avoid the creation of a /usr/tests/sys/vm/stack/.debug directory by
placing sys/vm/stack test debug symbols under /usr/lib/debug.
Reviewed by: emaste
Approved by: emaste (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D48796
(cherry picked from commit 88d448ec81)
(cherry picked from commit 955f974a1a)
Remove extra slashes that end up in the metalog. These double slashes
can produce an invalid specification file if there are subdirectories
down the hierarchy when sorted.
For example, consider the following metalog excerpt:
./base/aaa type=dir
./base//aaa/bbb type=dir
If sorted, would turn out:
./base//aaa/bbb type=dir
./base/aaa type=dir
Apparently missing the ./base/aaa directory in the specification.
Luckily here are no subdirectories.
Reviewed by: imp, emaste
Approved by: emaste (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D48779
(cherry picked from commit bccaf0262d)
Remove an extra slash that ends up in the metalog. This double slash
can produce an invalid specification file if there are subdirectories
down the hierarchy when sorted.
For example, consider the following metalog excerpt:
./base/aaa type=dir
./base//aaa/bbb type=dir
If sorted, would turn out:
./base//aaa/bbb type=dir
./base/aaa type=dir
Apparently missing the ./base/aaa directory in the specification.
Luckily here are no subdirectories.
Reviewed by: imp, emaste
Approved by: emaste (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D48778
(cherry picked from commit 841856570e)
Print the desired partition index together with the starting LBA and the
size. Otherwise, when only one code partition is desired, the
configuration partition (/cfg) may not end up in the third slice, thus
breaking the scripts that expect it there.
This was the previous approach, changed in 587c054bea ("nanobsd: Use
gpart and create code image before full disk image").
Fix it by printing the index as the last column to reduce the chances of
breaking current overrides, and using it as the gpart index.
PR: 262098
Reviewed by: imp
Approved by: emaste (mentor)
Fixes: 587c054bea ("nanobsd: Use gpart and create code image before full disk image")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D47835
(cherry picked from commit dc4b36b963)
Set _localbase variable from within /etc/defaults/periodic.conf
for use by periodic scripts.
This fixes e5d7100c09, no other functional changes intended.
Reported by: gahr, otis
Reviewed by: markj, gahr
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D47486
(cherry picked from commit c8b89c11a1)
d82c3e81:
net: if_media for 100BASE-BX
Renumber 1000BASE-BX and add 100BASE-BX sequentially
I added this 1000BASE-BX in 78c63ed260 but
did not connect it to any code yet, appologize for the churn.
7835a4ad:
net: if_media fix syntax/build
Fixes: d82c3e815a ("net: if_media for 100BASE-BX")
(cherry picked from commit d82c3e815a)
(cherry picked from commit 7835a4ad69)
pkg used to store copies of upstream repository databases in
/var/db/pkg/repo-*.sqlite. About a year ago this was moved to
/var/db/pkg/repos/*/, resulting in FreeBSD cloud images no longer
having those (unhelpful since they'll be long out of date before
the cloud images are launched) databases removed.
Remove the correct location, and hope that future pkg updates don't
break the base system again.
Sponsored by: Amazon
(cherry picked from commit 078e8b34b1)
This was a comment in a configuration example.
Reported by: bapt
Reviewed by: bapt, jlduran
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48810
(cherry picked from commit 513c4e2079)
(cherry picked from commit 5a7daf0199)
Loaded 100 of 3235 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.