Compare commits

...
760 Commits
Author SHA1 Message Date
Fedor Uporov 43cb7f0f48 Invalidate inode extents cache on truncation.
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)
2026-06-24 13:56:47 -04:00
Gordon Bergling 395d9672f5 mxge(4): Fix a typo in a source code comment
- s/deterimine/determine/

(cherry picked from commit 14e93e3e36)
2026-06-14 07:15:35 +02:00
Ed Maste b1ad74074d vt: Avoid integer overflow in CONS_HISTORY ioctl
Reviewed by:	markj, vexeduxr
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57250

(cherry picked from commit 0ae946e722)
(cherry picked from commit deaaddf1d3)
(cherry picked from commit b5a4f4bfbc)
2026-06-07 13:13:07 -04:00
Tai-hwa Liang 4f2925105e net: bandaid for plugging a fw_com leak in fwip_detach()
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)
2026-05-19 14:56:48 +00:00
Dag-Erling Smørgrav adf56b3107 freebsd-update: Skip /etc/ssl/cert.pem
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)
2026-05-19 16:00:07 +02:00
Ed Maste 815eb5a26e compat/linux: Avoid waitid() kernel stack disclosure
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)
2026-05-13 10:06:05 -04:00
Ed Maste 7f4bc4555a compat32: Zero struct to avoid stack disclosure
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)
2026-05-13 10:06:05 -04:00
Ed Maste c3aa964109 shm: Zero struct kinfo_file in sysctl handler
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)
2026-05-13 10:06:05 -04:00
Ed Maste c5c5705e64 sys: Fix heap disclosure in compat7 kern.proc.filedesc sysctl
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)
2026-05-13 10:06:04 -04:00
Dimitry Andric 57efbb1094 Define stdint.h macros unconditionally
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)
2026-05-08 12:28:09 +02:00
Dimitry Andric 9a69511b21 Remove extraneous tab characters at EOL in various _stdint.h files
MFC after:	3 days

(cherry picked from commit daeab702f9)
2026-05-08 12:27:22 +02:00
Dag-Erling Smørgrav bafb055ab1 lockf: Test that lockf does not spin on fd
PR:		294832
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D56723

(cherry picked from commit 0733afdb4d)
2026-05-06 05:37:46 +00:00
Christian Ullrich 2052d09b7a lockf: Avoid spinning when operating on an fd
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)
2026-05-06 05:37:46 +00:00
Michael Osipov f59c6677ee mfi(4)/mrsas(4): Set sysctl name for driver versions consistently
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)
2026-05-03 21:45:15 +02:00
Michael Osipov 70e0a1cbdc mfi(4)/mrsas(4): Print driver versions consistently
Reviewed by:	ziaee, des
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D54519

(cherry picked from commit 93122ead72)
2026-05-03 21:45:14 +02:00
Dag-Erling Smørgrav b1ece85741 dhclient: Improve server and filename validation
* 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)
2026-04-30 21:07:18 +00:00
Jessica Clarke 6311947d54 arm64: Ditch arm64-specific unsound PCPU optimisation
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)
2026-04-30 18:53:04 +01:00
Jessica Clarke b7dae28f36 loader.efi: Defer efi_translate(e_entry) until after bi_load
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)
2026-04-30 18:53:04 +01:00
Dag-Erling Smørgrav 47f819c572 caroot: Regenerate
Regenerate using certificate data from NSS 3.123.1.

MFC after:	1 week
Reviewed by:	kevans

(cherry picked from commit 07b52233e8)
2026-04-30 15:03:24 +00:00
Dag-Erling Smørgrav 7c8cafd771 caroot: Clean up
* 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)
2026-04-30 15:03:23 +00:00
Dag-Erling Smørgrav 1c928d9348 caroot: Rename script and normalize license
MFC after:	1 week
Reviewed by:	mandree, markj
Differential Revision:	https://reviews.freebsd.org/D51775

(cherry picked from commit 0886019bf8)
2026-04-30 15:03:23 +00:00
Dag-Erling Smørgrav 8547b32728 caroot: Generate both trusted and untrusted
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)
2026-04-30 15:03:22 +00:00
John W 65d75038f3 ahci(4): Add another device ID for Marvell 9128 SATA controller: 0x91a3
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)
2026-04-30 09:53:10 +02:00
Mariusz Zaborski 05b91c2a71 libnv: fix heap overflow in nvlist_recv()
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
2026-04-28 20:31:04 +00:00
Mariusz Zaborski 4acc2b5c61 libnv: switch fd_wait() from select(2) to poll(2)
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
2026-04-28 19:36:05 +00:00
Kristof Provost ed0e766f12 pf: improve SCTP validation
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
2026-04-28 19:35:48 +00:00
Mark Johnston 5d3e93fda7 dhclient: Fix reallocation of dhclient script environments
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/)
2026-04-28 17:06:01 +00:00
Mark Johnston 46c01e4dd1 dhclient: Check for unexpected characters in some DHCP server options
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/)
2026-04-28 17:06:01 +00:00
Mark Johnston d619e3a3c0 execve: Fix an operator precedence bug
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
2026-04-28 15:46:24 +00:00
Dan Mahoney 2a32297a6d termcap: fix screen entry standout mode (so/se) capabilities
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)
2026-04-28 07:20:05 -07:00
Alice Cariboni 4a56a9aae6 tuning.7: Fix suds typo in manual pages
MFC after:		3 days
Fixes:			fc32c80215 Add two new manual pages
Differential Revision:	https://reviews.freebsd.org/D55814

(cherry picked from commit f916091241)
2026-04-27 18:28:31 +02:00
Philip Paeps 18787e4ae2 contrib/tzdata: import tzdata 2026b
Changes: https://github.com/eggert/tz/blob/2026b/NEWS

(cherry picked from commit 9b95cab0a2)
2026-04-26 07:51:49 +05:45
Michael Osipov f890f8e17c mfiutil(8): "show drives" truncates information
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)
2026-04-25 16:39:02 +02:00
Cy Schubert 3246fe5f61 ippool(5): Correct example in man page
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)
2026-04-23 21:47:14 -07:00
Christos Longros c2b4fbdb45 ping6: treat setsockopt failures as fatal
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)
2026-04-24 00:53:10 +00:00
Dag-Erling Smørgrav 200b48c5e8 libarchive: Staticize some variables
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)
2026-04-23 11:49:15 +02:00
Dag-Erling Smørgrav 170f7d2168 libarchive: Update configuration
PR:		294577
MFC after:	1 week
Reviewed by:	mm
Differential Revision:	https://reviews.freebsd.org/D56468

(cherry picked from commit 05bbe5e388)
2026-04-23 11:45:52 +02:00
Martin Matuska 184dafb54c libarchive: merge from vendor branch
libarchive 3.8.7

Important bugfixes:
 #2871 libarchive: fix handling of option failures
 #2897 iso9660: fix undefined behavior
 #2898 RAR: fix LZSS window size mismatch after PPMd block
 #2900 CAB: fix NULL pointer dereference during skip
 #2911 libarchive: do not continue with truncated numbers
 #2919 CAB: Fix Heap OOB Write in CAB LZX decoder
 #2934 iso9660: fix posibble heap buffer overflow on 32-bit systems
 #2939 cpio: Fix -R memory leak
 #2947 libarchive: lzop and grzip filter support

Important bugfixes between 3.8.5 and 3.8.6:
 #2860 bsdunzip: fix ISO week year and Gregorian year confusion
 #2864 7zip: ix SEGV in check_7zip_header_in_sfx via ELF offset validation
 #2875 7zip: fix out-of-bounds access on ELF 64-bit header
 #2877 RAR5 reader: fix infinite loop in rar5 decompression
 #2878 mtree reader: Fix file descriptor leak in mtree parser cleanup
       (CWE-775)
 #2892 RAR5 reader: fix potential memory leak
 #2893 RAR5: fix SIGSEGV when archive_read_support_format_rar5 is called
       twice
 #2895 CAB reader: fix memory leak on repeated calls to
       archive_read_support_format_cab

Obtained from:	libarchive
Vendor commit:	ded82291ab41d5e355831b96b0e1ff49e24d8939
MFC after:	1 week

(cherry picked from commit eb5165bb49)
2026-04-23 11:45:11 +02:00
Michael Osipov 0fda88fa01 glabel(8): Fix debug message for already existing labels
Remove the duplicate (incorrect) name.

PR:		294542
Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D56400

(cherry picked from commit 92c69c791c)
2026-04-22 11:34:30 +02:00
Dag-Erling Smørgrav c2b8a57697 du: Set BLOCKSIZE before running tests
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)
2026-04-22 08:21:14 +00:00
Mark Johnston b8fc561930 pkru: Fix handling of 1GB largepage mappings
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
2026-04-21 15:43:53 +00:00
Mark Johnston 5eae7f23fe tty: Avoid leaving dangling pointers in tty_drop_ctty()
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
2026-04-21 15:43:53 +00:00
Jose Luis Duran e6f8afd1e8 rc.conf: Fix typo in comment
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)
2026-04-20 04:44:12 +00:00
Yuichiro NAITO ead225cd33 ixgbe: Fix MRQC register value.
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)
2026-04-19 03:42:17 -07:00
Michael Osipov cef2490a71 ciss.4: List all devices supported by ciss(4)
PR:		285744
Reviewed by:	ziaee
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D56285

(cherry picked from commit 54f5d20492)
2026-04-17 09:48:12 +02:00
Andre Albsmeier c80f52565b daemon(8): Add "--output-file -o" to list of options enabling supervision mode
This is the small internal doc fix from https://reviews.freebsd.org/D46313

Reviewed by:	michaelo
Approved by:	(blanket; comment fix)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D55325

(cherry picked from commit e9a69948a8)
2026-04-15 10:48:11 +02:00
Michael Osipov c2a961723f loader.efi.8/efibootmgr.8: Don't use contradicting term 'EFI BIOS'
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)
2026-04-14 09:30:06 +02:00
Mark Johnston 50f7b62f08 vm_fault: Reset m_needs_zeroing properly
- 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)
2026-04-13 02:58:16 +00:00
Mark Johnston bb5347cc6f kqueue: Fix a race when adding an fd-based knote to a queue
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)
2026-04-13 02:53:41 +00:00
Dag-Erling Smørgrav 10417355a7 libc: Add missing MLINK for stravis(3)
MFC after:	1 week
Fixes:		8dfeba04eb ("Update to a June 8th snapshot of (un)vis form NetBSD.")
Reviewed by:	ziaee
Differential Revision:	https://reviews.freebsd.org/D56260

(cherry picked from commit a09d06bc5b)
2026-04-12 05:59:39 +00:00
Dag-Erling Smørgrav b3bf8410a5 cd9660: Add length checks to Rock Ridge parser
* 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)
2026-04-07 15:52:56 +00:00
Philip Paeps 75767bb212 contrib/expat: import expat 2.7.5
Changes: https://github.com/libexpat/libexpat/blob/R_2_7_5/expat/Changes
         https://github.com/libexpat/libexpat/blob/R_2_7_4/expat/Changes

Security:	CVE-2026-32776
Security:	CVE-2026-32777
Security:	CVE-2026-32778
Security:	CVE-2026-24515
Security:	CVE-2026-25210

(cherry picked from commit ae04c7bbf0)
2026-04-05 13:37:13 +08:00
Dag-Erling Smørgrav e28c20959c tunefs: Don't combine GEOM journaling with SU
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)
2026-04-04 08:59:33 +00:00
Dag-Erling Smørgrav a4b2be2f6a newfs: Don't combine GEOM journaling with SU
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)
2026-04-04 08:59:33 +00:00
Arthur Kiyanovski 5fdb633777 ena: Update driver version to v2.8.2
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)
2026-04-02 22:50:05 +00:00
Arthur Kiyanovski f5370d1183 ena: Verify that an ENA ring is in netmap only in native mode
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)
2026-04-02 22:50:05 +00:00
Arthur Kiyanovski 0ae28e5776 ena: Minor changes
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)
2026-04-02 22:50:05 +00:00
Brooks Davis 36963d2497 .github: support all stable branches
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)
2026-04-02 11:11:05 +01:00
Jessica Clarke db9fd99ba8 cross-build: Provide mempcpy when building on macOS
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)
2026-04-02 11:02:04 +01:00
Dag-Erling Smørgrav 0d995ef541 syslogd: Allow killing when in foreground
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)
2026-04-02 11:56:21 +02:00
Dag-Erling Smørgrav bc735d80e2 m4: Misc style fixes
MFC after:	1 week

Reviewed by:	fuz
Differential Revision:	https://reviews.freebsd.org/D55794

(cherry picked from commit 41474e78c4)
2026-04-02 11:48:17 +02:00
Marc Espie a6eda8dd2d m4: Stop abbreviating builtin names
* 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)
2026-04-02 11:48:17 +02:00
Dag-Erling Smørgrav c7e5e9642a file: Parse some UFS2 flags
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)
2026-04-02 11:48:17 +02:00
Mark Johnston 99ec7f9b9e rpcsec_gss: Fix a stack overflow in svc_rpc_gss_validate()
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)
2026-03-25 18:30:00 -07:00
Kristof Provost 536751cb4e pf: include all elements when hashing rules
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit c6bcf6e6fd)
2026-03-25 08:12:49 +01:00
Kristof Provost 6666b2a0e7 pf tests: verify that we handle address range rules correctly
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)
2026-03-24 07:15:01 +01:00
Michael Gmelin d107424a44 pf: Fix hashing of IP address ranges
This corrects the false detection of duplicate rules.

MFC after:	1 week
Reviewed by:	kp

(cherry picked from commit 1fa873c93c)
2026-03-24 07:13:54 +01:00
Zhenlei Huang 2265cf938e ifnet: Fix decreasing the vnet interface count
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)
2026-03-20 18:03:43 +08:00
Eugene Grosbein 242346cb89 me.4: MFC: link if_me kernel module to its manual page.
(cherry picked from commit 46ba263d6e)
2026-03-11 14:23:00 +07:00
Zhenlei Huang ec22c4022d vnet: Ensure the space allocated by vnet_data_alloc() is sufficent aligned
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)
2026-03-05 19:12:41 +08:00
Dag-Erling Smørgrav f2f74aeca5 libiscsiutil: Record dependency on libmd
MFC after:	3 days
Fixes:		6378393308 ("Add an internal libiscsiutil library.")
Sponsored by:	Klara, Inc.
Sponsored by:	NetApp, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D55596

(cherry picked from commit 05ca4837a3)
2026-03-05 08:06:43 +00:00
Philip Paeps c0b2aff48f contrib/tzdata: import tzdata 2026a
Changes: https://github.com/eggert/tz/blob/2026a/NEWS

(cherry picked from commit 6becc3dff9)
2026-03-05 09:33:52 +08:00
Dag-Erling Smørgrav ba5f7719f6 lpd: Add timeout option
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)
2026-03-04 14:46:06 +00:00
Dag-Erling Smørgrav 88dc56a6ed lpd: Improve robustness
* 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)
2026-03-04 14:46:05 +00:00
Elyes Haouas 9711a6d01b lpr: Remove trailing semicolon
Signed-off-by: Elyes Haouas <[email protected]>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/654
(cherry picked from commit 365348f66a)
2026-03-04 14:46:05 +00:00
Chris Rees d3265561e2 lpd: Update SYNOPSIS with new flag
Reported by:	0mp

(cherry picked from commit cebcca89f1)
2026-03-04 14:46:05 +00:00
Chris Rees 1afa6f918b lpd.8: Chase Dd-- took old value when merging
(cherry picked from commit 56b0f5f360)
2026-03-04 14:46:05 +00:00
Chris Rees c7460134fb lpd: Add -F flag to prevent daemonizing
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)
2026-03-04 14:46:05 +00:00
Dag-Erling Smørgrav c1788a925a system(3): Clarify return values
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)
2026-03-04 14:46:04 +00:00
Kevin Bowling 55eff489d9 e1000: Increase FC pause/refresh time on PCH2 and newer
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)
2026-02-27 16:11:11 -07:00
Zhenlei Huang 59c399d38d qlnxe: Remove a pointless copy back from the link-layer address
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)
2026-02-26 22:17:22 +08:00
Zhenlei Huang 8f1de03b50 qlnxe: Advertise the IFCAP_HWSTATS capability
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)
2026-02-26 22:17:22 +08:00
Kristof Provost baed1f130a qlnx: fix panic at startup
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)
2026-02-26 22:17:22 +08:00
Dag-Erling Smørgrav 783cec744b libfetch: Gracefully skip unsupported protocols
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)
2026-02-26 04:03:52 +00:00
Dag-Erling Smørgrav c0ec07280e libfetch: Fail hard if interrupted while connecting
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)
2026-02-26 04:03:52 +00:00
Dag-Erling Smørgrav cee22ac13c libfetch: Clean up fetch_info usage
* 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)
2026-02-26 04:03:52 +00:00
Dag-Erling Smørgrav c550d07d8d m4: Fix eval output width
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)
2026-02-26 04:03:51 +00:00
Ahmad Khalifa f03fdff591 efibootmgr.8: capitalize examples section header
MFC after:	3 days

(cherry picked from commit fac9ae3db4)
2026-02-26 05:10:09 +02:00
Mark Johnston 8b476ffc4e rtsock: Fix stack overflow
Approved by:	so
Security:	FreeBSD-SA-26:05.route
Security:	CVE-2026-3038
Fixes:		92be2847e8 ("rtsock: Avoid copying uninitialized padding bytes")

(cherry picked from commit f3be7df50f)
2026-02-24 16:03:14 +00:00
Zhenlei Huang 091a1e7d21 qlnxe: Overhaul setting the multicast MAC filters
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)
2026-02-24 18:15:38 +08:00
Zhenlei Huang 281d578e9f qlnxe: Allow tapping the TX packets
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)
2026-02-24 18:15:37 +08:00
Zhenlei Huang eeb4c04dd1 qlnxe: Refactor setting the promiscuous and allmulti mode
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)
2026-02-24 18:15:37 +08:00
Zhenlei Huang 52609ccbf7 qlnxe: Let ether_ioctl() handle SIOCSIFADDR ioctl
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)
2026-02-24 18:15:37 +08:00
Zhenlei Huang aef23e8e27 qlnxe: Avoid reinitializing the interface when it is already initialized
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)
2026-02-24 18:15:37 +08:00
Zhenlei Huang e16c965add qlnxe: Prevent potential concurrency between ioctls
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)
2026-02-24 18:15:36 +08:00
Zhenlei Huang fb463bcd62 qlnxe: Fix setting the unicast MAC filter of RX path
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)
2026-02-24 18:15:36 +08:00
Zhenlei Huang 18e4cb41e9 qlnxe: Avoid memcpy with same source and destination
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)
2026-02-24 18:15:35 +08:00
Keith Reynolds 610b81333f qlnxe: Fix promiscuous and allmulti settings
PR:		278087

(cherry picked from commit e3ec564ecb)
(cherry picked from commit e4f48fc20b)
2026-02-24 18:15:35 +08:00
Eugene Grosbein 3c1f69661e trim(8): minor output correction
"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)
2026-02-23 14:14:05 +07:00
Dag-Erling Smørgrav be10d6fac6 diff: Fix gcc build.
Sponsored by:	Klara, Inc.

(cherry picked from commit 28d9586cde)
2026-02-21 17:29:06 +00:00
Maxim Konovalov c4a5799b76 pw.8: spell
(cherry picked from commit 66797b469e)
2026-02-21 13:50:46 +03:00
Cy Schubert bdf97b8f05 ipfilter: Interface name must not extend beyond end of buffer
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)
2026-02-19 18:24:26 -08:00
Cy Schubert 15c33b64ac ipfilter: Fix possible overrun
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)
2026-02-19 18:24:26 -08:00
Dag-Erling Smørgrav 0e093f57dc OptionalObsoleteFiles: Add figpar to dialog section
MFC after:	3 days
Fixes:		15d781b532 ("lib: Gate libfigpar under MK_DIALOG")
Reviewed by:	jhb, emaste
Differential Revision:	https://reviews.freebsd.org/D55330

(cherry picked from commit bc6c827078)

OptionalObsoleteFiles: Add missing figpar MLINKS

MFC after:	3 days
Fixes:		bc6c827078 ("OptionalObsoleteFiles: Add figpar to dialog section")

(cherry picked from commit efcfba9b31)

OptionalObsoleteFiles: Add missing dpv MLINK

MFC after:	3 days

(cherry picked from commit 32ec8e29a6)
2026-02-19 13:46:21 +00:00
Dmitry Morozovsky 072c3a70dc committers-ports: add andy
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)
2026-02-19 10:30:33 +03:00
Jessica Clarke a82128d03d Merge commit bfb276e55c from upstream OpenZFS (by Jessica Clarke)
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 #18217
  Closes #18218

Reported by:	fuz
MFC after:	1 day

(cherry picked from commit 45c1e44779)
2026-02-18 18:48:15 +00:00
Dag-Erling Smørgrav 589cef5d51 libfetch: Restore timeout functionality
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@)
2026-02-18 19:41:17 +01:00
Dmitry Morozovsky 4c66fafd6b pw: make manual page more friendly for uid/gid search
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)
2026-02-18 12:50:59 +03:00
Dag-Erling Smørgrav b9a6888b37 diff: Tweak recursion tests
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)
2026-02-18 00:21:16 +00:00
Dag-Erling Smørgrav c603843636 diff: Tweak range of -C and -U arguments
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)
2026-02-18 00:20:36 +00:00
Dag-Erling Smørgrav 2b11bbd790 ngctl: Fix buffer overflow in config command
Keep track of our buffer length when assembling the argument list.

PR:		293075
MFC after:	1 week
Reviewed by:	zlei, markj
Differential Revision:	https://reviews.freebsd.org/D55259

(cherry picked from commit 59906a163e)
2026-02-17 23:12:13 +00:00
Dag-Erling Smørgrav cff16d69d7 ngctl: Check hook name length
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)
2026-02-17 23:12:13 +00:00
Vladimir Kondratyev b66993bd51 evdev: Drop comments from input-event-codes.h
They were copied intact from the Linux GPL-only file.

Requested by:	imp, glebius
MFC after:	1 week

(cherry picked from commit 89aa8a9405)
2026-02-18 01:19:56 +03:00
Vladimir Kondratyev 262ea9d9a9 evdev: Sync event codes with Linux kernel 6.18
MFC after:	1 month

(cherry picked from commit 8d9a5d44b1)
2026-02-18 01:19:50 +03:00
Michael Osipov 6ce85d64d0 daemon: Add option for output file mode
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)
2026-02-15 12:17:22 +01:00
Dag-Erling Smørgrav 74e3453b90 diff: Improve directory loop detection
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)
2026-02-15 08:58:47 +00:00
Dag-Erling Smørgrav 8e65c66747 install: Expect EINTR while copying
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)
2026-02-15 08:58:47 +00:00
Dag-Erling Smørgrav f1a86b35de cp: Expect EINTR while copying
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)
2026-02-15 08:58:45 +00:00
Dimitry Andric 9349f96514 BSD.usr.dist: remove obsolete usr/share/examples/drivers entry
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)
2026-02-13 19:02:11 +01:00
Dag-Erling Smørgrav 767f1ebcf7 libfetch: Check for failure to create SSL context
* 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)
2026-02-11 13:54:33 +00:00
Enji Cooper e20dba3a21 libfetch: remove all old OpenSSL support
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)
2026-02-11 13:53:30 +00:00
Ed Maste be6ed6b277 libfetch: do not call deprecated OpenSSL functions
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)
2026-02-11 13:53:17 +00:00
Dag-Erling Smørgrav 6cfdd559a5 diff: Correctly declare tests
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)
2026-02-10 15:37:40 +00:00
Dag-Erling Smørgrav 9c99eacbc3 diff: Don't compare a file or directory to itself
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)
2026-02-10 15:36:24 +00:00
Dag-Erling Smørgrav 44cf3a1f6d diff: Fix pagination leak
* 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)
2026-02-10 15:32:47 +00:00
Dag-Erling Smørgrav f0852209a0 diff: Add test case for pagination resource leak
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)
2026-02-10 15:32:47 +00:00
Dag-Erling Smørgrav 641366df41 diff: Report I/O errors in Stone algorithm
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)
2026-02-10 14:24:30 +00:00
Dag-Erling Smørgrav 2ae615c4f1 diff: Fix integer overflows in Stone algorithm
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)
2026-02-10 14:24:30 +00:00
Dag-Erling Smørgrav bfd89763d2 diff: Detect loops when diffing directories.
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D50936

(cherry picked from commit 42092e1b66)
2026-02-10 14:24:30 +00:00
Konstantin Belousov 9748212e61 include/stdckdint.h: make the header compatible with C++
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)
2026-02-10 14:24:30 +00:00
Dag-Erling Smørgrav fda539d1ea include: Implement N2867.
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)
2026-02-10 14:24:30 +00:00
Jose Luis Duran 26fcc4afa9 Adapt changes from blocklist 2026-02-07 (10a907f)
Also apply the fix from PR 258411.

This is a direct commit to stable/13, as blacklist has been renamed to
blocklist upstream.
2026-02-10 02:22:46 +00:00
Mark Johnston 3b0f13ca60 amd64/conf: Remove a config committed by accident
Reported by:	kib, kp
Fixes:		350ba9672a ("unix: Set O_RESOLVE_BENEATH on fds transferred between jails")

(cherry picked from commit 3ef39f58e5)
2026-02-09 20:18:58 +00:00
Mark Johnston c997713286 unix/tests: Add a regression test for fd transfer across jails
MFC after:	3 weeks

(cherry picked from commit 5843b8ee02)
2026-02-09 18:07:10 +00:00
Mark Johnston 73530e4c2e unix: Set O_RESOLVE_BENEATH on fds transferred between jails
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)
2026-02-09 17:48:55 +00:00
Mark Johnston f7cbcb19a9 file: Add a fd flag with O_RESOLVE_BENEATH semantics
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)
2026-02-09 16:54:57 +00:00
Yogesh Bhosale f418e65768 ice(4): Handle allmulti flag in ice_if_promisc_set function
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)
2026-02-08 23:57:46 -07:00
Michael Osipov e5cb813ac4 sockstat: Surround explicit IPv6 addresses with brackets
PR:		254611
Approved by:	otis, tuexen, des
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D54375

(cherry picked from commit fe81e3944c)
2026-02-07 13:18:27 +01:00
Dag-Erling Smørgrav b3f23ae1e2 nextboot: Reimplement missing -a option
PR:		260520
MFC after:	3 days
Fixes:		e307eb94ae ("loader: zfs should support bootonce an nextboot")

(cherry picked from commit 33510b16e6)
2026-02-05 16:01:12 +01:00
Michael Osipov 93fbf353b6 loader: Prefer comma-separated list of values for "console"
PR:		292595
Reviewed by:	imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D54923

(cherry picked from commit 56970c3c4b)
2026-02-05 09:55:28 +01:00
Zhenlei Huang b562bbc06a e1000: Fix setting the promiscuous mode
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)
2026-02-05 13:28:50 +08:00
Mitchell Horne cc9d0192ed native-xtools: use static LLVM libraries
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)
2026-02-02 11:44:19 -04:00
Jilles Tjoelker e45b89582f sh: Fix job pointer invalidation with trapsasync
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)
2026-02-01 15:35:59 +01:00
Jilles Tjoelker b9cdb4d34b sh: Fix a double free in a rare scenario with pipes
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)
2026-02-01 15:35:54 +01:00
Enji Cooper 28966fcdbf freebsd-update: sort options alphabetically
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)
2026-01-31 15:08:08 -08:00
Enji Cooper 5975766234 rc.subr(8): run trailing-whitespace-fixer
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)
2026-01-31 15:04:46 -08:00
Enji Cooper d53bd16721 Fix OID format for vm.swap_reserved and vm.swap_total
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)
2026-01-31 15:03:51 -08:00
Rose c2b119e06b Correct size parameter to strncmp
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)
2026-01-31 15:02:17 -08:00
Kirill Kochnev ab63669726 sys/net/sff8436.h: Fix the register address of link length of copper or active cable
The register address of link length of copper or active cable is 146 as
per the SFF-8436 specification [1].

[1] 7.6.2 Upper Memory Map Page 00h SFF-8436 Specification (pdf): https://members.snia.org/document/dl/25896

Reviewed by:	imp, zlei
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1885
Closes:		https://github.com/freebsd/freebsd-src/pull/1885

(cherry picked from commit a537694b49)
(cherry picked from commit fdd23fc3d0)
(cherry picked from commit 58cf2a2840)
2026-02-01 02:42:42 +08:00
Zhenlei Huang 37de978534 qlnxe: Avoid out-of-bounds reading the multicast ethernet address
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)
2026-02-01 02:42:41 +08:00
Zhenlei Huang f119719571 lio: Avoid out-of-bounds read or write MAC address
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)
2026-02-01 02:42:41 +08:00
Dag-Erling Smørgrav df69b5792b mdmfs: Fix soft updates logic
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)
2026-01-31 17:50:18 +00:00
Dag-Erling Smørgrav ad64308af9 newfs: Add an option to disable soft updates
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)
2026-01-31 17:50:18 +00:00
Michael Osipov c0053a940e loader.conf.5: "console" setting does not document multi-value possiblity
PR:		292595
Approved by:	ziaee, dab, imp, tsoome
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D54843

(cherry picked from commit 240c614d48)
2026-01-31 18:32:32 +01:00
Roman Bogorodskiy bffa54b58c bhyve: make BHYVE_SNAPSHOT amd64-only
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)
2026-01-31 16:43:55 +01:00
Jessica Clarke 2696f9be7f libc: Don't use uninitialised string for getnetbyaddr[_r](0) DNS lookup
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)
2026-01-30 01:17:53 +00:00
Jessica Clarke 10f4191e2f Merge commit faa5141b9be4 from file git (by Christos Zoulas):
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)
2026-01-30 01:17:53 +00:00
Joseph Mingrone 223ebd5a04 periodic: Support RFC 5424 syslog timestamps
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)
2026-01-28 01:05:49 -04:00
Gordon Tetlow 1741502f8d openssl: Fix multiple vulnerabilities
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
2026-01-27 19:15:16 +00:00
Michael Osipov eda3cd3c7a vt.4: Document that hw.vga.textmode does not apply for UEFI(8) boot
PR:		292598
Approved by:	ziaee, imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D54842

(cherry picked from commit 28764001b5)
2026-01-27 16:16:38 +01:00
Konstantin Belousov f0fbaa71a5 namei: clear internal flags in NDREINIT()
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)
2026-01-26 15:49:51 +00:00
Konstantin Belousov babac9d7bc vm_fault: only rely on PG_ZERO when the page was newly allocated
(cherry picked from commit cff67bc43d)
2026-01-26 17:13:36 +02:00
Konstantin Belousov 1dc8b622b3 vm_object_page_remove(): clear pager even if there is no resident pages
(cherry picked from commit 72a447d0bc)
2026-01-26 17:10:59 +02:00
Dimitry Andric 731fa6c8f4 libc++ inttypes.h: define __STDC_CONSTANT_MACROS and __STDC_LIMIT_MACROS
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)
2026-01-26 09:33:08 +01:00
Dimitry Andric 1b02df092f mxge(4): avoid clang 21 warning in NO-IP configuration
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)
2026-01-26 09:30:32 +01:00
Dimitry Andric a4e3ff911c vchiq: fix build with clang 21
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)
2026-01-26 09:29:54 +01:00
Eugene Grosbein 6f358a6f2e MFC: libfetch: allow disabling TLS v1.3 when negotiating the connection
(cherry picked from commit 129aec7225)
2026-01-25 11:17:00 +07:00
Eugene Grosbein 2305dcc115 MFC: libfetch: apply timeout to SSL_read()
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)
2026-01-25 11:14:54 +07:00
Kevin Bowling 44b0f31df6 Revert "e1000: Try auto-negotiation for fixed 100 or 10 configuration"
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)
2026-01-24 04:12:55 -07:00
Michael Osipov b016fa60c8 sockstat: improve printaddr() according to style(9)
Reviewed by:	des
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D54412

(cherry picked from commit f89f7e58ba)
2026-01-19 23:13:23 +01:00
Jose Luis Duran fc614b08ef Import latest mtree from NetBSD
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)
2026-01-18 03:57:12 +00:00
Martin Matuska 72ba9e0213 libarchive: merge from vendor branch
libarchive 3.8.5

Important bugfixes:
 #2809 bsdtar: fix regression from 3.8.4 zero-length pattern issue bugfix

Obtained from:	libarchive
Vendor commit:  dd897a78c662a2c7a003e7ec158cea7909557bee
MFC after:	1 week

(cherry picked from commit 4b047c3af3)
2026-01-15 22:26:06 +01:00
Martin Matuska d5881e250e libarchive: merge from vendor branch
libarchive 3.8.4

Important bugfixes:
     #2787 bsdtar: Fix zero-length pattern issue
     #2797 lib: Fix regression introduced in libarchive 3.8.2
                when walking enterable but unreadable directories

Obtained from:	libarchive
Vendor commit:	d114ceee6de08a7a60ff1209492ba38bf9436f79
MFC after:	1 week

(cherry picked from commit c1e033c33e)
2026-01-15 22:25:54 +01:00
Martin Matuska d2131c8276 libarchive: merge from vendor branch
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)
2026-01-15 22:25:45 +01:00
Jose Luis Duran 70db1cd937 makefs: Fix typo 's/mirrorring/mirroring/'
MFC after:	1 week

(cherry picked from commit 73af599fb7)
2026-01-15 19:48:17 +00:00
Dimitry Andric a7d9d1b196 zfs: emit .note.GNU-stack section for all ELF targets
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)
2026-01-12 18:59:17 +01:00
Frank Hilgendorf b16ae77350 loader.efi: add stride & offset for MacBookPro3,1
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)
2026-01-12 19:28:03 +02:00
Ahmad Khalifa 8591ee986b loader.efi: only use firmware provided Blt on GOP
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)
2026-01-12 19:28:03 +02:00
Ahmad Khalifa f4e56d1bda loader.efi: probe for UGA if GOP isn't found
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)
2026-01-12 19:28:02 +02:00
Ahmad Khalifa da358db1cb ng_tty: avoid the sign extention of char
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)
2026-01-12 19:28:02 +02:00
Dag-Erling Smørgrav 61b429198d libgeom: Fix 32-bit gcc build
MFC after:	1 week
Fixes:		27894e20f1 ("libgeom: Fix segfault in 32-on-64 case")

(cherry picked from commit 17355cf50f)
2026-01-11 02:30:47 +00:00
Dag-Erling Smørgrav d39abff4ce libgeom: Improve type safety of xml2tree code
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)
2026-01-11 02:30:46 +00:00
Dag-Erling Smørgrav f147d5ea78 libgeom: Clean up xml2tree code
MFC after:	1 week
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D54453

(cherry picked from commit fad6707e25)
2026-01-11 02:30:46 +00:00
Dag-Erling Smørgrav 0ba11021c4 libgeom: Fix segfault in 32-on-64 case
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)
2026-01-11 02:30:46 +00:00
Michael Osipov 90f57724ef mrsas.4: Fix devid hex style
(cherry picked from commit c2b407244f)
2026-01-09 19:52:05 +01:00
Michael Osipov 87b6549375 mrsas.4: Add Fujitsu RAID Controller SAS 6Gbit/s 1GB (D3116)
This is an OEM card from Fujitsu using an LSI SAS2208 ROC controller shipped
with many Fujitsu PRIMERGY servers like RX300 S7.

Controller description: https://www.fujitsu.com/global/products/computing/servers/primergy/blades/connection/cb-pmod-110426.html

Reviewed by:	ziaee
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D54566

(cherry picked from commit ccec94bf63)
2026-01-09 16:56:22 +01:00
Alexander Ziaee 98b9f1dcbc mrsas.4: Cleaning
+ 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)
2026-01-07 08:57:40 -05:00
Michael Osipov 56eef386f5 mfi(4): Add subvendor and subdevice for Fujitsu RAID Controller SAS 6Gbit/s 1GB (D3116)
This is an OEM card from Fujitsu using an LSI SAS2208 ROC controller shipped
with many Fujitsu PRIMERGY servers like RX300 S7. This chip is also recognized
by mrsas(4) under the generic name for the controller chip.

Controller description: https://www.fujitsu.com/global/products/computing/servers/primergy/blades/connection/cb-pmod-110426.html

Reviewed by:	ziaee
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D54520

(cherry picked from commit 8b210276cd)
2026-01-06 20:13:39 +01:00
Dimitry Andric 496fce83a5 bsd.sys.mk: suppress another gcc warning for libc++
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)
2026-01-06 13:30:57 +01:00
Cy Schubert 57f1d519e0 ntp: Fix buildworld with MK_OPENSSL=no
Reported by:	wosch
Tested by:	wosch

(cherry picked from commit 2804461adf)
2026-01-04 19:40:12 -08:00
Warner Losh c4cc8ef864 ipfilter: fix broken build
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)
2026-01-04 19:40:12 -08:00
Cy Schubert 35d427d6d0 ipfilter: Add missing kenv fetch
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)
2026-01-04 19:40:11 -08:00
Cy Schubert 55ea321fe6 ipfilter: Disable ipfs(8) by default
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)
2026-01-04 19:40:11 -08:00
Cy Schubert e3b9f73e12 ipfilter: Restrict ipfilter within a jail
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)
2026-01-04 19:40:11 -08:00
Cy Schubert ceda9eb20f ipfilter: Restore used variable
One of the "unused" i variables is actually used.

Fixes:		20c48f090b
(cherry picked from commit 78c6cfdc3d)
2026-01-04 19:40:11 -08:00
Cy Schubert 27b1e9d16f ipfilter: Remove unused variable
Reported by:	jlduran
Fixes:		eda1756d04, 821774dfbd
MFC after:	1 week
X-MFC with:	eda1756d04, 821774dfbd
(cherry picked from commit 20c48f090b)
2026-01-04 19:40:10 -08:00
Cy Schubert 75fbf1d27b ipfilter: Verify ipnat on entry into kernel
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)
2026-01-04 19:40:10 -08:00
Cy Schubert 70eba39e86 ipfilter: Verify frentry on entry into kernel
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)
2026-01-04 19:40:10 -08:00
Cy Schubert 01bf278bd9 ipfilter: Add ipf_check_names_string()
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)
2026-01-04 19:40:10 -08:00
Cy Schubert 1b7195a169 ipfs: Fix typo in error message
MFC after:	3 days

(cherry picked from commit 5ae7b106cf)
2026-01-04 19:40:09 -08:00
Alex Richardson a96eb797b2 sys/xen: Use __printflike() instead of format(printf)
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)
2026-01-04 02:46:55 +01:00
Alex Richardson b94022db9a ocs_fc: Use __printflike() instead of format(printf)
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)
2026-01-04 02:46:39 +01:00
Dimitry Andric f5b76cb51e crypto: avoid warnings about too-long initializer strings
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)
2026-01-02 21:50:19 +01:00
Dimitry Andric 936112e7ff ncurses: avoid warnings about too-long initializer strings
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)
2026-01-02 21:50:13 +01:00
Kyle Evans 958f2ab6d4 compat: linux: use appropriate variables for copying out old timers
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)
2026-01-02 21:49:59 +01:00
Dimitry Andric 0262487496 bsd.sys.mk: suppress some new clang 21 warnings for C++
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)
2026-01-02 21:49:54 +01:00
Dimitry Andric 3015ca9407 sh: avoid warnings about too-long initializer strings
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)
2026-01-02 21:49:46 +01:00
Dimitry Andric d3a5756228 OptionalObsoleteFiles.inc: fix up WITH_LLVM_LINK_STATIC_LIBRARIES cases
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)
2026-01-02 21:49:35 +01:00
Dimitry Andric 6acae3bbe3 src.conf: Add WITH_LLVM_LINK_STATIC_LIBRARIES build knob
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)
2026-01-02 21:48:56 +01:00
Eugene Grosbein 7a5dfa03dc MFC: ipfw.8: document how to delete nat configuration instance
(cherry picked from commit e51047118c)
2026-01-03 02:34:57 +07:00
Michael Osipov 3f41c92c6b linprocfs.5: Synchronize style and format with 15-STABLE
This is a logical backport of 1d193b1808
including the changes happended after that.

Reviewed by:	fernape
Differential Revision:	https://reviews.freebsd.org/D54411
2026-01-01 13:38:18 +01:00
Xin LI 8b4f1d7349 MFV 762f11d98d: xz 5.8.2.
(cherry picked from commit ae12432049)
2025-12-29 18:21:15 -08:00
Dimitry Andric 68c94c3bc0 Remove __deprecated definition from OpenZFS compiler.h
Since it is now provided by <sys/cdefs.h>.

Direct commit to stable/13, since OpenZFS compiler.h has been
substantially changed in newer branches.
2025-12-30 00:48:21 +01:00
John Baldwin c7826c81fe cdefs: Add __deprecated1 which accepts a message as an argument
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)
2025-12-30 00:46:49 +01:00
Warner Losh 9622eff37f cdefs: Add __deprecated
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)
2025-12-30 00:46:49 +01:00
Lexi Winter cd2a65a607 sys/cdefs.h: add __noexcept and __noexcept_if
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)
2025-12-30 00:46:45 +01:00
Michael Osipov 0487408a76 bhyve_config.5: Fix consistency and terms in manpage
Correct inconsistent spelling of terms and duplication.

Reviewed by:	ziaee
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D54370

(cherry picked from commit 66604463e7)
2025-12-29 20:18:00 +01:00
Michael Osipov b4f84b19b4 bhyve: Document that MAC address has to be unicast
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)
2025-12-29 19:51:50 +01:00
Dimitry Andric d8c35dc1df sys/font.h: avoid warnings about too-long initializer strings
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)
2025-12-29 13:23:01 +01:00
Dimitry Andric 497aab21bd bsnmpd: avoid warnings about too-long initializer strings
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)
2025-12-29 13:21:20 +01:00
Dimitry Andric 8a620bd708 makefs: avoid warnings about too-long initializer strings
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)
2025-12-29 13:20:56 +01:00
Dimitry Andric c765646bee m4: avoid warnings about too-long initializer strings
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)
2025-12-29 13:20:37 +01:00
Eric Blake 4cea8771f7 m4: Fix OOB access displaying MIN_INT
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)
2025-12-29 13:20:29 +01:00
Dimitry Andric 21708f480a fsck_msdosfs: avoid warnings about too-long initializer strings
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)
2025-12-29 13:19:16 +01:00
Ayrton Munoz b354a138c0 cross-build: Avoid adding <sys/cdefs.h> to SYSINCS
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)
2025-12-29 13:16:55 +01:00
Dimitry Andric 50c02805f6 tools.build: add sys/cdefs.h to SYSINCS, since lots of other headers use it
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)
2025-12-29 13:16:49 +01:00
Alex Richardson bb4de3d2cf cdefs.h: Introduce __nonstring attribute
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)
2025-12-29 12:58:35 +01:00
Dimitry Andric 14ab9445f7 pmcannotate: avoid accessing uninitialized local variables
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)
2025-12-29 03:11:58 +01:00
Dimitry Andric 61383038bc Remove debug crutch I accidentally left in
Fixes:		cf1eaaf41c
MFC after:	1 week

(cherry picked from commit 3b1126208f)
2025-12-29 03:11:53 +01:00
Dimitry Andric d56ebf78c5 Reduce number of external symbols in libllvm, libclang and liblldb
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)
2025-12-29 03:11:42 +01:00
Dimitry Andric 1f5a55504f cuse(3): annotate cuse_init() to suppress thread safety analysis
This avoids warnings from clang 21, similar to:

    /usr/src/lib/libcuse/cuse_lib.c:111:14: error: writing variable 'h_cuse' requires holding mutex 'm_cuse' exclusively [-Werror,-Wthread-safety-analysis]
      111 |         TAILQ_INIT(&h_cuse);
          |                     ^
    /usr/src/lib/libcuse/cuse_lib.c:111:14: error: writing variable 'h_cuse' requires holding mutex 'm_cuse' exclusively [-Werror,-Wthread-safety-analysis]
    /usr/src/lib/libcuse/cuse_lib.c:112:14: error: writing variable 'h_cuse_entered' requires holding mutex 'm_cuse' exclusively [-Werror,-Wthread-safety-analysis]
      112 |         TAILQ_INIT(&h_cuse_entered);
          |                     ^
    /usr/src/lib/libcuse/cuse_lib.c:112:14: error: writing variable 'h_cuse_entered' requires holding mutex 'm_cuse' exclusively [-Werror,-Wthread-safety-analysis]

MFC after:	3 days

(cherry picked from commit 5629b5cf79)
2025-12-29 03:07:14 +01:00
Jose Luis Duran 5ea3ad01e6 Import latest mtree from NetBSD
Merge commit 'eb2ccba0c11b405ac613c3046997765317cc8b5c'

PR:		192839
PR:		219467
MFC after:	1 week

(cherry picked from commit f8cee1f2c2)
2025-12-27 16:29:02 +00:00
Michael Osipov 9aca11b4b1 bhyve.8: Fix consistency and terms in manpage
Correct inconsistent spelling of terms and duplication.

Reviewed by:	ziaee
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D54332

(cherry picked from commit 5819f8b285)
2025-12-23 20:40:26 +01:00
Paweł Krawczyk 7eb5a5b111 at cron file is now in /etc/cron.d
PR: 243380
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1106

(cherry picked from commit 783baf0012)
2025-12-23 09:13:25 -05:00
Jose Luis Duran 2011380115 mtree: tests: Import NetBSD's mtree test suite
Manually import latest mtree test suite from NetBSD.

MFC after:	1 week

(cherry picked from commit 2f29d0f3e6)
2025-12-20 01:08:49 +00:00
Jose Luis Duran 23d971abe8 mtree: Fix typos
Manually apply a typo fix.  This change has already been submitted
upstream as bin/59824.

MFC after:	1 week

(cherry picked from commit dab5daf54c)
2025-12-20 01:08:37 +00:00
Jose Luis Duran a3b349e439 Import latest mtree from NetBSD
Merge commit 'f600477feb4ae61a75f61949eb600caff4aeea8c'

MFC after:	1 week
Discussed with:	brooks

(cherry picked from commit 49b6dda4d7)
2025-12-20 01:08:28 +00:00
Dag-Erling Smørgrav 0c37e6e295 ipfilter: Prevent stack buffer overflow
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)
2025-12-19 18:07:05 +00:00
Dag-Erling Smørgrav 307cbd494b proc: Fix proc_init / proc_dtor ordering issues
* 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)
2025-12-19 18:07:05 +00:00
Dag-Erling Smørgrav b063e9c13a vfs: Let prison_enforce_statfs zero the fsid
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)
2025-12-19 18:07:04 +00:00
John Baldwin 33bc1fb48e netlink: Don't overwrite existing data in a linear buffer in snl_writer
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)
2025-12-19 11:55:36 -05:00
Cy Schubert 5ea68e7ea7 Revert "ipfilter: Add missing kenv fetch"
The commit depends on d9788eabff which
has not been merged yet.

This reverts commit fb20aad3e8.
2025-12-18 18:37:43 -08:00
Cy Schubert fb20aad3e8 ipfilter: Add missing kenv fetch
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)
2025-12-18 16:26:56 -08:00
Mark Johnston 4fef5819cc rtsold: Validate entries in domain search lists
Reported by:	Kevin Day <[email protected]>
Approved by:	so
Security:	FreeBSD-SA-25:12.rtsold
Security:	CVE-2025-14558

(cherry picked from commit bf804f69dd)
2025-12-16 23:44:05 +00:00
Eugene Grosbein c93d9e082b trim.8: minor update for manual page
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)
2025-12-16 23:09:30 +07:00
Mark Peek f1b50f2cb0 ctfmerge: fix segfault when building on macOS
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)
2025-12-15 14:50:10 -08:00
Ed Maste daedb9122a agp: Export intel_gtt_read_pte, required by i915kms
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)
2025-12-15 13:39:11 -05:00
Jessica Clarke 79fc0a5b50 mips: Include CCLDFLAGS when linking kernel.tramp.bin
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.
2025-12-15 18:16:54 +00:00
Jessica Clarke eb955433b1 mips: Drop unused TRAMP_LDFLAGS
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.
2025-12-15 18:10:19 +00:00
Konstantin Belousov 056563a158 cross-build: fix after the recent sqlite3 import
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)
2025-12-15 17:56:37 +00:00
John Baldwin 4aa3066670 cross-build: Workaround system-provided strchrnul on macOS 15.4+
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)
2025-12-15 17:56:37 +00:00
Jessica Clarke 3e264f4d35 imgact_elf: Fix off-by-one in note size check
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)
2025-12-15 17:56:37 +00:00
Jessica Clarke 577b231f3a freebsd-update: Mention upgrading packages, not just ports
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)
2025-12-15 17:56:37 +00:00
Jessica Clarke 29e74434e4 bsd.compat.mk: Honour XSTRIPBIN for lib32
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)
2025-12-15 17:56:37 +00:00
Jessica Clarke dc6d1c831d rtld-elf: Delete unused RELOC_ALIGNED_P copies
This was copied from arm to aarch64 to riscv, but only arm uses it.

MFC after:	1 week

(cherry picked from commit 02d06043ba)
2025-12-15 17:56:37 +00:00
Jessica Clarke cb89174539 sys: Various whitespace style(9) fixes for sys/elf_common.h
MFC after:	1 week

(cherry picked from commit 22ae840b9f)
2025-12-15 17:56:37 +00:00
Jessica Clarke 7a41a7442a sys: Sync RISC-V relocations
MFC after:	1 week

(cherry picked from commit 65bd6c7acd)
2025-12-15 17:56:37 +00:00
Jessica Clarke 275e553748 elf: Remove R_RISCV_[GT]PREL_[IS] relocation defines
These were internal binutils relocations that have no way to be
generated in assembly nor will ever be seen in the output, and so should
never have been defined in the psABI in the first place. They have
therefore been removed from the spec as of [1], so do so here too.

[1] https://github.com/riscv/riscv-elf-psabi-doc/commit/44f98e0fd8104def00f2a5a8d94b23dd647d18fb

(cherry picked from commit f221000127)
2025-12-15 17:56:37 +00:00
Jessica Clarke 205f65bcdd sys: Delete stale comments in sys/elf_common.h
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)
2025-12-15 17:56:36 +00:00
Jessica Clarke ec80f8a3ad share: Delete bitrotted make_*_driver.sh scripts
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)
2025-12-15 17:56:36 +00:00
Jessica Clarke 749af7d9d8 Revert "rtld: fix allocate_module_tls() variant I fallback to static allocation"
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)
2025-12-15 17:56:36 +00:00
Jessica Clarke c668cd775b libc/riscv: Fix initial exec TLS mode for dynamically loaded shared objects
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)
2025-12-15 17:56:36 +00:00
Jessica Clarke a85ba2eca4 rtld-elf/riscv: Don't allocate static TLS for dynamic TLS relocations
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)
2025-12-15 17:56:36 +00:00
Jessica Clarke 6216ed808d rtld-elf: Fix executable's TLS module index for direct exec
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)
2025-12-15 17:56:36 +00:00
Jessica Clarke cb48c371f2 rtld-elf: Fix UB for direct exec with no extra rtld arguments
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)
2025-12-15 17:56:36 +00:00
Jessica Clarke c9793e8702 rtld-elf: Fix dl_iterate_phdr's dlpi_tls_data for PowerPC and RISC-V
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)
2025-12-15 17:56:36 +00:00
Jessica Clarke d5e9943bec rtld-elf: Fix dlsym(3) for TLS symbols on PowerPC and RISC-V
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)
2025-12-15 17:56:36 +00:00
Jessica Clarke 03d5ae50dc libc: Fix dl_iterate_phdr's dlpi_tls_data for PowerPC and RISC-V
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)
2025-12-15 17:56:36 +00:00
Jessica Clarke 915a65a92a libc: Don't bias DTV entries by TLS_DTV_OFFSET
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)
2025-12-15 17:56:36 +00:00
Jessica Clarke 7adf09f630 riscv: Fix and generalise saving TP (PCPU pointer) whilst in userspace
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)
2025-12-15 17:56:36 +00:00
Jessica Clarke 017ebaa60a ofw: Fix inverted bcmp in ofw_bus_node_status_okay
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)
2025-12-15 17:56:36 +00:00
Jessica Clarke d00f1d6858 gic_v3: Correctly handle GICC GIGR Base Address case
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)
2025-12-15 17:56:36 +00:00
David Gilbert 7d8ea3c846 hexdump.3: Add missing LIBRARY section
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)
2025-12-15 17:56:36 +00:00
Jessica Clarke ae54b3ca78 sys/cdefs.h: Add comments to make #if/#else/#endif triple more obvious
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)
2025-12-15 17:56:35 +00:00
Jessica Clarke 3d292b9ee8 libc/csu: Unify INIT_RELOCS across architectures
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)
2025-12-15 17:56:35 +00:00
Jessica Clarke 1b03e7f80e tools/build/cross-build: Don't include sys/uio.h from linux limits.h
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)
2025-12-15 17:56:35 +00:00
Jessica Clarke 271d0a3119 depend-cleanup.sh: Clean up after riscv static binary IFUNC addition
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)
2025-12-15 17:56:35 +00:00
Jessica Clarke 3abb712c23 libc/csu: Support IFUNCs on riscv
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)
2025-12-15 17:56:35 +00:00
Jessica Clarke fc195afbb4 lib/clang: Commit cleaned-up workaround for building on RISC-V
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)
2025-12-15 17:56:35 +00:00
Jessica Clarke db284e1732 Merge commit 88433e640d from upstream OpenZFS (by Jessica Clarke)
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)
2025-12-15 17:56:35 +00:00
Jessica Clarke 9c9f4654e4 kldxref: Don't warn and skip file if no relocations are found
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)
2025-12-15 17:56:35 +00:00
Jessica Clarke 19b23effac gpart: Add u-boot-env alias for U-Boot's environment GPT partition UUID
This is a platform-independent UUID, and this is the name U-Boot uses.

MFC after:	1 week

(cherry picked from commit b162fc3f30)
2025-12-15 17:56:35 +00:00
Jessica Clarke 09e84ec73e riscv: Add machine/ifunc.h corresponding to rtld-elf's resolver interface
Reviewed by:	kib, mhorne
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D46279

(cherry picked from commit 8afae0caf4)
2025-12-15 17:56:35 +00:00
Jessica Clarke 8ccd9c23e6 rtld-elf: Support IFUNCs on riscv
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)
2025-12-15 17:56:35 +00:00
Jessica Clarke aaf455cfdc riscv: Recognise B extension for AT_HWCAP
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)
2025-12-15 17:56:35 +00:00
Jessica Clarke 91104d97ef rtld-elf: Pass parsed aux_info to ifunc_init
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)
2025-12-15 17:56:35 +00:00
Jessica Clarke d3fc73b79c mx25l.4: Document the correct disk device path
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)
2025-12-15 17:56:35 +00:00
Dapeng Gao e41762d412 Fix off-by-one bug in btpand
`ul` reaches `__arraycount(services)` before the bound-check happens, causing undefined behaviour.

Reviewed by:	imp, jrtc27
Fixes:		7718ced0ea ("Add btpand(8) daemon from NetBSD.")
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45463

(cherry picked from commit fbfdf57d65)
2025-12-15 17:56:35 +00:00
Jessica Clarke 8aaae40a35 ee: Fix use of uninitialised pointer in ispell_op
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)
2025-12-15 17:56:34 +00:00
Jessica Clarke c4f666e81c efibootmgr: Simplify make_next_boot_var_name and fix cnt == 0 case
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)
2025-12-15 17:56:34 +00:00
Jessica Clarke 8a29ebd6ea bsdinstall: Drop Error from title in netconfig no interfaces dialog
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)
2025-12-15 17:56:34 +00:00
Jessica Clarke 919db8472a bsdinstall: Fix netconfig script when no interfaces are present
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)
2025-12-15 17:56:34 +00:00
Jessica Clarke ede1087a40 bsd.subdir.mk: Drop broken optimisation for realinstall parallelisation
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)
2025-12-15 17:56:34 +00:00
Jessica Clarke 8a95bcc10b riscv: Remove the unused riscv64_cpu driver
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)
2025-12-15 17:56:34 +00:00
Mateusz Piotrowski faf64970ac vfs_cache: Fix the SDT definition of vfs:fplookup:lookup:done
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)
2025-12-15 18:26:14 +01:00
Mark Johnston 8ddb5aff83 netmap: Fix error handling in nm_os_extmem_create()
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)
2025-12-15 16:00:56 +00:00
Philip Paeps c7edaaf43f contrib/tzdata: import tzdata 2025c
Changes: https://github.com/eggert/tz/blob/2025c/NEWS

(cherry picked from commit a86dc94b84)
2025-12-14 16:30:23 +08:00
Dag-Erling Smørgrav 13ffee9940 fsync: Open files in non-blocking mode
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)
2025-12-12 18:53:02 +00:00
Dag-Erling Smørgrav b09c986c63 bus: Return 0 if reading an ivar fails
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)
2025-12-12 18:53:02 +00:00
Kristof Provost 7b4482f383 pf: relax sctp v_tag verification
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)
2025-12-11 10:22:15 +01:00
Cy Schubert d077ec7c0f rc.d/ipfilter: ipfilter must be enabled for options to take
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)
2025-12-10 13:10:47 -08:00
Cy Schubert 07b5eb3b6a rc.d/{ipfilter,ippool}: Fix typo in variable name
(cherry picked from commit f04b23ce35)
2025-12-10 13:10:47 -08:00
Kristof Provost 9b2551051f pfsync: fix incorrect unlock during destroy
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)
2025-12-08 10:34:20 +01:00
Dag-Erling Smørgrav ef8a5af2a3 rtld-elf: Mark LD_SHOW_AUXV insecure
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)
2025-12-05 18:28:45 +00:00
Cy Schubert 5b084744bb sqlite3: Update to 3.50.4
Release notes at https://www.sqlite.org/releaselog/3_50_4.html.

Obtained from:  https://www.sqlite.org/2025/sqlite-autoconf-3500400.tar.gz

Merge commit 'e7e917ee3cf2b3010b1c511c6ebaf8b65b983ad7'

(cherry picked from commit 07d5a9b1b2)
2025-12-05 05:20:12 -08:00
Jose Luis Duran 02a810d9b4 strfmon: Fix negative sign handling for C locale
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)
2025-12-03 02:35:56 +00:00
Jose Luis Duran 6b0e99570f strfmon: EINVAL if the '+' flag and both signs are empty
According to the Open Group Base Specifications Issue 8[1], strfmon(3)
should return EINVAL when the '+' flag was included in a conversion
specification and the locale's positive_sign and negative_sign values
would both be returned by localeconv(3) as empty strings.

Austin Group Defect 1199[2] is applied, adding the [EINVAL] error.

[1]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/strfmon.html
[2]: https://www.austingroupbugs.net/view.php?id=1199

Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D53912

(cherry picked from commit 1fd018972a)
2025-12-03 02:35:42 +00:00
Jose Luis Duran 33189f868a strfmon: Add tests for Austin Group Defect 1199
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)
2025-12-03 02:35:23 +00:00
Jose Luis Duran 6cccf4db13 strfmon: Fix typo s/poistion/position/
MFC after:	1 week

(cherry picked from commit 91e7f19ec4)
2025-12-03 02:35:07 +00:00
Cy Schubert c7cfc16f7c ipfilter: Load optionlist prior to ippool invocation
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)
2025-12-02 07:28:55 -08:00
Dimitry Andric f4ff747cb7 Remove TableGen objects from libllvm, fixing bad option registrations
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)
2025-12-01 12:57:17 +01:00
Kristof Provost 81385f6220 pf: handle divert packets
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)
2025-11-29 21:02:00 +01:00
Jose Luis Duran 8d338f99f8 beep: Sort usage and man page options
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)
2025-11-29 00:32:36 +00:00
Gordon Tetlow 2aed524b23 Mitigate YXDOMAIN and nodata non-referral answer poisoning.
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)
2025-11-26 08:02:20 -08:00
Jose Luis Duran 111b60a2fd local-unbound: Read a tab separated resolv.conf
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)
2025-11-26 15:34:23 +00:00
Dimitry Andric e0c79f13d7 Reapply "Merge commit e24f90190c77 from llvm git (by Brad Smith):"
[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)
2025-11-26 07:06:40 +01:00
Dag-Erling Smørgrav f6bd9b266d openssh: Don't attempt to connect to unsupported addresses
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)
2025-11-25 03:19:35 +00:00
Cy Schubert d9c345c9d3 ntpd: Fix segfault when same IP on multiple interfaces
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)
2025-11-23 20:00:43 -08:00
Mark Johnston 503ab844ce namei: Fix cn_flags width in various places
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)
2025-11-19 20:47:50 +00:00
Mark Johnston adb8c1a9d0 vfs cache: Add NAMEILOOKUP to the whitelist of fastpath lookup flags
Otherwise the lockless name lookup path is inadvertently disabled since
NAMEILOOKUP isn't recognized.

Reviewed by:	olce, kib
Fixes:		7587f6d484 ("namei: Make stackable filesystems check harder for jail roots")
Differential Revision:	https://reviews.freebsd.org/D50532

(cherry picked from commit f415895300)
2025-11-19 20:47:50 +00:00
Mark Johnston 4e31059f80 namei: Remove a now-unused variable
Reported by:	bapt
Fixes:		7587f6d484 ("namei: Make stackable filesystems check harder for jail roots")

(cherry picked from commit 14ec281a09)
2025-11-19 20:47:50 +00:00
Mark Johnston b55b927296 tests: Add a regression test for commit 7587f6d484
Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D50533

(cherry picked from commit a5dac34f6e)
2025-11-19 20:47:50 +00:00
Mark Johnston 8c63056ea8 vfs: Don't clobber namei flags in vn_open_cred()
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)
2025-11-19 20:47:50 +00:00
Mark Johnston 592de68e32 namei: Make stackable filesystems check harder for jail roots
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)
2025-11-19 20:47:50 +00:00
Konstantin Belousov 19b91b1553 nullfs lookup: cn_flags is 64bit
Reviewed by:	olce
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D50390

(cherry picked from commit 89549c2348)
2025-11-19 20:47:50 +00:00
Mark Johnston 90118a35a3 src.conf: Add a MK_ZFS_TESTS knob
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)
2025-11-19 20:47:50 +00:00
Dag-Erling Smørgrav a2630fec78 quot: Rewrite -n mode input parser
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)
2025-11-19 11:20:30 +00:00
Dag-Erling Smørgrav 29343c4b8f quot: Add tests
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)
2025-11-19 11:20:30 +00:00
Mateusz Piotrowski 6ec3d4402a geom_zero.4: Document
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)
2025-11-18 14:39:49 +01:00
Mateusz Piotrowski 760b71a493 dtrace_callout_execute.4: Document the DTrace callout_execute provider
MFC after:	2 weeks
Fixes:		91dd9aae1a Add explicit static DTrace tracing to the callout mechanism
Differential Revision:	https://reviews.freebsd.org/D51397

(cherry picked from commit 3ccb2d9513)
2025-11-18 14:37:10 +01:00
Mark Johnston ecc1e61d31 file: Qualify pointers to capsicum rights as const
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)
2025-11-17 15:06:28 +00:00
Mark Johnston e2956be814 file: Simplify an INVARIANTS check in _fdrop()
No functional change intended.

MFC after:	1 week
Sponsored by:	Klara, Inc.

(cherry picked from commit a2e22ed342)
2025-11-17 14:29:25 +00:00
Mateusz Piotrowski 3d0e2327e9 dtrace.1: Document DTRACE_DEBUG
Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D53627

(cherry picked from commit f811c0a555)
2025-11-15 08:19:26 +01:00
Dag-Erling Smørgrav 3e8d5f3608 cd9660: Unbreak symbolic links
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)
2025-11-14 15:43:53 +01:00
Cy Schubert dbe0b2c986 ipfilter: Don't trust userland supplied iph_size
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)
2025-11-11 20:02:31 -08:00
Cy Schubert e82f63c725 ipfilter: Add an htable max size tuneable.
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)
2025-11-11 20:02:31 -08:00
Cy Schubert 2e13641830 ipfilter: Add htable (hash table) tunable
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)
2025-11-11 20:02:31 -08:00
Cy Schubert eb411cd796 ipfilter: Calculate the number of elements in ipf_errors
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)
2025-11-11 20:02:31 -08:00
Mateusz Piotrowski 1b5d2fc026 dtrace_vfs.4: Document the DTrace vfs provider
Reviewed by:	bcr
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D51317

(cherry picked from commit 2020e76450)
2025-11-10 10:48:14 +01:00
Mateusz Piotrowski 8febbb2a7d dtrace.1: Fix mdoc macros around -x
There should be no space between -x's "arg" and "=value".

MFC after:	3 days

(cherry picked from commit 753cef701d)
2025-11-09 16:29:33 +01:00
Mateusz Piotrowski 956938cd28 ports.7: Add /var/db/ports to FILES
PR:		272426
MFC after:	3 days
Co-authored-by: Piotr Smyrak <[email protected]>

(cherry picked from commit b8ff8a11c0)
2025-11-09 16:28:54 +01:00
Mateusz Piotrowski 5cf8a3cbd9 truss.1: Reference sysdecode(3)
MFC after:	1 week

(cherry picked from commit fa9ac741d0)
2025-11-08 12:18:57 +01:00
Mateusz Piotrowski 3b7358bebd dtrace.1: Document evaltime
Reviewed by:	christos, ziaee
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D51301

(cherry picked from commit 1fe7af0635)
2025-11-08 12:15:05 +01:00
Mateusz Piotrowski 4735f556b9 vnode.9: Fix a typo in sys/tools/vnode_if.awk path name
Fixes:	e018265679 vnode.9: Document vnode_if.awk and vnode_if.src
MFC after:	1 week

(cherry picked from commit 0abee387e1)
2025-11-08 12:13:33 +01:00
Mateusz Piotrowski cd77df4c05 deadfs.9: Document
Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D53334

(cherry picked from commit daa6660f89)
2025-11-08 12:04:54 +01:00
Mateusz Piotrowski 53912e303f buf.9: Sprinkle with mdoc macros
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)
2025-11-08 11:55:47 +01:00
Dimitry Andric 1772049a8a Revert "Merge commit e24f90190c77 from llvm git (by Brad Smith):"
[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)
2025-11-07 22:58:49 +01:00
Seyed Pouria Mousavizadeh Tehrani a432ffb091 if_vxlan: fix byteorder of source port
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)
2025-11-07 09:57:49 +01:00
Tiago Gasiba 58f534ec40 truss: Properly display first argument to nmount
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)
2025-11-05 15:37:44 +00:00
Jose Luis Duran b781ee1e0b blacklist: Update the blacklistd-helper script
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
2025-11-05 15:18:48 +00:00
Stefan Eßer 50376dcb22 contrib/bc: MFC upgrade from version 7.02 to 7.1.0
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)
2025-11-04 20:24:57 +00:00
Jasper Tran O'Leary 639eaea58e nvme: Add handling for bar5
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)
2025-11-04 13:16:55 -05:00
Kyle Evans 9436058454 ipfw: pmod: avoid further rule processing after tcp-mod failures
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)
2025-11-03 18:52:12 -06:00
Martin Matuska 1b969a57d0 libarchive: merge from vendor branch
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)
2025-11-03 10:30:24 +01:00
Kristof Provost 8f92db3cf5 pf: improve DIOCRCLRTABLES validation
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)
2025-11-03 09:34:27 +01:00
Kristof Provost ba198fe8a0 pf: improve add state validation
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)
2025-11-03 09:34:26 +01:00
Mateusz Piotrowski 22d678c93e tuning.7 stats.7: Cross-reference
MFC after:	3 days

(cherry picked from commit b2c5686755)
2025-10-31 12:38:18 +01:00
Mateusz Piotrowski be3e8a9cc8 getvfsbyname.3 mount.8: Reference lsvfs(1)
MFC after:	3 days
Reviewed by:	ziaee
Differential Revision:	https://reviews.freebsd.org/D53411

(cherry picked from commit cb1315c15a)
2025-10-31 12:37:10 +01:00
Mateusz Piotrowski d99e5a7cc4 geom: zero: Let sysctls .byte and .clear to be settable in loader
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)
2025-10-31 12:35:06 +01:00
Mark Johnston 4f87ec9825 net: Validate interface group names in ioctl handlers
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)
2025-10-30 14:09:58 +00:00
Mark Johnston 83f74730db altq: Clear stats structures in get_class_stats()
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)
2025-10-30 14:09:58 +00:00
Mateusz Piotrowski fb7f92c346 uio.9: Improve description of uio_rw flags
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)
2025-10-30 14:00:35 +01:00
Mateusz Piotrowski 71dcae4412 style.mdoc.5: Point readers to style(9) regarding copyright headers
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)
2025-10-30 13:59:24 +01:00
Mateusz Piotrowski fbf5c60dc4 examples/mdoc: Remove text of BSD-2-Clause from mdoc examples
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)
2025-10-30 13:55:58 +01:00
Mateusz Piotrowski 78061ae6a9 g_bio.9: Reference dtrace_io(4)
MFC after:	3 days

(cherry picked from commit 3559b8e983)
2025-10-30 13:36:43 +01:00
Dimitry Andric 7849f088cd Merge commit e24f90190c77 from llvm git (by Brad Smith):
[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)
2025-10-30 09:25:11 +01:00
Dag-Erling Smørgrav ce85598972 w: Trim whitespace and commas from time and uptime
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)
2025-10-28 11:08:30 +00:00
Jose Luis Duran 93263ae5ea mtree: Remove stray wi directory
Reviewed by:	imp, emaste
Fixes:	a21def4d56 ("pccard: Remove wi(4) driver")
MFC after:	5 days
Differential Revision:	https://reviews.freebsd.org/D53264

(cherry picked from commit f942a74654)
2025-10-27 13:08:11 +00:00
Cy Schubert 4efaa78347 unbound: Vendor import 1.24.1
Release notes at
	https://nlnetlabs.nl/news/2025/Oct/22/unbound-1.24.1-released/

Security:	CVE-2025-11411

Merge commit '73dd92916f532cb3fe353220103babe576d30a15'

(cherry picked from commit 8b29c373e6)
2025-10-25 20:15:14 -07:00
Dag-Erling Smørgrav fe3e929ffa local-unbound-setup: Set so-sndbuf to 0
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)
2025-10-25 20:15:13 -07:00
Cy Schubert 29b59b8ac4 unbound: Vendor import 1.24.0
Release notes at
	https://nlnetlabs.nl/news/2025/Sep/18/unbound-1.24.0-released/

MFC after:	1 week

Merge commit '0064eb9cf1c8d526e87d3149249445d4bc8d0248'

(cherry picked from commit b2efd602ae)
2025-10-25 20:15:13 -07:00
Cy Schubert 4260de80f0 ipfilter: Plug ip_nat kernel information leak
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)
2025-10-25 20:15:13 -07:00
Cy Schubert 2ebb4779c4 ipfilter: Plug ip_htable kernel information leak
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)
2025-10-25 20:15:13 -07:00
Gordon Bergling 8a4e4d10f9 kdb: Fix a typo in a source code comment
- s/th/the/

(cherry picked from commit 0a53e6d8bc)
2025-10-25 11:18:24 +02:00
Gordon Bergling bbc7da8315 pmcstat(8): Fix a typo in a source code comment
- s/th/the/

(cherry picked from commit 2b2a4f02e0)
2025-10-25 11:18:16 +02:00
Lexi Winter 857897013b libc: Import OpenBSD's inet_net_{ntop,pton}
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)
2025-10-25 05:41:37 +01:00
Gordon Tetlow 2564a21f97 libc: Add "Z" as TZ designator for strptime.
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)
2025-10-22 10:53:28 -07:00
Mark Johnston 8e999e63c3 so_reuseport_lb_test: Add a test case for connected UDP sockets
Approved by:	so

(cherry picked from commit 1dd66c6ac2)
2025-10-22 15:49:17 +00:00
Mark Johnston df888c8f41 inpcb: Ignore SO_REUSEPORT_LB on connected sockets
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)
2025-10-22 15:49:11 +00:00
Mark Johnston 6e4767672a imgact_elf: Check note body sizes
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)
2025-10-22 12:34:07 +00:00
Mark Johnston 43bf0f4cd2 libnv: Fix a length check in nvpair_unpack_string_array()
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)
2025-10-22 12:33:48 +00:00
Mark Johnston c839eecec5 ipfw: Check for errors from sooptcopyin() and sooptcopyout()
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)
2025-10-21 13:13:03 +00:00
Dag-Erling Smørgrav bbf986d0f1 quot: Fix benign buffer overflow
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)
2025-10-20 16:11:48 +00:00
Jose Luis Duran 549cba3c9d rc: dmesg: Allow umask to be configurable
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)
2025-10-20 16:05:40 +00:00
Jose Luis Duran 2779d63101 rc.conf: Fix typo interferring -> interfering
Reviewed by:	emaste
MFC after:	2 days
Differential Revision:	https://reviews.freebsd.org/D53168

(cherry picked from commit 982d70ca2e)
2025-10-20 16:04:00 +00:00
Michael Osipov 25150c4f98 manpages: Use canonical names for Linux filesystems
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)
2025-10-20 14:34:34 +02:00
Paul Armstrong f8c4b9d71a login.conf: Remove never used ignoretime/ignoretime@
PR:		240378
Reviewed by:	otis (mentor), glebius (src committer)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D52991

(cherry picked from commit 4835fc45ef)
2025-10-20 14:33:31 +02:00
Jose Luis Duran 07a3c93bc5 tools: Update sysctl to its new name
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)
2025-10-16 18:45:33 +00:00
Jose Luis Duran 14e02220e4 nanobsd: rescue: Update legacy sysctls
Reviewed by:	emaste
MFC after:	1 hour
Differential Revision:	https://reviews.freebsd.org/D34598

(cherry picked from commit 93ee9bb424)
2025-10-16 18:45:23 +00:00
Ahmad Khalifa d06e31d4a7 libm: remainder: make sure x is zero
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)
2025-10-14 17:01:59 +03:00
Gregory Neil Shapiro 8f13891707 MFC: Merge commit '1fdae2e33fdc751bc2ec74c81fcde14323e4e965'
Be explicit that newaliases for sendmail
(Upstream sendmail.org commit 3084151d898)

PR:	289259

(cherry picked from commit e9f7c3de11)
2025-10-09 21:01:40 +00:00
Cy Schubert cccbbb3299 ipfilter/ippool: Dump a copy of ippool dstlist data in "new" format
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)
2025-10-09 05:36:57 -07:00
Cy Schubert 96870b5acc ipfilter/ippool: Dump a copy of ippool hash data in "new" format
As with 7531c434a5, which dumped ippool table data in the "new"
format, print hash data in the "new" format.

(cherry picked from commit 2f30b43fa2)
2025-10-09 05:36:57 -07:00
Cy Schubert 517430d262 ipfilter ippool: Prefix deleted entries with "#"
To maintain consistency with ippool list functions, prefix deleted
entries with "#".

(cherry picked from commit f3ff6abb9d)
2025-10-09 05:36:57 -07:00
Cy Schubert c6a31e29ef ipfilter ippool: Flag deleted entries with "#"
List deleted entries prefixed by "#". This is consistent with other
ippool list functions.

Fixes:		7531c434a5

(cherry picked from commit 94758e72fd)
2025-10-09 05:36:57 -07:00
Dag-Erling Smørgrav 86d368403e rcorder: Fix grammar in warning about loops
MFC after:	1 week
Reviewed by:	ae
Differential Revision:	https://reviews.freebsd.org/D52951

(cherry picked from commit d96f9a4688)
2025-10-08 11:44:40 +00:00
Dag-Erling Smørgrav 1c541a2098 ln: Simplify sameness checks
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D52927

(cherry picked from commit 18997fb9ec)
2025-10-08 11:44:39 +00:00
Dag-Erling Smørgrav b0c147af08 cp: Simplify sameness checks
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D52926

(cherry picked from commit 95de78614a)
2025-10-08 11:44:39 +00:00
Dag-Erling Smørgrav ce6061658f tail: Tweak follow_rename test case
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)
2025-10-08 11:44:34 +00:00
Ed Maste e01971362f Merge commit 7a66a26658f4 from llvm git (by Fangrui Song):
--discard-locals/--discard-all: allow and keep symbols referenced by relocations

  In GNU objcopy, symbols referenced by relocations are retained. Our
  COFF (https://reviews.llvm.org/D56480) and Mach-O
  (https://reviews.llvm.org/D75104) ports port the behavior, but the ELF
  port doesn't.

  This PR implements the behavior for ELF.
  Close #47468 (tcl has a use case that requires `strip -x tclStubLib.o`
  to strip local symbols not referenced by relocations.)

  Pull Request: https://github.com/llvm/llvm-project/pull/130704

PR:		258820
Approved by:	dim
Differential Revision: https://reviews.freebsd.org/D52198

(cherry picked from commit 959806e0a8)
(cherry picked from commit 4558fc4f91)
2025-10-07 14:16:44 -04:00
Ed Maste 5c0d60e75b boot_i386.8: Mention this is legacy
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D49704

(cherry picked from commit b8437cbae1)
(cherry picked from commit 96743bfb95)
2025-10-07 14:16:44 -04:00
Ed Maste 244ecc5616 Makefile.inc1: Avoid including cwd in path
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)
2025-10-07 14:16:44 -04:00
Jose Luis Duran 8699896713 nss_tacplus: Fix typo MK_INSTALLIB -> MK_INSTALLLIB
Reviewed by:	des
Approved by:	emaste (mentor)
Fixes:	6c5cdba1ba ("Add nss_tacplus, a TACACS+ NSS module.")
MFC after:	1 day
Differential Revision:	https://reviews.freebsd.org/D52882

(cherry picked from commit 75f7e003b7)
2025-10-07 00:33:32 +00:00
Zhenlei Huang 8583840cfb witness: Record the first acquired file and line for recursable locks
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)
2025-10-05 00:43:28 +08:00
Zhenlei Huang b4a079dd78 witness: White space cleanup and some style(9) tweeks
MFC after:	3 days

(cherry picked from commit f537766525)
(cherry picked from commit 91c0ef0f5a)
2025-10-05 00:43:28 +08:00
Zhenlei Huang a08e8da274 ifconfig: Display the IFCAP_HWSTATS capability
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
2025-10-05 00:43:27 +08:00
Zhenlei Huang d334e045a4 ifconfig: Fix the display of the IFCAP_MEXTPG capability
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
2025-10-05 00:43:27 +08:00
Zhenlei Huang 22f26eb3b8 ifconfig: Garbage collect unused parameter swabips
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)
2025-10-05 00:43:26 +08:00
Zhenlei Huang ce95ba8ae5 tcp: Add CTLFLAG_VNET flag to some sysctls
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)
2025-10-05 00:43:26 +08:00
Zhenlei Huang 4b92e54c9b tcp: Fix expiring and purging hostcache entries of vnet jails
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)
2025-10-05 00:43:25 +08:00
Zhenlei Huang d59a8f27fc tslog: Move sysinit_tslog_shim() into kern_tslog.c
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)
2025-10-05 00:43:24 +08:00
Zhenlei Huang 1d101415d7 qlnxe: Report speeds in decimal format
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)
2025-10-05 00:43:24 +08:00
Zhenlei Huang f30da24e9d qlnxe: Support SIOCGIFXMEDIA ioctl
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)
2025-10-05 00:43:23 +08:00
Zhenlei Huang 49fbc8dcf7 qlnxe: Unconditionally enable extended media types
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)
2025-10-05 00:43:23 +08:00
Zhenlei Huang ad08006c7f qlnxe: Fix advertising the IFCAP_LINKSTATE capability
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)
2025-10-05 00:43:22 +08:00
Zhenlei Huang 4dc6c65704 init_main: Fix logging the subsystem of pre-loaded kernel modules
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)
2025-10-05 00:43:22 +08:00
Zhenlei Huang 1a9f9b4e38 ipfw: Teach ipfw that EtherIP is an upper layer protocol
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)
2025-10-05 00:43:21 +08:00
Zhenlei Huang 7cbb184bbf gif.4: Mention that gif(4) can tunnel Ethernet traffic
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)
2025-10-05 00:43:21 +08:00
Zhenlei Huang 6e605ed6df EtherIP: Fix passing the address family from if_bridge(4) to gif(4)
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)
2025-10-05 00:43:20 +08:00
Zhenlei Huang a3fbecac68 tests: gif(4): Add regression tests for setup with EtherIP
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)
2025-10-05 00:43:20 +08:00
Zhenlei Huang 767db00447 tests: gif(4): Add tests to cover all IPv[46] in IPv[46] setups
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)
2025-10-05 00:43:19 +08:00
Ed Maste bc4a85b69d Cirrus-CI: Bump to FreeBSD 13.5 image
It is currently the oldest supported FreeBSD 13 release.

Sponsored by:	The FreeBSD Foundation
2025-10-04 12:08:51 -04:00
Eugene Grosbein 40497eda79 trim.8: update the manual with references to zpool-trim and fsck_ffs -E
(cherry picked from commit 5d8fde8507)
2025-10-04 11:18:17 +07:00
Xin LI dc00c4cd16 MFC: MFV: expat 2.7.3.
(cherry picked from commit 8d485a8490)
2025-10-02 09:41:56 -07:00
Dag-Erling Smørgrav 01c9851772 nss_tacplus: Fix typo in Makefile
Reported by:	ivy@
MFC after:	3 days

(cherry picked from commit e98d341691)
2025-10-02 07:28:56 +00:00
Dag-Erling Smørgrav 4704cb6d92 libucl: Fix bugs in C-style comment parser
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)
2025-10-02 07:28:56 +00:00
Muhammad Moinur Rahman 1d6e02cfc3 MFV: libucl: Update to 0.9.2
- 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)
2025-10-02 07:28:55 +00:00
John Baldwin 97d4b45ae3 libucl: Add a ucl::Ucl::forced_string_value method
This is a wrapper around ucl_object_tostring_forced.

Sponsored by:	Chelsio Communications
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1794

(cherry picked from commit 47586ffc8b)
2025-10-02 07:28:55 +00:00
Baptiste Daroussin 817170736b libucl: import snapshot 2024-02-06
(cherry picked from commit ddca081d38)
2025-10-02 07:28:55 +00:00
Mateusz Piotrowski ae87c1af44 mktemp.1: Document TMPDIR in ENVIRONMENT
While here, use Ev for TMPDIR consistently.

MFC after:	3 days
Event:		EuroBSDCon 2025

(cherry picked from commit 6b164f1811)
2025-10-01 18:31:45 +02:00
Mateusz Piotrowski d7d94b0ab8 sysctl.9: Fix grammar in *TUN descriptions
Reported by:	bcr
Reviewed by:	bcr
MFC after:	3 days
Event:		EuroBSDCon 2025
Fixes:	5eb1caa8c8 Updated SYSCTL manual pages
Differential Revision:	https://reviews.freebsd.org/D52768

(cherry picked from commit f34e1c76ad)
2025-10-01 17:52:31 +02:00
Ahmad Khalifa 1488828f45 gpioc: allocate new fifo size
This slipped through after I resolved some merge conflicts.

Fixes:		d000adfe
MFC after:	1 day

(cherry picked from commit 2679636b44)
2025-10-01 11:52:33 +03:00
Ahmad Khalifa 4472ecb362 gpioc: fix race in ioctl(GPIOCONFIGEVENTS)
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)
2025-10-01 11:52:21 +03:00
Ahmad Khalifa d8ee81cb8a gpioc: allocate priv->events with the correct size
MFC after:	1 day

(cherry picked from commit fa26e44554)
2025-10-01 11:52:08 +03:00
Ahmad Khalifa 51cac1f186 ng_tty: copy to the correct mbuf
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)
2025-10-01 11:50:57 +03:00
Ahmad Khalifa 2dc10f2a49 ng_tty: don't increment m_data
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)
2025-10-01 11:50:46 +03:00
Jose Luis Duran f60ddbd0fb ftpd: blocklist: Add a permission denied probe
Reviewed by:	emaste
Approved by:	emaste (mentor)
Obtained from:	NetBSD
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D52746

(cherry picked from commit 1060684b04)
2025-09-30 23:21:18 +00:00
Jose Luis Duran da2437b62e ftpd: blocklist: Add an extra probe
Add a blocklist probe when user access is denied.

Reviewed by:	emaste
Approved by:	emaste (mentor)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D52747

(cherry picked from commit 307929b211)
2025-09-30 23:21:06 +00:00
Gordon Tetlow c0dbaf2b5d Fix issue from OpenSSL.
Out-of-bounds read & write in RFC 3211 KEK Unwrap (CVE-2025-9230)

Obtained from:	OpenSSL
Approved by:	so
Security:	FreeBSD-SA-25:08.openssl
Security:	CVE-2025-9230
2025-09-30 08:28:59 -07:00
Krzysztof Galazka db8b10d728 ixl(4): Fix queue MSI and legacy IRQ rearming
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)
2025-09-29 15:45:33 +02:00
Jose Luis Duran 7a5bdaf1d7 cron: Fix comment from "root's" to "system" crontab
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)
2025-09-27 11:01:12 +00:00
Colin Percival 87eb52f1b0 freebsd-update: Library ordering
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)
2025-09-25 12:27:28 -07:00
Siva Mahadevan 7e42cedae8 bsdinstall: fix vfs.zfs.vdev.min_auto_ashift oid
Signed-off-by: Siva Mahadevan <[email protected]>
PR: 266374
Pull request: https://github.com/freebsd/freebsd-src/pull/1851
Reviewed by: emaste
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 87a7b35f04)
(cherry picked from commit 093f3f26e9)
(cherry picked from commit 8f7dded412)
2025-09-25 16:41:33 +02:00
Enji Cooper 08be83a3cb Fix the build post-dcf5d5603b3af8
I didn't compile test the prior code before committing.

MFC after:	1 week
MFC with:	dcf5d5603b

(cherry picked from commit 27234ad699)
2025-09-23 22:36:59 -07:00
Enji Cooper 8782ceb942 Reduce ifdef soup by adding pre-3.0 compat support
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)
2025-09-23 22:36:59 -07:00
Enji Cooper a694dad26b factor: support OpenSSL 3
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)
2025-09-23 22:36:59 -07:00
Enji Cooper ebb9f371b4 Add simple factor/primes regression tests
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)
2025-09-23 22:33:18 -07:00
Enji Cooper 6ff0347e8f Unbreak usr.bin/dc with OpenSSL 3
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)
2025-09-23 21:49:26 -07:00
Enji Cooper 7fcf7175e7 Makefile.inc1: garbage collect unused variable: install-info
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)
2025-09-23 21:41:11 -07:00
Dag-Erling Smørgrav 0416dd2d03 man: Fix usage message
PR:		289245
Fixes:		14b61b2e93 ("man: Add -l option")
(cherry picked from commit dc38cf116c)
2025-09-23 13:06:14 +00:00
Xin LI bbdd55f00d MFC: MFV: libexpat 2.7.2
(cherry picked from commit 627b778d9e)
2025-09-21 22:56:32 -07:00
Dag-Erling Smørgrav 3ac71c45ff uptime: Mention libxo support in manual page
MFC after:	3 days
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D52489

(cherry picked from commit 55bd607b99)
2025-09-16 13:55:23 +00:00
Dag-Erling Smørgrav eafc54027d src.sys.mk: Support src.conf in SRCTOP
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)
2025-09-16 13:55:22 +00:00
Ingo Schwarze e5c5d8f78e man: Add -l option
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)
2025-09-16 13:55:22 +00:00
Dag-Erling Smørgrav c34e79820b unbound: Update to 1.23.1
Release notes at
	https://nlnetlabs.nl/news/2025/Jul/16/unbound-1.23.1-released/

Since we don't enable ECS, this is mostly a nop for us.

Merge commit 'c8864f6ba46ff3271d97b4ae1c3cc6ce01eaf18a'

MFC after:	3 days

(cherry picked from commit 5a0119491a)
2025-09-16 13:55:22 +00:00
Marius Halden d703ae86bf w: Fix idle time in json output, add login/idle times to json output
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)
2025-09-16 13:03:57 +00:00
Ruslan Bukin 8302f09d84 riscv timer: fix interrupt handling.
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)
2025-09-15 16:32:17 -03:00
Ruslan Bukin 850182848d riscv: Fix SSTC extension support
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)
2025-09-15 16:32:14 -03:00
Mateusz Piotrowski aacf2678b6 ports.7: Fix example of passing variables on the command line
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)
2025-09-13 13:31:38 +02:00
Michael Osipov 7f14cf603e bsdinstall: Drop outdated comments about ZFS dataset compression
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)
2025-09-12 17:22:52 +02:00
Kevin Bowling b62a72cd8a ixgbe: Correct ixgbe_link_speed_to_str comment
PR:		288960
Reported by:	michaelo

(cherry picked from commit c1532f74e4)
2025-09-11 17:39:25 -07:00
Yogesh Bhosale 5a85a5ed44 ixgbe: Fix incomplete speed coverage in link status logging
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)
2025-09-11 17:39:17 -07:00
Yasuhiro Kimura 00038a0204 leap-seconds: Update to leap-seconds.3960835200 from IERS
Current leap-seconds file has already expired on 28 June 2025

PR:		289352
Obtained from:	https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.3960835200
MFC after:	3 days

(cherry picked from commit 4729d5e2e2)
2025-09-10 22:39:55 -07:00
Rick Macklem bda4837363 exports.5: Add a paragraph clarifying the use of "V4:"
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)
2025-09-08 17:59:06 -07:00
Seyed Pouria Mousavizadeh Tehrani bb5b0c1624 ipfw: Fix segfault in NPTv6 rule parser
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)
2025-09-04 18:15:15 +00:00
Michael Osipov 2e25db2197 date(1): Improve manpage around '-I'
* 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)
2025-09-04 16:55:50 +02:00
Ed Maste e3af3a23c1 ng_parse: Add upper bound to avoid possible overflow
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)
2025-09-04 09:05:30 -04:00
Ed Maste bc77917cd0 ng_parse: disallow negative length for malloc
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)
2025-09-04 09:05:30 -04:00
Dimitry Andric 17c0ecb14d Merge commit cf721e29c6a3 from llvm git (by Amy Kwan):
[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)
2025-08-30 11:58:12 +02:00
Ed Maste 2e6697c8d9 pom: Cache tzdata before entering capability mode
Pom uses localtime() so needs tzdata available.

PR:		278574
Reported by:	Tatsuki Makino
Reviewed by:	ivy
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D51521

(cherry picked from commit 0fde36fe04)
(cherry picked from commit 05459c1b86)
2025-08-29 11:11:18 -04:00
Gordon Bergling 7cad1e5478 mwl(4): Fix a typo in a source code comment
- s/firwmare/firmware/

(cherry picked from commit 4f768b8acd)
2025-08-28 11:15:51 +02:00
Gordon Bergling 59088fa391 bce(4): Fix a typo in a source code comment
- s/firwmare/firmware/

(cherry picked from commit a848c85d27)
2025-08-28 11:15:37 +02:00
Gordon Bergling f9fab6aa83 cam(3): Fix a common typo in source code comments
- s/tranferred/transferred/

(cherry picked from commit 90d7186379)
2025-08-28 11:15:25 +02:00
Gordon Bergling ee72210b7c ice(4): Fix a typo in a source code comment
- s/firwmare/firmware/

(cherry picked from commit 62db40b564)
2025-08-28 11:15:14 +02:00
Gordon Bergling 6062ccb1fb ffs(3): Fix a typo in a source code comment
- s/fist/first/

(cherry picked from commit cc5623d8bd)
2025-08-28 11:15:01 +02:00
Gordon Bergling d0fc19ab9f hpt27xx(4): Fix a couple of typos in source code comments
- s/tranform/transform/

(cherry picked from commit 49ae0c2592)
2025-08-28 11:14:50 +02:00
Gordon Bergling 87e0274be9 msdofs(5): Fix a typo in a source code comment
- s/fist/first/

(cherry picked from commit ac40052191)
2025-08-28 11:14:33 +02:00
Dag-Erling Smørgrav 0d9522888c stat(2): Document the st_rdev field
MFC after:	1 week
Sponsored by:	Klara, Inc.
Sponsored by:	NetApp, Inc.
Reviewed by:	bcr
Differential Revision:	https://reviews.freebsd.org/D51946

(cherry picked from commit 4eaa7f6662)
2025-08-27 18:50:58 +00:00
Dag-Erling Smørgrav 59fb30e785 getmntpoint: Don't compare st_rdev for non-devices
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)
2025-08-27 18:50:57 +00:00
Dag-Erling Smørgrav 4e3f44692f freebsd-update: Do not fsync
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)
2025-08-27 18:50:57 +00:00
Dag-Erling Smørgrav af321075b4 libkern: Drop incorrect qsort optimization
See 5205b32de3 for details.

PR:		287089
MFC after:	1 week
Reviewed by:	jlduran
Differential Revision:	https://reviews.freebsd.org/D51919

(cherry picked from commit ef8f3e9131)
2025-08-27 18:50:57 +00:00
Dag-Erling Smørgrav c9c1ecb811 libc: Drop incorrect qsort optimization
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)
2025-08-27 18:50:57 +00:00
John-Mark Gurney 98ac13c4ba arm64: prevent panic when using syscall mux + large arg call (mmap)
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)
2025-08-25 15:23:12 +00:00
Gordon Bergling 9418999e0a arm: Fix two typos in kernel messages of pmu_fdt.c
- s/interupt/interrupt/

(cherry picked from commit 9c7a9b3ff1)
2025-08-22 07:28:04 +02:00
Steve Kargl 8d2c0354e1 [libm] Avoid left shift of signed integer entities
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)
2025-08-21 12:41:43 +02:00
Steve Kargl 94b09b2f34 [libm] Fix undefined behavior of a left shifted of a signed integer
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)
2025-08-21 12:41:41 +02:00
Mateusz Piotrowski e84d5425bf dtrace.1: Document security.bsd.allow_destructive_dtrace
PR:		288284
Reviewed by:	bcr, markj
MFC after:	3 days
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D51633

(cherry picked from commit 1acfb873cf)
2025-08-20 12:49:10 +02:00
Christos Margiolis 1a6f2bf372 dtrace.1: fix mandoc -Tlint
Reviewed by:	markj
Approved by:	markj (mentor)
Differential Revision:	https://reviews.freebsd.org/D40230

(cherry picked from commit ed35c7cf77)
2025-08-20 12:49:07 +02:00
Steve Kargl e7fa662183 Updates for ccosh[f] and csinh[f]
* 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)
2025-08-17 20:32:35 +02:00
Ryan Libby 1eea81c39a libmsun: remove duplicates after cdefs.h added inline to __always_inline
Reviewed by:	kib, olce
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45712

(cherry picked from commit 07cc7ea738)
2025-08-17 20:32:35 +02:00
Kyle Evans c96e754ea6 chroot: don't clobber the egid with the first supplemental group
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)
2025-08-15 00:03:24 -05:00
Mark Johnston 5c56784992 sys/conf: Re-add -Wno-unused to ipfilter build flags
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")
2025-08-14 21:14:03 +00:00
Mark Johnston 1e58eb141b vm_pageout: Disallow invalid values for act_scan_laundry_weight
PR:		234167
MFC after:	2 weeks

(cherry picked from commit d8b03c5904)
2025-08-14 21:11:11 +00:00
Steve Kargl 22a5c54e8a Remove unused variables in msun/bsdsrc/b_tgamma.c
PR:		288736
MFC after:	3 days

(cherry picked from commit 53b77089e5)
2025-08-14 20:32:25 +02:00
Dag-Erling Smørgrav 4b89029fef bsd.man.mk: Add checkmanlinks target
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)
2025-08-14 14:00:06 +00:00
Dag-Erling Smørgrav 65cbf5862e kern.post.mk: Support flavors in PORTS_MODULES
MFC after:	1 week
PR:		288596
Reviewed by:	pkubaj
Differential Revision:	https://reviews.freebsd.org/D51833

(cherry picked from commit 988426e815)
2025-08-14 14:00:06 +00:00
Dag-Erling Smørgrav 1229e3a06d indent: Fix buffer overflow
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)
2025-08-14 14:00:06 +00:00
Dag-Erling Smørgrav 831799f6d3 indent: Simplify test script
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)
2025-08-14 14:00:06 +00:00
Dag-Erling Smørgrav ebd7ad2815 hastd: Fix nv data size check
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)
2025-08-14 14:00:06 +00:00
Dag-Erling Smørgrav a64e034831 libutil: Add missing MLINKs
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)
2025-08-14 14:00:05 +00:00
Dag-Erling Smørgrav f580383f1e libutil: Document pidfile_signal()
Fixes:		287451fd01
MFC after:	1 week
Reviewed by:	pauamma_gundo.com, emaste
Differential Revision:	https://reviews.freebsd.org/D51705

(cherry picked from commit 4e6a3e7e32)
2025-08-14 14:00:05 +00:00
Kenny Levinsen 01bb889cc1 wordexp(3): Handle ECHILD from waitpid
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)
2025-08-12 23:20:24 +02:00
Romain Tartière 77a0173ca9 vm_page: Fix handling of empty bad memory addresses file
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)
2025-08-10 18:51:35 -10:00
Siva Mahadevan 8bbb1f4ce7 ip_htable: fix -Wtautological-pointer-compare warnings
This also fixes a few other trivial -Wunused-but-set-variable warnings.

Pull Request:	https://github.com/freebsd/freebsd-src/pull/1677
MFC after:	1 month

(cherry picked from commit e4c864e555)
2025-08-09 22:55:15 -07:00
Siva Mahadevan 3b6536d030 ip_nat.c: fix non-trivial unused variable warnings
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1677
MFC after:	1 month

(cherry picked from commit 2bae5cad79)
2025-08-09 22:55:15 -07:00
Siva Mahadevan 4134e9a11c files: add new IPFILTER_C rule for netpfil/ipfilter sources
This re-enables all compiler warnings for these sources.

Pull Request:	https://github.com/freebsd/freebsd-src/pull/1677
MFC after:	1 month

(cherry picked from commit 45730dd3ed)
2025-08-09 22:55:15 -07:00
Siva Mahadevan 8777d3a9b8 netpfil/ipfilter: fix remaining trivial unused variable warnings
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1677
MFC after:	1 month

(cherry picked from commit 79d2384517)
2025-08-09 22:55:15 -07:00
Siva Mahadevan 5a248f1b90 ip_nat6.c: fix non-trivial unused variable warnings
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1677
MFC after:	1 month

(cherry picked from commit 2bbaeb717b)
2025-08-09 22:55:14 -07:00
Cy Schubert 9a34cc3bd9 sqlite3: Vendor import of sqlite3 3.50.2
Release notes at https://www.sqlite.org/releaselog/3_50_2.html.

Obtained from:  https://www.sqlite.org/2025/sqlite-autoconf-3500200.tar.gz

MFC after:	1 month

Merge commit '89922daaa168292633b1a7a523bcd0559487c6ad'

(cherry picked from commit 17f0f75308)
2025-08-09 22:55:14 -07:00
Cy Schubert 597601a23d ipfilter: End (cleanup) the iterative search key
This results in not finding nodes in subsequent hash table listings.

MFC after:	3 days

(cherry picked from commit ac2e39b5dd)
2025-08-09 22:55:14 -07:00
Cy Schubert 9c1615a1a1 Revert "ipfilter: Avoid allocating a new ipf token when not needed"
malloc() outside of a write lock will reduce potential contention.

MFC after:	3 days

This reverts commit 7f5e3b9fa3.

(cherry picked from commit cf9b685754)
2025-08-09 22:55:13 -07:00
Andriy Gapon 6b5813daf3 sys/geom: use proper style for sizeof operator
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)
2025-08-09 14:31:29 +03:00
Dag-Erling Smørgrav 805f602928 kyua: Stop using readdir_r()
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)
2025-08-08 19:46:33 +00:00
Dag-Erling Smørgrav 83e2f9e1c0 libarchive: Stop using readdir_r()
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)
2025-08-08 19:46:32 +00:00
Dag-Erling Smørgrav 6d2bc21c67 bsnmpd: Fix an error message
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D51678

(cherry picked from commit bf304a40cd)
2025-08-08 19:46:32 +00:00
Dag-Erling Smørgrav f318186deb netlink: Fully clear parser state between messages
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)
2025-08-06 13:52:14 +00:00
Andriy Gapon aadc10e7ce cam_fill_mmcio: initialize cmd.error sub-field
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)
2025-08-06 09:04:36 +03:00
Andriy Gapon 706291eddb mmc_da: garbage-collect sdda_get_max_data
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)
2025-08-06 09:04:32 +03:00
Andriy Gapon 7293d82104 mmc_da: fix garbage in disk->d_attachment
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)
2025-08-06 09:04:27 +03:00
Andriy Gapon be941fa483 mmc_xpt: use strlcpy instead of strncpy
A better practice in general.

(cherry picked from commit ad8d336799)
2025-08-06 09:04:23 +03:00
Andriy Gapon f8f0cae5e0 rk_i2c: use the register read mode even if the read ends with IIC_M_NOSTOP
Tested with max44009(4).

(cherry picked from commit a743e280ea)
2025-08-06 08:55:34 +03:00
Andriy Gapon e71f019b82 rk_i2c: emulate repeated start
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)
2025-08-06 08:55:24 +03:00
Dag-Erling Smørgrav 6ca3734e92 comsat: Don't read arbitrary files
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)
2025-08-05 11:52:28 +00:00
Ed Maste 1501ecebf5 comsat: Improve use of setuid()
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)
2025-08-05 11:52:26 +00:00
Dag-Erling Smørgrav 39bc7081b8 xargs: Limit -n to {ARG_MAX}
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)
2025-08-05 09:33:12 +00:00
Dag-Erling Smørgrav a42bf0da8d rc.d: Fix mountd service script.
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)
2025-08-05 09:32:41 +00:00
Dmitry Morozovsky d91839d3e3 extend description of net.inet.ip.fw.one_pass
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
2025-08-05 08:53:06 +03:00
Xin LI 4266bc4fcf MFC: MFV: less v679.
(cherry picked from commit 76bafc9069)
2025-08-02 18:00:44 -07:00
Romain Tartière e4624465c1 vm_page: Fix loading bad memory addresses from file
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)
2025-08-01 19:31:38 -10:00
Zhenlei Huang aee028cb4e if_genet: Plug memory leaks
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)
2025-07-31 18:11:52 +08:00
Zhenlei Huang 8c49d0a9f8 if_genet: Consistently use the boolean form
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)
2025-07-31 18:11:51 +08:00
Lexi Winter de19b9d6e9 clang-scan-deps: Pass ${TDFILE} to tblgen, not ${.ALLSRC}
${.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)
2025-07-31 10:57:54 +01:00
Lexi Winter 4eee2c9e96 crash.8: update a little
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)
2025-07-31 10:56:56 +01:00
Lexi Winter 0a23354713 pom.6: add a more complete bibliography
Source: Wikipedia
<https://en.wikipedia.org/wiki/Practical_Astronomy_with_Your_Calculator>

(cherry picked from commit bf0ee5f217)
2025-07-31 10:56:30 +01:00
Ed Maste fd05ce71c7 dtrace.1: Resolve merge conflict
PR: 288556
Fixes: 0c91fa9824 ("dtrace_fbt.4: Document the DTrace fbt provider")
(cherry picked from commit 185bd9cf21)
2025-07-30 20:06:49 -04:00
Mateusz Piotrowski 7ee04c7b17 rc: Use check_jail to check values of security.jail MIBs
PR:		282404
Reviewed by:	markj, netchild
Approved by:	markj (mentor)
MFC after:	2 weeks
Event:		Berlin Hackathon 202507
Differential Revision:	https://reviews.freebsd.org/D47329

(cherry picked from commit 46f18ecf8d)
2025-07-30 11:55:30 +02:00
Mateusz Piotrowski 2dded8fb5b dtrace_fbt.4: Document the DTrace fbt provider
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.
2025-07-30 11:41:09 +02:00
Mateusz Piotrowski 683f161bd5 dtrace.1: Mention providers in SEE ALSO
Reviewed by:	bnovkov, christos, markj
Approved by:	bnovkov (mentor), christos (mentor), markj (mentor)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D50852

(cherry picked from commit 177471148a)
2025-07-30 11:39:16 +02:00
Michael Proto 0bb490bdbf /etc/rc.d/pf: Fix for multi-line pf_fallback_rules
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)
2025-07-29 09:48:51 +02:00
Eric Joyner 4f8cb9f1da MFC: ice: unbreak build with update to 1.42.5-k
- 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)
2025-07-26 18:11:17 +07:00
Eugene Grosbein f12f5d1d66 devd(8): correct error logging
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)
2025-07-26 14:16:47 +07:00
Warner Losh 0111be0a40 devd: Add vm_guest variable
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)
2025-07-26 14:16:09 +07:00
Eugene Grosbein 8812941de6 devd.conf(5): call hyperv_vfattach in a Hyper-V guest only
Limit calls to /usr/libexec/hyperv/hyperv_vfattach to Hyper-V guests.

PR:		287873
MFC after:	3 days

(cherry picked from commit d4a0e749cc)
2025-07-26 14:15:56 +07:00
Eric Joyner 00daa1b56a ice: Update to 1.42.1-k
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)
2025-07-24 16:17:53 +02:00
Eric Joyner 66b1d696db ice_ddp: Update to 1.3.41.0
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)
2025-07-24 16:17:45 +02:00
Dag-Erling Smørgrav b86c699704 tzcode: Fix time zone change detection.
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)
2025-07-24 13:02:13 +00:00
Dag-Erling Smørgrav 4cafd1021a udf: Improve input validation.
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)
2025-07-24 13:02:12 +00:00
Dag-Erling Smørgrav a7b4e2e9d0 kyua: Try harder to delete directories.
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)
2025-07-24 13:02:12 +00:00
Dimitry Andric e5fcb8c32f Merge commit 8ac140f39084 from llvm git (by Younan Zhang):
[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)
2025-07-24 09:44:49 +02:00
Zhenlei Huang d9a1e54cb0 qlnxe: Fix error handling of SIOCGI2C ioctl
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)
2025-07-20 22:16:36 +08:00
Dirk Engling da5827a63c bluetooth-config: Fix command line parsing
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)
2025-07-20 11:12:16 +02:00
Lexi Winter 42dd8f4add inetd.conf: remove -[46] from the ssh entry
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)
2025-07-19 02:13:21 +01:00
Lexi Winter 2c8c8fe02a nlmsg_report_err_msg: add __printflike annotation
Reviewed by:	kevans, kp
Approved by:	kevans (mentor)
Differential Revision:	https://reviews.freebsd.org/D51234

(cherry picked from commit db55cc8110)
2025-07-19 02:12:29 +01:00
Lexi Winter ae3b38b834 deprecate RIP
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)
2025-07-19 02:12:27 +01:00
Koichiro Iwao 16879ba615 ifconfig.8: remove accept_rev_ethip_ver and send_rev_ethip_ver
It is removed long ago [1] and unavailable on FreeBSD 11 and later,
but the corresponding entries in the man page were not removed
accordingly.

[1] https://cgit.freebsd.org/src/commit/?id=b1c250ff3ff6af36e95f5cf910973133c3445704

MFH after:	3 days
Reviewed by:	mhorne
Approved by:	mhorne
Differential Revision:	https://reviews.freebsd.org/D51261

(cherry picked from commit cca6a72d7f)
2025-07-16 11:19:47 +09:00
Mateusz Piotrowski cdd5fece16 rc.subr: Fix a typo in check_jail()'s description
MFC after:	3 days
Event:		Berlin Hackathon 202507

(cherry picked from commit 5d5258653b)
2025-07-15 02:24:27 +02:00
Eugene Grosbein 5d15e09a26 libexec/rc: MFC: improve performance of pccard_ether script
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)
2025-07-13 22:48:37 +07:00
Damir Bikmuhametov 57c652dfa1 pf: fix ICMP ECHO handling of ID conflicts
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)
2025-07-12 09:50:55 +02:00
Lexi Winter 778f5aaa89 clang: install clang-scan-deps
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)
2025-07-09 17:55:51 +01:00
Zhenlei Huang 0a5e8108bf pfsync: Allocate and initialize buckets before attaching the interface
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)
2025-07-08 18:03:29 +08:00
Zhenlei Huang 9d53e7eaab pfsync: Destroy buckets mutexes on clone destroying interface
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)
2025-07-08 18:03:29 +08:00
Zhenlei Huang 2db01aea74 pfsync: Remove a redundant assignment of if_type
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)
2025-07-08 18:03:28 +08:00
Zhenlei Huang 12a1baa42b bridge: Remove a redundant assignment of if_type
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)
2025-07-08 18:03:28 +08:00
Zhenlei Huang 56a81f3733 ng_iface(4): Remove a redundant assignment of if_type
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)
2025-07-08 18:03:28 +08:00
Zhenlei Huang e59f60d3c0 if_vlan: Fix up if_type before attaching the interface
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)
2025-07-08 18:03:28 +08:00
Zhenlei Huang afaa32661b axgbe: Fix setting promisc mode
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)
2025-07-08 18:03:28 +08:00
Dimitry Andric f82159545a contrib/llvm-project: re-add clang/tools/clang-scan-deps
This is in preparation for adding it as an optional tool in base.

MFC after:	1 week

(cherry picked from commit 7ed1628066)
2025-07-02 20:08:51 +02:00
Lexi Winter fbaab13732 contrib/llvm-project: fix clang crash compiling modules
clang++ may crash when compiling certain C++20 modules.  Backport the
fix from LLVM upstream.

This fixes LLVM bug 102684:
https://github.com/llvm/llvm-project/issues/102684.

PR:	287803
MFC after:	3 days
Obtained from:	https://github.com/llvm/llvm-project/pull/102855
Reviewed by:	kevans, dim
Approved by:	kevans (mentor)
Differential Revision:	https://reviews.freebsd.org/D51041

(cherry picked from commit 55dfaeae8e)
2025-06-30 23:27:40 +01:00
George Amanakis eae8301095 Fix 2 bugs in non-raw send with encryption
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 #12014
Closes #17340
(cherry picked from commit ea74cdedda)
2025-06-27 20:07:48 +00:00
Andriy Gapon 264aeb32e9 ads111x: initialize the lock earlier, before it's used
The first use can be in ads111x_add_channels.

(cherry picked from commit eda3a7ac75)
2025-06-27 10:40:02 +03:00
Andriy Gapon 4d1ff6d22b dwc_otg_fdt: do not create and leak extra usbus child
dwc_otg_init() already takes care of creating the bus and setting up sc
to point to it.

Fixes:		518da7ace8

(cherry picked from commit 97c799661a)
2025-06-27 10:39:55 +03:00
Andriy Gapon 0bcd8425f0 OptionalObsoleteFiles: etc/rc.d/powerd is used/useful without ACPI/APM
Just like powerd daemon does not depend on ACPI/APM, its rc script does
not either.

Fixes:		20eb6bd8c5

(cherry picked from commit 28d74f18f1)
2025-06-27 10:38:38 +03:00
Kyle Evans 0106e5d725 libarchive/test: fix build when memcpy() is a macro
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)
2025-06-20 22:15:19 +02:00
Martin Matuska a46bed9937 libarchive: fix duplicate entry in tests Makefile
Reported by:	des
MFC after:	2 weeks (together with 2e113ef82)

(cherry picked from commit 331f2c1c46)
2025-06-20 22:15:12 +02:00
Martin Matuska f47afeb2ce libarchive: merge from vendor branch
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)
2025-06-20 22:14:01 +02:00
Graham Perrin 610a0ffaba zfsboot: fix misuse of the phrase zpool
A pool is not a zpool.

Reviewed by:	jbh, ivy
Approved by:	des (mentor)
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1569

(cherry picked from commit f69afe4201)
2025-06-20 18:33:39 +01:00
Nathan Whitehorn e3fd26a3d7 bsdinstall: Fix grammatical issues.
PR:		263488

(cherry picked from commit dfa5a74357)
2025-06-19 14:25:48 -04:00
Xin LI 47807edf0a MFC: MFV: less v678.
(cherry picked from commit 252d6dde57)
2025-06-09 23:05:19 -07:00
Dag-Erling Smørgrav be0706e8e1 netcat: Allow service names to be used.
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)
2025-06-07 06:51:39 +00:00
Dag-Erling Smørgrav 39f039512f libpam: Additional module directory.
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)
2025-06-07 06:50:38 +00:00
Kristof Provost 06664c3b0e pf: fix panic in pf_return()
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)
2025-06-06 23:20:16 +02:00
Michael Osipov cda1b2b634 caroot: Update certdata URL for GitHub switch
Mozilla has migrated its projects' source code to GitHub, update certdata URL
along with it.

Reference: https://github.com/curl/curl/pull/17321

Reviewed by:	jrm (mentor), otis (mentor), kevans
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D50575

(cherry picked from commit 87c46facc3)
2025-06-04 21:32:53 +02:00
Alexander Motin c92ffde748 systat/top: Update ZFS sysctl names
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)
2025-05-27 20:27:55 -04:00
Lexi Winter 2e4014e81f net/if_bridgevar.h: add include guard
Reviewed by:	kp
Approved by:	des (mentor)

(cherry picked from commit f6aedb956e)
2025-05-27 08:11:56 +01:00
Jordan Gordeev 1c12934eba libc++: fix compiling <locale> with -fmodules
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)
2025-05-25 11:20:41 +02:00
Philip Paeps df16df7700 zoneinfo: don't install version
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)
2025-05-24 10:39:20 +06:00
[email protected] 50cf49f601 service(8): Allow for passing no arguments to the service script
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)
2025-05-23 10:43:58 +02:00
Dan Langille 5fa8cce7e9 newsyslog.conf.d/opensm.conf: remove leading blank line
Reviewed by:	jlduran, ivy, kevans
Approved by:	kevans (mentor)
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1603

(cherry picked from commit 2d22d54fc4)
2025-05-22 22:45:13 +01:00
Lexi Winter 3214a79585 link_addr: be more strict about address formats
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)
2025-05-21 00:17:06 +01:00
Lexi Winter 054468aa45 net/if_dl.h: add param names in prototypes
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)
2025-05-20 23:11:59 +01:00
Lexi Winter 838c75f869 libc: add link_ntoa_r()
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)
2025-05-20 23:11:52 +01:00
Lexi Winter 55f0de2793 libc tests: add tests for link_addr(3) and link_ntoa(3)
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)
2025-05-20 23:11:46 +01:00
Lexi Winter c82e217415 column(1): add tests and -l flag
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)
2025-05-20 22:03:29 +01:00
Seyed Pouria Mousavizadeh Tehrani 9f290050a6 ng_sample: fix style nits
MFC after:	3 days
Reviewed by:	ivy, kp, des
Approved by:	des (mentor)
Differential Revision:	https://reviews.freebsd.org/D50343

(cherry picked from commit 95c414dd27)
2025-05-20 22:03:29 +01:00
Lexi Winter 513df87288 sys/cdefs.h: add __nodiscard annotation
__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)
2025-05-20 22:03:29 +01:00
Roger Pau Monné ca77785752 xen: improve man (4) page
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)
2025-05-19 10:25:08 +02:00
Lexi Winter 9523a569fc sys/net: add a new ether_vlanid_t type
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)
2025-05-19 03:49:20 +01:00
Cy Schubert 738c0bb0ad wpa_supplicant: Use PF_LOCAL instead of PF_INET*
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)
2025-05-10 21:50:00 -07:00
Marek Zarychta b3e677d58b wpa_supplicant: Handle systems without INET (legacy IP) support
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)
2025-05-10 21:49:59 -07:00
Cy Schubert 560608f78a unbound: Update version strings
Fixes:		be771a7b7f
MFC after:	2 weeks
(cherry picked from commit 3bef9b313b)
2025-05-10 21:49:59 -07:00
Cy Schubert 8f00a3eabd unbound: Vendor import 1.23.0
Release notes at
	https://nlnetlabs.nl/news/2025/Apr/24/unbound-1.23.0-released/

Merge commit '44bab727dfe28451b777dc9e47db4f748b709182'

(cherry picked from commit be771a7b7f)
2025-05-10 21:49:59 -07:00
Cy Schubert 7e755cde72 heimdal: Add missing symbols to map
Patch supplied by mi@ through a private email.

Bump __FreeBSD_version for ports that might need this.

PR:		280025

(cherry picked from commit d5c8041388)
2025-05-10 21:49:59 -07:00
Dimitry Andric b2bd1781fe depend-cleanup: ensure clang and llvm binaries are rebuilt
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)
2025-05-09 21:53:20 +02:00
Dimitry Andric ae60fcd40f Convert libllvm, libclang and liblldb into private shared libraries
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)
2025-05-09 19:16:15 +02:00
Gordon Bergling faf7c4ad59 udf: Fix a typo in a source code comment
- s/demostrates/demonstrates/

(cherry picked from commit f6674f74fb)
2025-05-08 08:45:28 +02:00
Xin LI 346bb5d3fe MFV: xz 5.8.1.
PR:		bin/286252

(cherry picked from commit 128836d304)
2025-05-07 14:23:44 -07:00
Lexi Winter b18da5008e net/if_dl.h: make self-contained
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)
2025-05-07 22:01:28 +01:00
Lexi Winter 243de2ac15 net/if_dl.h: put kernel decls behind _KERNEL
Reviewed by:	des
Approved by:	des (mentor)
Differential Revision:	https://reviews.freebsd.org/D50063

(cherry picked from commit a5ba03f6e4)
2025-05-07 20:21:25 +01:00
Lexi Winter a13702f04a bridge: define VLANTAGOF correctly
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)
2025-05-07 20:09:59 +01:00
Graham Perrin 9a6a287c8b tty.4: see also: cross-reference pts(4)
pts(4) already refers to tty(4).

Add a cross-reference.

Reviewed by:	kevans
Approved by:	kevans (mentor)
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1617

(cherry picked from commit 6f4c4cfe4b)
2025-05-07 19:59:47 +01:00
K Rin 7e98bfd666 netstat(1): add description for option -o and -O.
Reviewed by: kevans, ziaee, ivy
Approved by: kevans (mentor)
Fixes: fedeb08b6a ("Introduce scalable route multipath.")
Fixes: a666325282 ("Introduce nexthop objects and new routing KPI.")
Pull Request: https://github.com/freebsd/freebsd-src/pull/1643

(cherry picked from commit afa30c5dec)
2025-05-07 19:53:52 +01:00
Lexi Winter 77e0f080b2 etc: add config tag to /root/.k5login
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)
2025-05-07 15:17:26 +01:00
Lexi Winter cc6b113851 rc.conf.5: add a missing word in the description of $ipv6_enable
Reviewed by:	ziaee, kevans
Approved by:	kevans (mentor)
Differential Revision:	https://reviews.freebsd.org/D50113

(cherry picked from commit dd2d270923)
2025-05-07 15:00:16 +01:00
Philip Paeps 3502f06c66 zoneinfo: also install tzdata.zi and version
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)
2025-05-06 09:57:32 +08:00
Dimitry Andric 979864eef4 Use .pieo extension for WITH_PIE bsd.prog.mk output
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)
2025-05-05 10:59:30 +02:00
Rick Macklem 70369e4c2c mountd: Fix updating the network/host(s) for an exports line
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)
2025-05-03 18:08:24 -07:00
Gordon Bergling ee75c4d77a nvmecontrol(8): Fix two typos in command messages
Fix two typos in command messages:

- s/identiy/identity/

(cherry picked from commit 52cc1708f5)
2025-05-03 13:31:31 +02:00
Arthur Kiyanovski 7ea71ba86a ena: Bump driver version to v2.8.1
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)
2025-05-01 18:14:30 +00:00
David Arinzon 162b5bbb40 ena: Fix misconfiguration when requesting regular LLQ
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)
2025-05-01 18:14:30 +00:00
John Baldwin 00c8c5e2c3 pcib: Clear any pending slot status events during attach
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)
2025-04-29 10:46:43 -04:00
John Baldwin 37032a39c5 pcib: Ignore power fault detected if a power controller is not present
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)
2025-04-29 10:46:30 -04:00
John Baldwin eef4e44a41 telnet: Prevent buffer overflow in the user prompt for SRA
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)
2025-04-29 10:45:59 -04:00
Colin Percival 2ef9c17d68 release: Pass PKG_INSTALL_EPOCH (take 2)
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)
2025-04-26 12:49:35 -07:00
Colin Percival d434f9f58d release: Pass PKG_INSTALL_EPOCH to vmimage.subr
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)
2025-04-26 12:49:09 -07:00
Dimitry Andric 061ce1c392 Move extra suffix-transformation rules into bsd.suffixes-extra.mk
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)
2025-04-26 13:31:20 +02:00
Dimitry Andric b03ee8687e libllvm: remove duplicated SRCS_MIN line
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)
2025-04-26 13:19:27 +02:00
Mark Johnston f7851ff750 netinet: Make ip.h self-contained
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)
2025-04-24 13:23:38 +00:00
Dimitry Andric 5195ff613f Fix build with WITH_CLANG_BOOTSTRAP and WITHOUT_CLANG
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)
2025-04-23 21:37:40 +02:00
Colin Percival c8c624de57 dhclient: Keep two clocks
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)
2025-04-22 21:50:55 -07:00
Kristof Provost 5b182c68c0 pfctl: also remove incorrect counter print for rule anchors
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)
2025-04-21 23:14:17 +02:00
Kristof Provost 35a83d58bd pfctl: fix crash on "pfctl -a '*' -vvsr"
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)
2025-04-21 23:14:17 +02:00
Kristof Provost 4df4b69530 pf: explicitly NULL state key pointers
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)
2025-04-21 23:14:16 +02:00
Kristof Provost 7161339bb5 pf: don't use state keys after pf_state_insert()
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)
2025-04-21 23:14:16 +02:00
Kristof Provost d6381193a3 pf: improve pf_state_key_attach() error handling
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)
2025-04-21 23:14:16 +02:00
Dag-Erling Smørgrav c6cb1b2ee5 cp: Improve error messages.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude, markj
Differential Revision:	https://reviews.freebsd.org/D49841

(cherry picked from commit 7622e2d21a)
2025-04-20 08:00:24 +00:00
Dag-Erling Smørgrav 413e5dca9d fts: Move private flags away from public ones.
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)
2025-04-20 08:00:24 +00:00
Kyle Evans cc7bff2632 libc: tests: add some tests for __cxa_atexit handling
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)
2025-04-16 20:02:43 -05:00
Aurélien Croc de Suray 04f7496f89 libc: allow __cxa_atexit handlers to be added during __cxa_finalize
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)
2025-04-16 20:02:12 -05:00
Kristof Provost 9edd1e62ca pfctl: fix recursive printing of NAT rules
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)
2025-04-16 09:35:42 +02:00
Ed Maste c976df712c OpenSSH: Fix logic error in DisableForwarding option
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)
2025-04-14 15:25:13 -04:00
Eugene Grosbein 92c6cc8ee3 netgraph: MFC: prevent panic with INVARIANTS-enabled kernel
This change makes NG_ABI_VERSION depend on INVARIANTS
in addition to NETGRAPH_DEBUG.

PR:		257876

(cherry picked from commit 93b4a54456)
2025-04-13 05:04:43 +07:00
Dag-Erling Smørgrav 64f5a71c1c fts: Stop abusing the comma operator.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D49624

(cherry picked from commit 5abef29833)
2025-04-08 10:19:41 +00:00
Philip Paeps 5630672e6f lib/libexpat: update build config for 2.7.1
Forgotten in fe9278888f.

Point hat to:	philip

(cherry picked from commit 00c8538e87)
2025-04-07 11:40:56 +08:00
Philip Paeps adc9e9e8db lib/libexpat: bump libbsdxml.3 after 2.7.1 import
Forgotten in fe9278888f.

Pointy hat to:	philip

(cherry picked from commit 03a1992591)
2025-04-07 10:39:30 +08:00
Norbert Ciosek a8431b47ad ixgbe: fix mailbox ack handling
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)
2025-04-04 20:44:37 -07:00
Philip Paeps 41b768ae19 contrib/expat: import expat 2.7.1
Changes: https://github.com/libexpat/libexpat/blob/R_2_7_1/expat/Changes
         https://github.com/libexpat/libexpat/blob/R_2_7_0/expat/Changes

Security:	CVE-2024-8176

(cherry picked from commit fe9278888f)
2025-04-05 11:19:08 +08:00
Eric Joyner 5ae5f71d50 igc(4): Fix attach for I226-K and LMVP devices
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)
2025-04-03 13:00:25 -07:00
Kristof Provost 42aa0d02c2 pf tests: test table information export via snmp_pf
Event:		Tokyo Hackathon 202503
(cherry picked from commit 3658680080)
2025-04-03 07:58:58 +02:00
Kristof Provost ca1bf31177 pf tests: add a basic snmp_pf test case
Event:		Tokyo Hackathon 202503
(cherry picked from commit c849f53332)
2025-04-03 07:58:48 +02:00
Kristof Provost 861b8faca9 snmp_pf: fix pfInterfacesIfRefsState
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)
2025-04-03 07:57:30 +02:00
Andrey V. Elsukov f8cd0c8e20 tests: fix test for NULL encription
After 04207850a9 it is required that key length is not zero.
Add some key to avoid error.

Reported by:	markj

(cherry picked from commit b670804559)
2025-04-02 10:54:12 +03:00
Enji Cooper 4b98fe9def Fix GoogleTest 1.14.0 import
- 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)
2025-03-31 22:30:20 -07:00
Mark Johnston b84a505d2e m4 tests: Update tests after $FreeBSD$ removal
Fixes:	d54a7d3373 ("Remove $FreeBSD$: one-line m4 tag")
(cherry picked from commit d5b5497e10)
2025-03-31 19:39:18 -07:00
Xin LI ebd127c3e3 file: Support testing multiple magic files.
This is based on upstream b74150490be904801378b2712fe0d532e1700124
but adapted to ATF.

Reviewed by: [email protected], markj, vangyzen
Differential Revision: https://reviews.freebsd.org/D42129

(cherry picked from commit 8f75390c66)
2025-03-31 14:34:46 -07:00
Mark Johnston 18c4022e9f netbsd-tests: Update a test case to chase grep symlink handling changes
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)
2025-03-31 14:30:41 -07:00
Mark Johnston 910535a82a uma: Avoid excessive per-CPU draining
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)
2025-03-31 18:36:01 +00:00
Dag-Erling Smørgrav 227c127071 top: Make locale issues non-fatal.
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)
2025-03-31 18:36:01 +00:00
Enji Cooper c15ed41118 dumpon: provide diag info when PEM_read_RSA_PUBKEY fails
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)
2025-03-26 14:36:43 -07:00
Enji Cooper 30cfebf2f0 mca_log: add missing breaks when handling thresholds
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)
2025-03-26 14:26:50 -07:00
Enji Cooper d5425ed751 mptutil: document that disabled/enabled are also supported
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)
2025-03-26 14:26:13 -07:00
Enji Cooper b99e7c4688 lib/libcrypt: another trivial style change
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)
2025-03-26 14:18:00 -07:00
Enji Cooper 62e7a3c6cd lib/libcrypt: remove trailing whitespace
No functional change intended.

MFC after:	2 weeks

(cherry picked from commit 8ef8da882f)
2025-03-26 14:16:38 -07:00
Enji Cooper f7d46b858a radlib: fix a memory leak in is_valid_request
Call `HMAC_CTX_free` if returning early from `is_valid_request` when
processing `Message-Authenticator` tags.

Reported by:	Coverity
MFC after:	1 week
Fixes: 8d5c781306 ("libradius: Fix input validation bugs")
Differential Revision:	https://reviews.freebsd.org/D45488

(cherry picked from commit 77c04f3eb1)
2025-03-26 14:15:25 -07:00
Enji Cooper f50d338974 lib/libsbuf/tests: reformat with clang-format
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)
2025-03-26 14:10:48 -07:00
Enji Cooper a5403c1f7d contrib/googletest: update from 1.14.0 to 1.15.2
The changes between the two versions can be found in this diff of the
two release tags:
https://github.com/google/googletest/compare/v1.14.0...v1.15.2

One notable change is that GoogleTest 1.15.x now officially requires
C++-14 (1.14.x required C++-11).

MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D47197

Merge commit '14f7077fed7d82046bdcbe347004132f08aba886'

(cherry picked from commit 5ca8c28cd8)
(cherry picked from commit 1d67cec525)
2025-03-26 13:00:35 -07:00
Enji Cooper eb331308b0 tests/sys/fs/fusefs: include iomanip header
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)
2025-03-26 12:34:05 -07:00
Enji Cooper 687096cf1e Import GoogleTest 1.14.0
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)
2025-03-26 09:41:31 -07:00
Enji Cooper 2adc0bae0b fusefs tests: handle -Wdeprecated* issues with GoogleTest 1.14.0
`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)
2025-03-26 09:40:48 -07:00
Philip Paeps 7b17666c32 contrib/tzdata: import tzdata 2025b
Changes: https://github.com/eggert/tz/blob/2025b/NEWS

(cherry picked from commit d2cccdef30)
2025-03-26 09:04:40 +08:00
Alexander Ziaee 69569859a0 ports.7: Update dialog4ports to portconfig
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)
2025-03-23 21:42:56 -04:00
Michael Osipov f89c056e11 caroot: update the root bundle
Summary:
- Seven (7) new roots
- Four (4) distrusted roots
- Fourteen (14) removed (expired) roots

Reviewed by:	kevans
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D49294

(cherry picked from commit 0100da4deb)
2025-03-20 12:32:44 +01:00
Cy Schubert dd503d7b4c ntp: Replace the workaround from 98e34e8e25 with a patch from upstream
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)
2025-03-19 20:10:43 -07:00
Cy Schubert 9d425f11f9 ntp: Another patch to address IPv6 pool regression
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)
2025-03-19 20:10:29 -07:00
Cy Schubert e7b5dabcba ntp: ntpd does not connect to NTP server with link local IPv6 address
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)
2025-03-19 20:10:09 -07:00
Mateusz Guzik d0105578f0 inet6: add the missing lock acquire to nd6_get_llentry
Reported by:	Lexi Winter
PR:		282378
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit d6138a6540)
2025-03-18 14:38:00 +00:00
Andrey V. Elsukov b297093eba routing: do not allow PINNED routes to be overriden
First configured PINNED routes should have higher priority.

Fixes:		1da4954c92
Differential Revision:	https://reviews.freebsd.org/D48650

(cherry picked from commit 361a8395f0)
2025-03-18 12:11:37 +03:00
Michael Osipov 61df1b78f9 sh(1): Replace recommendation of use of -e with a note
This partially reverts b14cfdf665 and has
been discussed in D42719.

Reviewed by:	jrm (mentor), otis (mentor), mandree, ziaee (manpages)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45073

(cherry picked from commit 7bd8da72c5)
2025-03-15 15:01:42 +01:00
Michael Osipov d3e5558d31 caroot: Ignore soft distrust of server CA certificates after 398 days
Mozilla introduced the field CKA_NSS_SERVER_DISTRUST_AFTER which indicates that
a CA certificate will be distrusted in the future before its NotAfter time.
This means that the CA stops issuing new certificates, but previous ones are
still valid, but at most for 398 days after the distrust date.

See also:
* https://bugzilla.mozilla.org/show_bug.cgi?id=1465613
* https://github.com/Lukasa/mkcert/issues/19
* https://gitlab.alpinelinux.org/alpine/ca-certificates/-/merge_requests/16
* https://github.com/curl/curl/commit/448df98d9280b3290ecf63e5fc9452d487f41a7c

Tested by:	michaelo
Reviewed by:	emaste
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D49075

(cherry picked from commit 457c03b397)
2025-03-15 14:56:16 +01:00
Warner Losh a4a271424f posix: POSIX-1.2008 moved SA_* from XSI to base standard
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)
2025-03-14 11:51:46 -06:00
Andrey V. Elsukov 1219a3f40d pfkey2: use correct value for a key length
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)
2025-03-13 13:23:29 +03:00
Andrey V. Elsukov f1929835f7 ipfw: fix dump_soptcodes() handler
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)
2025-03-13 13:18:44 +03:00
Cy Schubert 067cf605f8 Revert "ntpd: Use the ntpd -u option in preference to the rc su plumbing"
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)
2025-03-11 10:59:36 -07:00
Jose Luis Duran 2008349686 vmm: Emulate testb imm8,r/m8
Add support for "testb imm8,r/m8" emulation.

PR:		261940
PR:		282852
Reviewed by:	markj, emaste
Approved by:	emaste (mentor)
Obtained from:	Illumos (https://www.illumos.org/issues/14483)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D49208

(cherry picked from commit 49a4838a0d)
2025-03-11 00:42:30 +00:00
Zhenlei Huang 6771ec1d6a netlink: Fix getting route scope of interface's IPv4 addresses
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)
2025-03-10 18:23:11 +08:00
Zhenlei Huang 9f26a03fdb tests/netlink: Assert the route scope of interface's addresses
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)
2025-03-10 18:23:11 +08:00
Andrey V. Elsukov 699ed29c4f routing: set net.route.multipath=0 when kernel doesn't have ROUTE_MPATH
(cherry picked from commit f2644d64b4)
2025-03-07 12:56:14 +03:00
Cy Schubert d2011755f3 ipf: Correct ippool.5 man page
The file URL must be enclosed in quotes.

MFC after:	3 days

(cherry picked from commit 278a726eec)
2025-03-06 16:33:41 -08:00
Cy Schubert 2fae556f6a var_run: Clean up style
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)
2025-03-04 20:46:14 -08:00
Ed Maste 206ed99650 Cirrus-CI: Bump image to (supported) 13.4
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 5bd7cf837c)
(cherry picked from commit 7bcd307814)
2025-03-03 11:24:57 -05:00
Kevin Lo 42ba6765c9 ixgbe: Fix a logic error in ixgbe_read_mailbox_vf()
Reviewed by:	kbowling
Differential Revision:	https://reviews.freebsd.org/D49156

(cherry picked from commit 5c7087c349)
2025-03-03 09:39:28 +08:00
Tore Amundsen e94246e0a2 net: if_media for 1000Base-BX BiDi
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)
2025-03-02 13:57:59 -07:00
Cy Schubert a3d32f9e60 ntp: NULL pointer deref when create_interface() fails
Fix NULL pointer dereference when create_interface() fails in
update_interfaces(). The upstream bug report says a typo was introduced
by https://bk.ntp.org/ntp-dev/ntpd/ntp_io.c?PAGE=diffs&REV=66175036PETA6g__fON8oNrjL54Ttw. ep should have been ep2.

Fix obtained from upstream bug report.

PR:		285065
Upstream bug:	https://bugs.ntp.org/show_bug.cgi?id=3939

(cherry picked from commit 628715fdcc)
2025-02-28 07:58:54 -08:00
Olivier Certner 4fd887f08b queue: Fix STAILQ_ASSERT_EMPTY()
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)
2025-02-27 22:11:10 +01:00
Rick Macklem 319b59fbde nfscl: Fix setting of mtime for the NFSv4.n client
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)
2025-02-26 18:35:54 -08:00
Jose Luis Duran f931a32bca openssh: Fix blacklistd sshd-session integration
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)
2025-02-26 16:42:45 +00:00
Cy Schubert 9b65c9cdbb shar: Make sure a sed failure in the generated archive results in failure
Obtained from:	NetBSD hg commit 365369:21b92f0055b4
MFC after:	1 week

(cherry picked from commit f0c8d2cd62)
2025-02-24 16:38:10 -08:00
Cy Schubert 9b70262b08 shar: Handle special characters or white space in file names fed to shar
Obtained from:	NetBSD hg commit 365370:124268924386
MFC after:	1 week

(cherry picked from commit 1080f53154)
2025-02-24 16:38:10 -08:00
Cy Schubert 92c834c698 ntpd: Use the ntpd -u option in preference to the rc su plumbing
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)
2025-02-24 16:38:10 -08:00
Emmanuel Vadot ab4d246b78 Deprecate publickey(5) stuff
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)
2025-02-24 10:53:42 -05:00
Ed Maste 96e06df5bc upgt: Deprecate ancient 802.11b/g driver
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)
2025-02-24 10:53:42 -05:00
Andrey V. Elsukov 63422982e0 ipfw: make 'ipfw show' output compatible with 'ipfw add' command
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)
2025-02-21 14:18:44 +03:00
Ed Maste a8c1ea2614 openssh: Update to 9.9p2
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)
2025-02-20 12:56:24 -05:00
Ed Maste 6e688e6d4f openssh: Update to 9.9p1
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)
2025-02-20 12:56:23 -05:00
Ed Maste c845ae4755 openssh: Update to 9.8p1
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)
2025-02-20 12:56:23 -05:00
Ed Maste 63d3c24522 libssh: Remove progressmeter
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)
2025-02-20 08:21:02 -05:00
Ed Maste 10e9add50f ssh: Move XAUTH_PATH setting to ssh.mk
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)
2025-02-20 08:21:02 -05:00
Ed Maste 935e29dcdd ssh_config.5: Remove redundant CheckHostIP default text
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)
2025-02-20 08:21:02 -05:00
Ed Maste fb4102bc52 vtfontcvt: Improve error message for unsupported DWIDTH
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)
2025-02-19 21:49:24 -05:00
Li-Wen Hsu fd3016b17e Canonicalize the name of the FreeBSD Foundation
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit dab59af3bc)
(cherry picked from commit ef3ed0726f)
2025-02-19 14:52:36 -05:00
Colin Percival 4ddbb7945c pkg-stage.sh: kde5 -> kde
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)
2025-02-19 11:25:50 -08:00
Jose Luis Duran 2dcc11d827 uath: Avoid a NULL dereference
PR:		284643
Reviewed by:	adrian
Approved by:	emaste (mentor)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D48948

(cherry picked from commit 4b77a9a80c)
2025-02-19 16:23:59 +00:00
Ed Maste b2674931a2 ssh: update FREEBSD-upgrade instructions
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)
2025-02-19 10:26:58 -05:00
Ed Maste 2fc62d0bd4 ssh: Bump VersionAddendum for CVE fixes
Approved by:	so
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 62df41ae0a)
(cherry picked from commit 24ce323f02)
2025-02-19 10:02:39 -05:00
Ed Maste 8c67967cb1 ssh: Fix cases where error codes were not correctly set
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)
2025-02-19 10:02:39 -05:00
Ed Maste 3ea366f744 ssh: Don't reply to PING in preauth phase or during KEX
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)
2025-02-19 10:02:39 -05:00
Kristof Provost f84494807e pf: fix fragment hole count
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)
2025-02-18 17:49:42 +01:00
Kristof Provost a5b6cff9a6 pf: do not keep state when dropping overlapping IPv6 fragments
ok sperreault@

Obtained from:	OpenBSD, bluhm <[email protected]>, cd45765685
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 3b79f6d2d3)
2025-02-18 17:49:42 +01:00
Kristof Provost a61c2617f1 pf: drop IPv6 packets built from overlapping fragments in pf reassembly
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)
2025-02-18 17:49:42 +01:00
Kristof Provost 91ff75b756 pf.conf.5: fix ≤
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)
2025-02-18 17:49:41 +01:00
Zhenlei Huang 904510b2ac powerpc: Remove flag CTLFLAG_TUN from sysctl knob hw.platform
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)
2025-02-18 23:23:37 +08:00
Kevin Bowling d22c729454 ixgbe: x550 support for 1000BASE-BX SFP modules
Add support for 1Gbit BiDi modules to x550 derivatives

(cherry picked from commit 1836216556)
2025-02-17 20:27:25 -07:00
Jose Luis Duran 8bd278e270 mtree: Add missing directories generated by certctl
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
2025-02-17 20:49:30 +00:00
Jose Luis Duran 057598ba18 mtree: Add missing flua entry
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
2025-02-17 20:11:19 +00:00
Andrey V. Elsukov ff2588f2ac ipfw: add missing initializer for 'limit' table value
PR:		284691

(cherry picked from commit 95ab7b3223)
2025-02-17 10:40:29 +03:00
Jose Luis Duran b6490ad408 ObsoleteFiles.inc: Remove test debug file from wrong dir
Reported by:	des
Reviewed by:	des, emaste
Approved by:	emaste (mentor)
Fixes:	88d448ec81 ("mk: Move vm stack test debug symbols")
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D48991

(cherry picked from commit e159dcc37e)
2025-02-16 04:15:31 +00:00
Kevin Bowling a06369238d igc: Remove unused register IGC_RXD_SPC_VLAN_MASK
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)
2025-02-15 17:26:50 -07:00
Aurelien Cazuc e812e4d86d e1000: Fix vlan PCP/DEI on lem(4)
The vlan PCP and CFI/DEI were discarded when receiving vlan tagged
packets on lem(4) interfaces with vlanhwtag.

According to the 82540 SDM[1] (pg. 24), vlan tag is in the standard
format, so there's no reason to discard PCP/DEI.

[1]: http://iommu.com/datasheets/ethernet/controllers-nics/intel/e1000/pci-pci-x-family-gbe-controllers-software-dev-manual.pdf

Sponsored by:	Stormshield (author)
Differential Revision:	https://reviews.freebsd.org/D48987

(cherry picked from commit 4b29599fbb)
2025-02-15 17:26:40 -07:00
Tore Amundsen b26592d87d ixgbe: Add support for 1000BASE-BX SFP modules
Add support for 1Gbit BiDi modules

Signed-off-by:	Tore Amundsen <[email protected]>
Relnotes:	yes
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1518

(cherry picked from commit 89d4096950)
2025-02-15 17:26:26 -07:00
Kevin Bowling 4759b165d5 ixgbe: Add ixgbe_dev_from_hw() back
This got lost many years ago in 8eb6488ebb

It is used by the driver's DBG printfs.

(cherry picked from commit bf6f0db8a7)
2025-02-13 18:25:09 -07:00
John Baldwin 749ec2967e pac: Consistently use item count as the first argument to calloc
Reported by:	GCC 14 -Wcalloc-transposed-args

(cherry picked from commit 22956bc9dc)
2025-02-13 12:49:06 -05:00
John Baldwin 74a5a7d842 pac: Use strdup and asprintf in place of dubious string building
GCC 14 warned about transposed arguments to calloc, but these cases
are better served by more abstract string functions.

(cherry picked from commit f94513a3a3)
2025-02-13 12:49:02 -05:00
Zhenlei Huang dcd7286d90 sysctl: Harden sysctl_handle_string() against unterminated string
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)
2025-02-13 18:23:04 +08:00
Zhenlei Huang 87836ab994 MAC: mac_biba, mac_lomac: Fix setting loader tunables
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)
2025-02-13 18:23:03 +08:00
Ronald Klop 9370c2c331 Remove obsolete clang18 files for aarch64
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)
2025-02-13 09:23:59 +01:00
Dag-Erling Smørgrav 931b099029 unifdef: Fix collision check when adding symbols.
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)
2025-02-13 01:39:04 +01:00
Michael Tuexen e1dd07ede9 icmp: use per rate limit randomized jitter
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)
2025-02-12 15:07:19 +01:00
Michael Tuexen bd6a89a6c3 icmp: improve INVARIANTS check
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)
2025-02-12 15:06:14 +01:00
Gleb Smirnoff 1b4561cf4b icmp: correct the assertion that checks limit + jitter
Fixes:	4399e055ea
(cherry picked from commit f7c4d12bcd)
2025-02-12 15:05:14 +01:00
Gleb Smirnoff 0b29ef1e3f icmp: allow zero value for ICMP limits
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)
2025-02-12 15:03:22 +01:00
Gleb Smirnoff 1cc0ac5ef3 icmp6: bring rate limiting on a par with IPv4
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)
2025-02-12 15:02:01 +01:00
Gleb Smirnoff 90ecc3fc67 icmp6: rate limit our echo replies
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)
2025-02-12 11:28:44 +01:00
Gleb Smirnoff dc167e64dc icmp6: make icmp6_ratelimit() responsible to update the stats counter
Reviewed by:		tuexen
Differential Revision:	https://reviews.freebsd.org/D44479

(cherry picked from commit c6c96aaba8)
2025-02-12 11:27:12 +01:00
Gleb Smirnoff 18058544c6 icmp: improve ICMP limit jitter
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)
2025-02-12 11:23:36 +01:00
Gleb Smirnoff a71eee300b icmp: when logging ICMP ratelimiting message use correct jitter value
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)
2025-02-12 11:22:14 +01:00
Gleb Smirnoff a6d5c6a04f icmp: hide icmp_bandlimit_uninit() under VIMAGE
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)
2025-02-12 11:20:53 +01:00
Gleb Smirnoff 0939f3a046 icmp: do not store per-VNET identical array of strings
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)
2025-02-12 11:15:53 +01:00
Jose Luis Duran 28ac62860b mtree: Add missing libxo/encoder path
Reviewed by:	imp
Approved by:	emaste (mentor)
Fixes:	d1a0d267b7 ("Upgrade libxo to 0.4.5.")
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D48836

(cherry picked from commit d10deaea12)
2025-02-12 01:41:52 +00:00
Jose Luis Duran ceab30bfe2 mk: Move vm stack test debug symbols
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)
2025-02-12 01:41:18 +00:00
Jose Luis Duran 65b71a21fc libopencsd: Remove extra slashes
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)
2025-02-12 01:39:41 +00:00
Jose Luis Duran 11391f2fa3 csu tests: Remove extra slash
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)
2025-02-12 01:38:56 +00:00
Jose Luis Duran 6fc8d02b59 nanobsd: Always define the partition index
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)
2025-02-12 01:38:47 +00:00
Juraj Lutter c204fdb1c8 periodic: set _localbase for periodic scripts from within periodic.conf
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)
2025-02-11 14:48:14 +01:00
Kevin Bowling a32cc87cc0 net: if_media for 100BASE-BX
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)
2025-02-10 17:52:16 -07:00
Gordon Bergling d9c36c812b mlx4ib(4): Fix some typos in device messages
- s/availible/available/

(cherry picked from commit 84e3ffac12)
2025-02-10 07:56:05 +01:00
Colin Percival 8984d070d6 release: Chase location of pkg repo databases
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)
2025-02-09 13:16:25 -08:00
Gleb Smirnoff 55c3167e51 tests/sigsys: initialize parameter passed to sysctlbyname()
(cherry picked from commit e53b83a849)
(cherry picked from commit e4e6423ef3)
2025-02-10 00:39:02 +08:00
Ed Maste ca3c2d2862 jls.8: Reference correct manpage for libxo options
PR:		284135
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 90670e0e27)
(cherry picked from commit 707adc335e)
2025-02-07 10:59:52 -05:00
Ed Maste 02cd05b637 blocklistd: Remove obsolete network class reference
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)
2025-02-07 10:57:35 -05:00
Kirk McKusick 6f87402a02 Defer the January 19, 2038 date limit in UFS1 filesystems to February 7, 2106
Standardize the definition of a UFS dinode.

Differential Revision: https://reviews.freebsd.org/D48472

(cherry picked from commit 1111a44301)
(cherry picked from commit aa90fbed15)
(cherry picked from commit 256389eaf1)
(cherry picked from commit 6cd973d903)
(cherry picked from commit e1ebda4458)
2025-02-06 16:27:15 -08:00
Colin Percival 645ddc8048 Post-13.5-branch updates
Rename stable/13 to -STABLE

Bump __FreeBSD_version

Approved by:	re (implicit)
Sponsored by:	Amazon
2025-02-07 00:00:00 +00:00
3235 changed files with 295927 additions and 206274 deletions

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@ compute_engine_instance:
# gcloud compute images list --project freebsd-org-cloud-dev --no-standard-images
platform: freebsd
image_project: freebsd-org-cloud-dev
image: freebsd-13-3-release-amd64
image: freebsd-13-5-release-amd64
cpu: 8
memory: 8G
disk: 40
+1 -1
View File
@@ -2,7 +2,7 @@ name: Cross-build Kernel
on:
push:
branches: [ main, 'stable/13' ]
branches: [ main, 'stable/[1-9][0-9]' ]
pull_request:
branches: [ main ]
+1
View File
@@ -22,3 +22,4 @@ cscope.in.out
cscope.out
cscope.po.out
tags
/src.conf
+8 -3
View File
@@ -607,7 +607,10 @@ XPATH= ${WORLDTMP}/bin:${WORLDTMP}/usr/sbin:${WORLDTMP}/usr/bin
# When building we want to find the cross tools before the host tools in ${BPATH}.
# We also need to add UNIVERSE_TOOLCHAIN_PATH so that we can find the shared
# toolchain files (clang, lld, etc.) during make universe/tinderbox
STRICTTMPPATH= ${XPATH}:${BPATH}:${UNIVERSE_TOOLCHAIN_PATH}
STRICTTMPPATH= ${XPATH}:${BPATH}
.if defined(UNIVERSE_TOOLCHAIN_PATH)
STRICTTMPPATH:=${STRICTTMPPATH}:${UNIVERSE_TOOLCHAIN_PATH}
.endif
# We should not be using tools from /usr/bin accidentally since this could cause
# the build to break on other systems that don't have that tool. For now we
# still allow using the old behaviour (inheriting $PATH) if
@@ -782,6 +785,7 @@ TMAKE= \
# TOOLS_PREFIX set in BMAKE
XMAKE= ${BMAKE} \
TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
MK_CLANG=${MK_CLANG_BOOTSTRAP} \
MK_CLANG_IS_CC=${MK_CLANG_BOOTSTRAP} \
MK_LLDB=no \
MK_LLVM_BINUTILS=no \
@@ -1354,7 +1358,7 @@ _sysctl=sysctl
.endif
ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
date echo egrep find grep id install ${_install-info} \
date echo egrep find grep id install \
ln make mkdir mtree mv pwd_mkdb \
rm sed services_mkdb sh sort strip ${_sysctl} test true uname wc
@@ -2707,7 +2711,7 @@ _elftctools= lib/libelftc \
.endif
.if ${MK_CLANG_BOOTSTRAP} != "no"
_clang= usr.bin/clang
_clang= usr.bin/clang/clang
.endif
.if ${MK_LLD_BOOTSTRAP} != "no"
_lld= usr.bin/clang/lld
@@ -2846,6 +2850,7 @@ NXBMAKEARGS+= \
MK_DEBUG_FILES=no \
MK_HTML=no \
MK_LLDB=no \
MK_LLVM_LINK_STATIC_LIBRARIES=yes \
MK_MAN=no \
MK_MAN_UTILS=yes \
MK_OFED=no \
+135
View File
@@ -51,6 +51,123 @@
# xargs -n1 | sort | uniq -d;
# done
# 20260430: Regenerate trust store
OLD_FILES+=usr/share/certs/trusted/Entrust_net_Premium_2048_Secure_Server_CA.pem
OLD_FILES+=usr/share/certs/trusted/AffirmTrust_Premium.pem
OLD_FILES+=usr/share/certs/trusted/Starfield_Class_2_CA.pem
OLD_FILES+=usr/share/certs/trusted/GTS_Root_R2.pem
OLD_FILES+=usr/share/certs/trusted/GLOBALTRUST_2020.pem
OLD_FILES+=usr/share/certs/trusted/Secure_Global_CA.pem
OLD_FILES+=usr/share/certs/trusted/GlobalSign_Root_CA.pem
OLD_FILES+=usr/share/certs/trusted/CommScope_Public_Trust_RSA_Root-01.pem
OLD_FILES+=usr/share/certs/trusted/Trustwave_Global_ECC_P384_Certification_Authority.pem
OLD_FILES+=usr/share/certs/trusted/SwissSign_Gold_CA_-_G2.pem
OLD_FILES+=usr/share/certs/trusted/Go_Daddy_Class_2_CA.pem
OLD_FILES+=usr/share/certs/trusted/FIRMAPROFESIONAL_CA_ROOT-A_WEB.pem
OLD_FILES+=usr/share/certs/trusted/Trustwave_Global_Certification_Authority.pem
OLD_FILES+=usr/share/certs/trusted/Trustwave_Global_ECC_P256_Certification_Authority.pem
OLD_FILES+=usr/share/certs/trusted/CommScope_Public_Trust_ECC_Root-01.pem
OLD_FILES+=usr/share/certs/trusted/Entrust_Root_Certification_Authority_-_EC1.pem
OLD_FILES+=usr/share/certs/trusted/Certigna.pem
OLD_FILES+=usr/share/certs/trusted/AffirmTrust_Commercial.pem
OLD_FILES+=usr/share/certs/trusted/DigiCert_Assured_ID_Root_CA.pem
OLD_FILES+=usr/share/certs/trusted/Baltimore_CyberTrust_Root.pem
OLD_FILES+=usr/share/certs/trusted/CommScope_Public_Trust_ECC_Root-02.pem
OLD_FILES+=usr/share/certs/trusted/Entrust_Root_Certification_Authority.pem
OLD_FILES+=usr/share/certs/trusted/AffirmTrust_Premium_ECC.pem
OLD_FILES+=usr/share/certs/trusted/CommScope_Public_Trust_RSA_Root-02.pem
OLD_FILES+=usr/share/certs/trusted/TeliaSonera_Root_CA_v1.pem
OLD_FILES+=usr/share/certs/trusted/QuoVadis_Root_CA_2.pem
OLD_FILES+=usr/share/certs/trusted/COMODO_Certification_Authority.pem
OLD_FILES+=usr/share/certs/trusted/SecureTrust_CA.pem
OLD_FILES+=usr/share/certs/trusted/Comodo_AAA_Services_root.pem
OLD_FILES+=usr/share/certs/trusted/Entrust_Root_Certification_Authority_-_G2.pem
OLD_FILES+=usr/share/certs/trusted/QuoVadis_Root_CA_3.pem
OLD_FILES+=usr/share/certs/trusted/DigiCert_High_Assurance_EV_Root_CA.pem
OLD_FILES+=usr/share/certs/trusted/certSIGN_ROOT_CA.pem
OLD_FILES+=usr/share/certs/trusted/DigiCert_Global_Root_CA.pem
OLD_FILES+=usr/share/certs/trusted/AffirmTrust_Networking.pem
OLD_FILES+=usr/share/certs/trusted/XRamp_Global_CA_Root.pem
OLD_FILES+=usr/share/certs/blacklisted/Security_Communication_RootCA3.pem
OLD_FILES+=usr/share/certs/blacklisted/GeoTrust_Primary_Certification_Authority_-_G3.pem
OLD_FILES+=usr/share/certs/blacklisted/E-Tugra_Global_Root_CA_ECC_v3.pem
OLD_FILES+=usr/share/certs/blacklisted/Symantec_Class_2_Public_Primary_Certification_Authority_-_G4.pem
OLD_FILES+=usr/share/certs/blacklisted/EE_Certification_Centre_Root_CA.pem
OLD_FILES+=usr/share/certs/blacklisted/EC-ACC.pem
OLD_FILES+=usr/share/certs/blacklisted/Hellenic_Academic_and_Research_Institutions_RootCA_2011.pem
OLD_FILES+=usr/share/certs/blacklisted/GeoTrust_Universal_CA.pem
OLD_FILES+=usr/share/certs/blacklisted/Global_Chambersign_Root_-_2008.pem
OLD_FILES+=usr/share/certs/blacklisted/Camerfirma_Global_Chambersign_Root.pem
OLD_FILES+=usr/share/certs/blacklisted/Verisign_Class_1_Public_Primary_Certification_Authority_-_G3.pem
OLD_FILES+=usr/share/certs/blacklisted/Symantec_Class_1_Public_Primary_Certification_Authority_-_G6.pem
OLD_FILES+=usr/share/certs/blacklisted/GeoTrust_Primary_Certification_Authority_-_G2.pem
OLD_FILES+=usr/share/certs/blacklisted/TrustCor_RootCert_CA-2.pem
OLD_FILES+=usr/share/certs/blacklisted/GeoTrust_Universal_CA_2.pem
OLD_FILES+=usr/share/certs/blacklisted/Network_Solutions_Certificate_Authority.pem
OLD_FILES+=usr/share/certs/blacklisted/thawte_Primary_Root_CA.pem
OLD_FILES+=usr/share/certs/blacklisted/E-Tugra_Global_Root_CA_RSA_v3.pem
OLD_FILES+=usr/share/certs/blacklisted/GeoTrust_Primary_Certification_Authority.pem
OLD_FILES+=usr/share/certs/blacklisted/Taiwan_GRCA.pem
OLD_FILES+=usr/share/certs/blacklisted/Verisign_Class_2_Public_Primary_Certification_Authority_-_G3.pem
OLD_FILES+=usr/share/certs/blacklisted/Symantec_Class_2_Public_Primary_Certification_Authority_-_G6.pem
OLD_FILES+=usr/share/certs/blacklisted/VeriSign_Class_3_Public_Primary_Certification_Authority_-_G5.pem
OLD_FILES+=usr/share/certs/blacklisted/SwissSign_Platinum_CA_-_G2.pem
OLD_FILES+=usr/share/certs/blacklisted/TrustCor_RootCert_CA-1.pem
OLD_FILES+=usr/share/certs/blacklisted/thawte_Primary_Root_CA_-_G3.pem
OLD_FILES+=usr/share/certs/blacklisted/Camerfirma_Chambers_of_Commerce_Root.pem
OLD_FILES+=usr/share/certs/blacklisted/SwissSign_Silver_CA_-_G2.pem
OLD_FILES+=usr/share/certs/blacklisted/TrustCor_ECA-1.pem
OLD_FILES+=usr/share/certs/blacklisted/VeriSign_Class_3_Public_Primary_Certification_Authority_-_G4.pem
OLD_FILES+=usr/share/certs/blacklisted/SecureSign_RootCA11.pem
OLD_FILES+=usr/share/certs/blacklisted/Chambers_of_Commerce_Root_-_2008.pem
OLD_FILES+=usr/share/certs/blacklisted/Verisign_Class_3_Public_Primary_Certification_Authority_-_G3.pem
OLD_FILES+=usr/share/certs/blacklisted/VeriSign_Universal_Root_Certification_Authority.pem
OLD_FILES+=usr/share/certs/blacklisted/LuxTrust_Global_Root_2.pem
OLD_FILES+=usr/share/certs/blacklisted/thawte_Primary_Root_CA_-_G2.pem
OLD_FILES+=usr/share/certs/blacklisted/Symantec_Class_1_Public_Primary_Certification_Authority_-_G4.pem
# 20251006: Remove libnss_tacplus.a (it never should have been installed)
OLD_FILES+=usr/lib/libnss_tacplus.a
# 20250812: Remove a bogus manlink
OLD_FILES+=usr/share/man/man3/quota_statfs.3.gz
# 20250805: Test case renamed
OLD_FILES+=usr/tests/usr.bin/xargs/regress.n2147483647.out
# 20250710: share: Delete bitrotted make_*_driver.sh scripts
OLD_FILES+=usr/share/examples/drivers/README
OLD_FILES+=usr/share/examples/drivers/make_device_driver.sh
OLD_FILES+=usr/share/examples/drivers/make_pseudo_driver.sh
OLD_DIRS+=usr/share/examples/drivers
# 20250524: don't install zoneinfo version
OLD_FILES+=usr/share/zoneinfo/version
# 20250310: caroot bundle updated
OLD_FILES+=usr/share/certs/trusted/Entrust_Root_Certification_Authority_-_G4.pem
OLD_FILES+=usr/share/certs/trusted/SecureSign_RootCA11.pem
OLD_FILES+=usr/share/certs/trusted/Security_Communication_RootCA3.pem
OLD_FILES+=usr/share/certs/trusted/SwissSign_Silver_CA_-_G2.pem
OLD_FILES+=usr/share/certs/blacklisted/AddTrust_External_Root.pem
OLD_FILES+=usr/share/certs/blacklisted/AddTrust_Low-Value_Services_Root.pem
OLD_FILES+=usr/share/certs/blacklisted/Staat_der_Nederlanden_Root_CA_-_G2.pem
OLD_FILES+=usr/share/certs/blacklisted/Cybertrust_Global_Root.pem
OLD_FILES+=usr/share/certs/blacklisted/DST_Root_CA_X3.pem
OLD_FILES+=usr/share/certs/blacklisted/GlobalSign_Root_CA_-_R2.pem
OLD_FILES+=usr/share/certs/blacklisted/QuoVadis_Root_CA.pem
OLD_FILES+=usr/share/certs/blacklisted/Sonera_Class_2_Root_CA.pem
OLD_FILES+=usr/share/certs/blacklisted/GeoTrust_Global_CA.pem
OLD_FILES+=usr/share/certs/blacklisted/Staat_der_Nederlanden_EV_Root_CA.pem
OLD_FILES+=usr/share/certs/blacklisted/E-Tugra_Certification_Authority.pem
OLD_FILES+=usr/share/certs/blacklisted/Hongkong_Post_Root_CA_1.pem
OLD_FILES+=usr/share/certs/blacklisted/Security_Communication_Root_CA.pem
OLD_FILES+=usr/share/certs/blacklisted/Trustis_FPS_Root_CA.pem
# 20250204: sys/vm/stack test symbols moved to /usr/lib/debug
OLD_FILES+=usr/tests/sys/vm/stack/.debug/libsoxstack.so.debug
OLD_DIRS+=usr/tests/sys/vm/stack/.debug
# 20241201: new clang import which bumps version from 18 to 19
OLD_FILES+=usr/lib/clang/18/include/__clang_cuda_builtin_vars.h
OLD_FILES+=usr/lib/clang/18/include/__clang_cuda_cmath.h
@@ -347,6 +464,7 @@ OLD_FILES+=usr/lib/clang/18/lib/freebsd/libclang_rt.asan_cxx-powerpc64.a
OLD_FILES+=usr/lib/clang/18/lib/freebsd/libclang_rt.asan_cxx-powerpc64le.a
OLD_FILES+=usr/lib/clang/18/lib/freebsd/libclang_rt.asan_cxx-riscv64.a
OLD_FILES+=usr/lib/clang/18/lib/freebsd/libclang_rt.asan_cxx-x86_64.a
OLD_FILES+=usr/lib/clang/18/lib/freebsd/libclang_rt.asan_static-aarch64.a
OLD_FILES+=usr/lib/clang/18/lib/freebsd/libclang_rt.asan_static-i386.a
OLD_FILES+=usr/lib/clang/18/lib/freebsd/libclang_rt.asan_static-powerpc64.a
OLD_FILES+=usr/lib/clang/18/lib/freebsd/libclang_rt.asan_static-powerpc64le.a
@@ -365,6 +483,7 @@ OLD_FILES+=usr/lib/clang/18/lib/freebsd/libclang_rt.dd-aarch64.a
OLD_FILES+=usr/lib/clang/18/lib/freebsd/libclang_rt.dd-x86_64.a
OLD_FILES+=usr/lib/clang/18/lib/freebsd/libclang_rt.fuzzer-aarch64.a
OLD_FILES+=usr/lib/clang/18/lib/freebsd/libclang_rt.fuzzer-x86_64.a
OLD_FILES+=usr/lib/clang/18/lib/freebsd/libclang_rt.fuzzer_interceptors-aarch64.a
OLD_FILES+=usr/lib/clang/18/lib/freebsd/libclang_rt.fuzzer_interceptors-x86_64.a
OLD_FILES+=usr/lib/clang/18/lib/freebsd/libclang_rt.fuzzer_no_main-aarch64.a
OLD_FILES+=usr/lib/clang/18/lib/freebsd/libclang_rt.fuzzer_no_main-x86_64.a
@@ -1393,6 +1512,22 @@ OLD_FILES+=usr/share/certs/trusted/E-Tugra_Global_Root_CA_ECC_v3.pem
OLD_FILES+=usr/share/certs/trusted/E-Tugra_Global_Root_CA_RSA_v3.pem
OLD_FILES+=usr/share/certs/trusted/Hongkong_Post_Root_CA_1.pem
# 20230807: GoogleTest 1.14.0 upgrade.
OLD_FILES+=usr/include/private/gmock/gmock-generated-actions.h
OLD_FILES+=usr/include/private/gmock/gmock-generated-function-mockers.h
OLD_FILES+=usr/include/private/gmock/gmock-generated-matchers.h
OLD_FILES+=usr/include/private/gmock/gmock-generated-nice-strict.h
OLD_FILES+=usr/include/private/gmock/internal/gmock-generated-internal-utils.h
OLD_FILES+=usr/include/private/gtest/internal/gtest-linked_ptr.h
OLD_FILES+=usr/include/private/gtest/internal/gtest-param-util-generated.h
OLD_FILES+=usr/include/private/gtest/internal/gtest-tuple.h
OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-generated-actions_test
OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-generated-function-mockers_test
OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-generated-internal-utils_test
OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-generated-matchers_test
OLD_FILES+=usr/tests/lib/googletest/gmock_main/gmock-matchers_test
OLD_FILES+=usr/tests/lib/googletest/gtest_main/googletest-linked-ptr-test
# 20230806: Removal of support for the VTOC8 partitioning scheme
OLD_FILES+=usr/include/sys/disk/vtoc.h
OLD_FILES+=usr/include/sys/vtoc.h
+5
View File
@@ -17,6 +17,11 @@ and/or ports.
has changed. An NFS server that exports any of these file systems will
need its clients to unmount and remount the exports.
20250916:
If SRCCONF is unset and a file named src.conf is present at
the top of the source tree, it will now be used instead of
/etc/src.conf.
20240419:
Clang, llvm, lld, lldb, compiler-rt, libc++, libunwind and openmp have
been upgraded to 18.1.6. It is important that you run `make delete-old`
+9 -9
View File
@@ -227,7 +227,7 @@ main(int argc, char *argv[])
* Case (1). Target is not a directory.
*/
if (argc > 1)
errx(1, "%s is not a directory", to.p_path);
errc(1, ENOTDIR, "%s", to.p_path);
/*
* Need to detect the case:
@@ -250,17 +250,17 @@ main(int argc, char *argv[])
type = FILE_TO_FILE;
if (have_trailing_slash && type == FILE_TO_FILE) {
if (r == -1) {
errx(1, "directory %s does not exist",
to.p_path);
} else
errx(1, "%s is not a directory", to.p_path);
if (r == -1)
errc(1, ENOENT, "%s", to.p_path);
else
errc(1, ENOTDIR, "%s", to.p_path);
}
} else
} else {
/*
* Case (2). Target is a directory.
*/
type = FILE_TO_DIR;
}
/*
* For DIR_TO_DNE, we could provide copy() with the to_stat we've
@@ -368,8 +368,8 @@ copy(char *argv[], enum op type, int fts_options, struct stat *root_stat)
base = (p == NULL) ? 0 :
(int)(p - curr->fts_path + 1);
if (!strcmp(&curr->fts_path[base],
".."))
if (strcmp(curr->fts_path + base, "..")
== 0)
base += 1;
} else
base = curr->fts_pathlen;
+4 -4
View File
@@ -74,7 +74,7 @@ hardlink_body()
echo "foo" >foo
atf_check cp -l foo bar
atf_check -o inline:"foo\n" cat bar
atf_check_equal "$(stat -f%d,%i foo)" "$(stat -f%d,%i bar)"
atf_check test foo -ef bar
}
atf_test_case hardlink_exists
@@ -84,7 +84,7 @@ hardlink_exists_body()
echo "bar" >bar
atf_check -s not-exit:0 -e match:exists cp -l foo bar
atf_check -o inline:"bar\n" cat bar
atf_check_not_equal "$(stat -f%d,%i foo)" "$(stat -f%d,%i bar)"
atf_check test ! foo -ef bar
}
atf_test_case hardlink_exists_force
@@ -94,7 +94,7 @@ hardlink_exists_force_body()
echo "bar" >bar
atf_check cp -fl foo bar
atf_check -o inline:"foo\n" cat bar
atf_check_equal "$(stat -f%d,%i foo)" "$(stat -f%d,%i bar)"
atf_check test foo -ef bar
}
atf_test_case matching_srctgt
@@ -247,7 +247,7 @@ file_is_sparse()
files_are_equal()
{
atf_check_not_equal "$(stat -f%d,%i "$1")" "$(stat -f%d,%i "$2")"
atf_check test ! "$1" -ef "$2"
atf_check cmp "$1" "$2"
}
+5 -2
View File
@@ -213,7 +213,10 @@ copy_file(const FTSENT *entp, int dne)
if (!use_copy_file_range) {
wcount = copy_fallback(from_fd, to_fd);
}
wtotal += wcount;
if (wcount >= 0)
wtotal += wcount;
else if (errno != EINTR)
break;
if (info) {
info = 0;
(void)fprintf(stderr,
@@ -221,7 +224,7 @@ copy_file(const FTSENT *entp, int dne)
entp->fts_path, to.p_path,
cp_pct(wtotal, fs->st_size));
}
} while (wcount > 0);
} while (wcount != 0);
if (wcount < 0) {
warn("%s", entp->fts_path);
rval = 1;
+4 -4
View File
@@ -31,7 +31,7 @@
.\"
.\" @(#)date.1 8.3 (Berkeley) 4/28/95
.\"
.Dd February 27, 2023
.Dd September 1, 2025
.Dt DATE 1
.Os
.Sh NAME
@@ -128,7 +128,7 @@ format.
Parsing is done using
.Xr strptime 3 .
.It Fl I Ns Op Ar FMT
Use
Use extended
.St -iso8601
output format.
.Ar FMT
@@ -151,9 +151,9 @@ is
.Cm minutes
or
.Cm seconds ) ,
the
the extended
.St -iso8601
format includes the timezone.
format includes the timezone offset.
.It Fl j
Do not try to set the date.
This allows you to use the
+1 -1
View File
@@ -28,7 +28,7 @@
atf_check_same_file()
{
atf_check_equal "$(stat -f %d,%i "$1")" "$(stat -f %d,%i "$2")"
atf_check test "$1" -ef "$2"
}
atf_check_symlink_to()
+7 -2
View File
@@ -579,6 +579,7 @@ waitcmdloop(struct job *job)
freejob(job);
else {
job->remembered = 0;
deljob(job);
if (job == bgjob)
bgjob = NULL;
}
@@ -603,7 +604,7 @@ waitcmdloop(struct job *job)
break;
}
}
} while (dowait(DOWAIT_BLOCK | DOWAIT_SIG, (struct job *)NULL) != -1);
} while (dowait(DOWAIT_BLOCK | DOWAIT_SIG, job) != -1);
sig = pendingsig_waitcmd;
pendingsig_waitcmd = 0;
@@ -1081,6 +1082,7 @@ waitforjob(struct job *jp, int *signaled)
#if JOBS
int propagate_int = jp->jobctl && jp->foreground;
#endif
int jobindex;
int status;
int st;
@@ -1088,8 +1090,11 @@ waitforjob(struct job *jp, int *signaled)
TRACE(("waitforjob(%%%td) called\n", jp - jobtab + 1));
while (jp->state == 0)
if (dowait(DOWAIT_BLOCK | (Tflag ? DOWAIT_SIG |
DOWAIT_SIG_TRAP : 0), jp) == -1)
DOWAIT_SIG_TRAP : 0), jp) == -1) {
jobindex = jp - jobtab;
dotrap();
jp = jobtab + jobindex;
}
#if JOBS
if (jp->jobctl) {
if (ttyfd >= 0 && tcsetpgrp(ttyfd, rootpid) < 0)
+1 -1
View File
@@ -75,7 +75,7 @@ extern char optval[NOPTS];
extern const char optletter[NSHORTOPTS];
#ifdef DEFINE_OPTIONS
char optval[NOPTS];
const char optletter[NSHORTOPTS] = "efIimnsxvVECabupTPh";
const char optletter[NSHORTOPTS] __nonstring = "efIimnsxvVECabupTPh";
static const unsigned char optname[] =
"\007errexit"
"\006noglob"
+4 -6
View File
@@ -33,7 +33,7 @@
.\"
.\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95
.\"
.Dd November 20, 2024
.Dd March 8, 2025
.Dt SH 1
.Os
.Sh NAME
@@ -240,11 +240,9 @@ If a shell function is executed and its exit status is explicitly
tested, all commands of the function are considered to be tested as
well.
.Pp
It is recommended to check for failures explicitly
instead of relying on
.Fl e
because it tends to behave in unexpected ways,
particularly in larger scripts.
Note that many commands return non-zero values to convey information other
than errors, which can cause unexpected program termination with
.Fl e .
.It Fl f Li noglob
Disable pathname expansion.
.It Fl h Li trackall
+1
View File
@@ -186,5 +186,6 @@ ${PACKAGE}FILES+= wait7.0
${PACKAGE}FILES+= wait8.0
${PACKAGE}FILES+= wait9.127
${PACKAGE}FILES+= wait10.0
${PACKAGE}FILES+= wait11.0
.include <bsd.test.mk>
+6
View File
@@ -0,0 +1,6 @@
sleep 3 | sleep 2 &
sleep 3 &
kill %1
wait %1
r=$?
[ "$r" -gt 128 ] && [ "$(kill -l "$r")" = TERM ]
+1
View File
@@ -19,6 +19,7 @@ ${PACKAGE}FILES+= bg10.0 bg10.0.stdout
${PACKAGE}FILES+= bg11.0
${PACKAGE}FILES+= bg12.0
${PACKAGE}FILES+= bg13.0
${PACKAGE}FILES+= bg14.0
${PACKAGE}FILES+= env1.0
${PACKAGE}FILES+= fork1.0
${PACKAGE}FILES+= fork2.0
+9
View File
@@ -0,0 +1,9 @@
T=`mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXXXX`
trap 'rm -rf "$T"' 0
cd "$T" || exit 3
mkfifo fifo1 || exit 3
set -T
trap "for i in 1 2 3 4; do sleep 1 & done" USR1
sleep 1 &
{ kill -USR1 "$$"; echo .; } >fifo1 &
(read dummy <fifo1)
+1 -1
View File
@@ -117,7 +117,7 @@ enum token {
#define TOKEN_TYPE(token) ((token) & 0xff00)
static const struct t_op {
char op_text[2];
char op_text[2] __nonstring;
short op_num;
} ops1[] = {
{"=", STREQ},
+99 -7
View File
@@ -18,7 +18,9 @@
.\" CDDL HEADER END
.\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
.\"
.Dd September 7, 2021
.\" $FreeBSD$
.\"
.Dd November 8, 2025
.Dt DTRACE 1
.Os
.Sh NAME
@@ -515,7 +517,18 @@ option is not specified,
.Nm
does not permit the compilation or enabling of a D program that contains
destructive actions.
.It Fl x Ar arg Op Ns = Ns value
.Pp
Set the
.Va security.bsd.allow_destructive_dtrace
.Xr loader 8
tunable
to
.Ql 0
to disallow the possibility of enabling destructive actions system-wide at any point at all.
Any attempts to enable destructive actions will cause
.Nm
to exit with a runtime error.
.It Fl x Ar arg Ns Op = Ns Ar value
Enable or modify a DTrace runtime option or D compiler option.
Boolean options are enabled by specifying their name.
Options with values are set by separating the option name and value with an
@@ -595,6 +608,52 @@ Same as the
flag.
.It Sy dynvarsize Ns = Ns Ar size
Size of the dynamic variable space.
.Sm off
.It Sy evaltime = Cm exec | preinit | postinit | main
.Sm on
Process create mode.
When using
.Fl c Ar cmd
to start a command,
.Nm
will first stop the newly started
.Ar cmd ,
evaluate the
.Xr d 7
program,
and then resume the
.Ar cmd .
The
.Cm evaltime
option controls the exact moment when this happens.
.Pp
The following table describes supported modes.
.Bl -column -offset indent "postinit" "D Program Evaluation Time"
.It Sy Mode Ta Sy D Program Evaluation Time
.It Cm exec Ta
Right at the first instruction of the command
.Ar cmd
execution.
.It Cm preinit Ta
Before
.Xr elf 5 Ap s
.Dq .init
sections.
.It Cm postinit Ta
After
.Xr elf 5 Ap s
.Dq .init
sections.
Default on
.Fx .
.It Cm main Ta
Before the first instruction of the
.Fn main
function.
.El
.Pp
Usually, there is no reason to change the default mode,
but it might be handy in situations such as shared library tracing.
.It Sy flowindent
Turn on flow indentation.
Same as the
@@ -777,6 +836,14 @@ command line to define a set of macro variables and so forth).
The additional arguments can be used in D programs specified using the
.Fl s
option or on the command line.
.Sh ENVIRONMENT
.Bl -tag -width 'DTRACE_DEBUG'
.It Ev DTRACE_DEBUG
When defined,
.Nm
will output debug log messages to
.Xr stderr 4 .
.El
.Sh FILES
.Bl -tag -width /boot/dtrace.dof -compact
.It Pa /boot/dtrace.dof
@@ -801,15 +868,40 @@ failed or that the specified request could not be satisfied.
.It 2
Invalid command line options or arguments were specified.
.El
.Sh HISTORY
The
.Nm
utility first appeared in
.Fx 7.1 .
.Sh DIAGNOSTICS
.Bl -diag
.It dtrace: could not enable tracing: Permission denied
This can happen when
.Nm
fails to enable destructive actions because
.Va security.bsd.allow_destructive_dtrace
is set to
.Ql 0
in
.Xr loader.conf 5 .
.El
.Sh SEE ALSO
.Xr cpp 1 ,
.Xr dtrace_audit 4 ,
.Xr dtrace_callout_execute 4 ,
.Xr dtrace_fbt 4 ,
.Xr dtrace_io 4 ,
.Xr dtrace_ip 4 ,
.Xr dtrace_lockstat 4 ,
.Xr dtrace_proc 4 ,
.Xr dtrace_sched 4 ,
.Xr dtrace_sctp 4 ,
.Xr dtrace_tcp 4 ,
.Xr dtrace_udp 4 ,
.Xr dtrace_udplite 4 ,
.Xr dtrace_vfs 4 ,
.Xr elf 5 ,
.Xr SDT 9
.Rs
.%T Solaris Dynamic Tracing Guide
.Re
.Sh HISTORY
The
.Nm
utility first appeared in
.Fx 7.1 .
@@ -38,9 +38,6 @@
*/
#include <pthread.h>
#ifdef illumos
#include <synch.h>
#endif
#include <stdio.h>
#include "barrier.h"
@@ -49,12 +46,7 @@ void
barrier_init(barrier_t *bar, int nthreads)
{
pthread_mutex_init(&bar->bar_lock, NULL);
#ifdef illumos
sema_init(&bar->bar_sem, 0, USYNC_THREAD, NULL);
#else
sem_init(&bar->bar_sem, 0, 0);
#endif
pthread_cond_init(&bar->bar_cv, NULL);
bar->bar_numin = 0;
bar->bar_nthr = nthreads;
}
@@ -65,26 +57,14 @@ barrier_wait(barrier_t *bar)
pthread_mutex_lock(&bar->bar_lock);
if (++bar->bar_numin < bar->bar_nthr) {
pthread_cond_wait(&bar->bar_cv, &bar->bar_lock);
pthread_mutex_unlock(&bar->bar_lock);
#ifdef illumos
sema_wait(&bar->bar_sem);
#else
sem_wait(&bar->bar_sem);
#endif
return (0);
} else {
int i;
/* reset for next use */
bar->bar_numin = 0;
for (i = 1; i < bar->bar_nthr; i++)
#ifdef illumos
sema_post(&bar->bar_sem);
#else
sem_post(&bar->bar_sem);
#endif
pthread_cond_broadcast(&bar->bar_cv);
pthread_mutex_unlock(&bar->bar_lock);
return (1);
@@ -33,12 +33,7 @@
* APIs for the barrier synchronization primitive.
*/
#ifdef illumos
#include <synch.h>
#else
#include <semaphore.h>
typedef sem_t sema_t;
#endif
#include <pthread.h>
#ifdef __cplusplus
extern "C" {
@@ -48,7 +43,7 @@ typedef struct barrier {
pthread_mutex_t bar_lock; /* protects bar_numin */
int bar_numin; /* current number of waiters */
sema_t bar_sem; /* where everyone waits */
pthread_cond_t bar_cv; /* where everyone waits */
int bar_nthr; /* # of waiters to trigger release */
} barrier_t;
+2 -2
View File
@@ -1,6 +1,6 @@
# License
Copyright (c) 2018-2024 Gavin D. Howard <gavin@gavinhoward.com>
Copyright (c) 2018-2025 Gavin D. Howard <gavin@gavinhoward.com>
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -60,7 +60,7 @@ The files `src/rand.c` and `include/rand.h` are under the following copyrights
and license:
Copyright (c) 2014-2017 Melissa O'Neill and PCG Project contributors<br>
Copyright (c) 2018-2024 Gavin D. Howard <gavin@gavinhoward.com>
Copyright (c) 2018-2025 Gavin D. Howard <gavin@gavinhoward.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
+80
View File
@@ -0,0 +1,80 @@
# Maintenance Terms
> Last Updated: 27 June 2025
The code, text, and other materials in this repository are provided as-is under
the terms of the repository's [`LICENSE.md`][0] file, as a gift to the commons
and the common good. In providing this software as-is, its author(s) admit no
further obligations from anyone using the software for any reason, particularly
with respect to:
* Releases,
* Response time,
* Change review and integration,
* Disclosure schedules,
* Discretionary, proprietary or otherwise secretive communications, and
* Any other non-contractual obligations or conventions, regardless of their
presumed urgency or severity.
Should anyone wish to make a contract with me (Gavin Howard) to ensure that work
he or she deems critical gets done, the terms are as follows:
* Compute time will be charged at \$25/hr.
* My time will be charged at \$100/hr.
* All issues deemed critical by either me or the requester, that also change the
source code (anything in `gen`, `include`, or `src`) will require at least two
weeks of fuzzing without error.
* If errors are found, those hours will still be charged on top of the final
two weeks.
* All changes will require running the [release script][2] on Linux (GCC), Linux
(Clang), FreeBSD, OpenBSD, macOS, Windows.
* Any hours spent on bugs or code that have been, or are suspected to have been,
generated by "AI" will be charged double rates.
Compute time includes, but is not limited to:
* Fuzzing.
* Running my [release script][2].
* Running tests and my [release script][2] on macOS.
My time includes, but is not limited to:
* Code review.
* Reading bug reports.
* Design.
* Coding.
* Any compute time that interferes with my ability to do any other work:
* Fuzzing makes my computer unusable, so fuzzing for the 8-12 hours of the
day that I could be working will be charged at \$100/hr.
* Same with running my [release script][2] because I run two instances on my
machine and two in VMs at the same time.
* Running my [release script][2] or any other compute time on Windows
because Windows blocks me from doing my main work on Linux.
* Any other instances of blocking compute time.
All amounts will be billed by, and paid to, [Yzena, LLC][2]. Invoices will be
provided, including line items for what each hour was spent on.
It is suggested that the following amounts be budgeted:
* At least \$3000 for a non-critical issue or change.
The release script takes about 10 hours, and I would need to run it once on
Linux (and others at the same time) and once on Windows, which is 20 hours.
Most of that won't be at the \$100/hr rate, but some probably will be. Then
an extra \$1000 for other work.
* At least \$15,000 for a critical issue or change.
The \$3000 above is the start, which leaves \$12,000. Fuzzing is expected to
cost \$11,400 (6 days a week, 8 hours a day, at \$100, the rest at \$25), and
rounded up to \$12,000 for good measure.
---
This document is inspired by [Mike Hoye's Maintenance Terms][1].
[0]: LICENSE.md
[1]: https://github.com/mhoye/maintenance-terms
[2]: scripts/release.sh
[3]: https://yzena.com/
+21 -262
View File
@@ -1,7 +1,7 @@
#
# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2018-2024 Gavin D. Howard and contributors.
# Copyright (c) 2018-2025 Gavin D. Howard and contributors.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -38,6 +38,8 @@ GENDIR = $(ROOTDIR)/gen
BUILDDIR = %%BUILDDIR%%
VERSION = %%VERSION%%
SRC = %%SRC%%
OBJ = %%OBJ%%
GCDA = %%GCDA%%
@@ -99,17 +101,16 @@ BC_FUZZER_C = $(BIN)/$(BC)_fuzzer_C
DC_FUZZER = $(BIN)/$(DC)_fuzzer_c
DC_FUZZER_C = $(BIN)/$(DC)_fuzzer_C
BC_TEST_OUTPUTS = tests/bc_outputs
BC_FUZZ_OUTPUTS = tests/fuzzing/bc_outputs1 tests/fuzzing/bc_outputs2 tests/fuzzing/bc_outputs3
DC_TEST_OUTPUTS = tests/dc_outputs
DC_FUZZ_OUTPUTS = tests/fuzzing/dc_outputs
LIB = libbcl
LIB_NAME = $(LIB).a
LIBBC = $(BIN)/$(LIB_NAME)
BCL = bcl
BCL_TEST = $(BIN)/$(BCL)
BCL_TEST_C = $(TESTSDIR)/$(BCL).c
GENERATE_TESTS = %%GENERATE_TESTS%%
PROBLEMATIC_TESTS = %%PROBLEMATIC_TESTS%%
MANUALS = manuals
BC_MANPAGE_NAME = $(EXEC_PREFIX)$(BC)$(EXEC_SUFFIX).1
@@ -152,11 +153,11 @@ BC_ENABLE_EXTRA_MATH = %%EXTRA_MATH%%
BC_ENABLE_NLS = %%NLS%%
BC_EXCLUDE_EXTRA_MATH = %%EXCLUDE_EXTRA_MATH%%
BC_ENABLE_AFL = %%FUZZ%%
BC_ENABLE_OSSFUZZ = %%OSSFUZZ%%
BC_ENABLE_MEMCHECK = %%MEMCHECK%%
BC_ENABLE_AFL = 0
BC_ENABLE_OSSFUZZ = 0
BC_ENABLE_MEMCHECK = 0
LIB_FUZZING_ENGINE = %%LIB_FUZZING_ENGINE%%
LIB_FUZZING_ENGINE = 0
BC_DEFAULT_BANNER = %%BC_DEFAULT_BANNER%%
BC_DEFAULT_SIGINT_RESET = %%BC_DEFAULT_SIGINT_RESET%%
@@ -189,10 +190,6 @@ KARATSUBA = $(SCRIPTSDIR)/karatsuba.py
LOCALE_INSTALL = $(SCRIPTSDIR)/locale_install.sh
LOCALE_UNINSTALL = $(SCRIPTSDIR)/locale_uninstall.sh
VALGRIND_ARGS = --error-exitcode=100 --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all
TEST_STARS = ***********************************************************************
BC_NUM_KARATSUBA_LEN = %%KARATSUBA_LEN%%
BC_DEFS0 = -DBC_DEFAULT_BANNER=$(BC_DEFAULT_BANNER)
@@ -218,7 +215,7 @@ CPPFLAGS6 = $(CPPFLAGS5) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS)
CPPFLAGS7 = $(CPPFLAGS6) -D$(BC_ENABLE_EXTRA_MATH_NAME)=$(BC_ENABLE_EXTRA_MATH)
CPPFLAGS8 = $(CPPFLAGS7) -DBC_ENABLE_HISTORY=$(BC_ENABLE_HISTORY) -DBC_ENABLE_LIBRARY=$(BC_ENABLE_LIBRARY)
CPPFLAGS9 = $(CPPFLAGS8) -DBC_ENABLE_MEMCHECK=$(BC_ENABLE_MEMCHECK) -DBC_ENABLE_AFL=$(BC_ENABLE_AFL)
CPPFLAGS = $(CPPFLAGS9) -DBC_ENABLE_OSSFUZZ=$(BC_ENABLE_OSSFUZZ)
CPPFLAGS = -DVERSION=$(VERSION) $(CPPFLAGS9) -DBC_ENABLE_OSSFUZZ=$(BC_ENABLE_OSSFUZZ)
CFLAGS = $(CPPFLAGS) $(BC_DEFS) $(DC_DEFS) %%CPPFLAGS%% %%CFLAGS%%
LDFLAGS = %%LDFLAGS%%
@@ -293,236 +290,10 @@ help:
@printf ' check alias for `make test`\n'
@printf ' clean removes all build files\n'
@printf ' clean_config removes all build files as well as the generated Makefile\n'
@printf ' clean_tests removes all build files, the generated Makefile,\n'
@printf ' and generated tests\n'
@printf ' install installs binaries to "%s%s"\n' "$(DESTDIR)" "$(BINDIR)"
@printf ' and (if enabled) manpages to "%s%s"\n' "$(DESTDIR)" "$(MAN1DIR)"
@printf ' karatsuba runs the karatsuba script (requires Python 3)\n'
@printf ' karatsuba_test runs the karatsuba script while running tests\n'
@printf ' (requires Python 3)\n'
@printf ' uninstall uninstalls binaries from "%s%s"\n' "$(DESTDIR)" "$(BINDIR)"
@printf ' and (if enabled) manpages from "%s%s"\n' "$(DESTDIR)" "$(MAN1DIR)"
@printf ' test runs the test suite\n'
@printf ' test_bc runs the bc test suite, if bc has been built\n'
@printf ' test_dc runs the dc test suite, if dc has been built\n'
@printf ' time_test runs the test suite, displaying times for some things\n'
@printf ' time_test_bc runs the bc test suite, displaying times for some things\n'
@printf ' time_test_dc runs the dc test suite, displaying times for some things\n'
@printf ' timeconst runs the test on the Linux timeconst.bc script,\n'
@printf ' if it exists and bc has been built\n'
run_all_tests: bc_all_tests timeconst_all_tests dc_all_tests
run_all_tests_np: bc_all_tests_np timeconst_all_tests dc_all_tests_np
bc_all_tests:
%%BC_ALL_TESTS%%
bc_all_tests_np:
%%BC_ALL_TESTS_NP%%
timeconst_all_tests:
%%TIMECONST_ALL_TESTS%%
dc_all_tests:
%%DC_ALL_TESTS%%
dc_all_tests_np:
%%DC_ALL_TESTS_NP%%
history_all_tests:
%%HISTORY_TESTS%%
check: test
test: %%TESTS%%
test_bc: test_bc_header test_bc_tests test_bc_scripts test_bc_errors test_bc_stdin test_bc_read test_bc_other
@printf '\nAll bc tests passed.\n\n$(TEST_STARS)\n'
test_bc_tests:%%BC_TESTS%%
test_bc_scripts:%%BC_SCRIPT_TESTS%%
test_bc_stdin:
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/stdin.sh bc %%BC_TEST_EXEC%%
test_bc_read:
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/read.sh bc %%BC_TEST_EXEC%%
test_bc_errors: test_bc_error_lines%%BC_ERROR_TESTS%%
test_bc_error_lines:
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/errors.sh bc %%BC_TEST_EXEC%%
test_bc_other:
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/other.sh bc $(BC_ENABLE_EXTRA_MATH) %%BC_TEST_EXEC%%
test_bc_header:
@printf '$(TEST_STARS)\n\nRunning bc tests...\n\n'
test_dc: test_dc_header test_dc_tests test_dc_scripts test_dc_errors test_dc_stdin test_dc_read test_dc_other
@printf '\nAll dc tests passed.\n\n$(TEST_STARS)\n'
test_dc_tests:%%DC_TESTS%%
test_dc_scripts:%%DC_SCRIPT_TESTS%%
test_dc_stdin:
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/stdin.sh dc %%DC_TEST_EXEC%%
test_dc_read:
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/read.sh dc %%DC_TEST_EXEC%%
test_dc_errors: test_dc_error_lines%%DC_ERROR_TESTS%%
test_dc_error_lines:
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/errors.sh dc %%DC_TEST_EXEC%%
test_dc_other:
@export BC_TEST_OUTPUT_DIR="$(BUILDDIR)/tests"; sh $(TESTSDIR)/other.sh dc $(BC_ENABLE_EXTRA_MATH) %%DC_TEST_EXEC%%
test_dc_header:
@printf '$(TEST_STARS)\n\nRunning dc tests...\n\n'
timeconst:
%%TIMECONST%%
test_history: test_history_header test_bc_history test_dc_history
@printf '\nAll history tests passed.\n\n$(TEST_STARS)\n'
test_bc_history:%%BC_HISTORY_TEST_PREREQS%%
test_bc_history_all: test_bc_history0 test_bc_history1 test_bc_history2 test_bc_history3 test_bc_history4 test_bc_history5 test_bc_history6 test_bc_history7 test_bc_history8 test_bc_history9 test_bc_history10 test_bc_history11 test_bc_history12 test_bc_history13 test_bc_history14 test_bc_history15 test_bc_history16 test_bc_history17 test_bc_history18 test_bc_history19 test_bc_history20 test_bc_history21
test_bc_history_skip:
@printf 'No bc history tests to run\n'
test_bc_history0:
@sh $(TESTSDIR)/history.sh bc 0 %%BC_TEST_EXEC%%
test_bc_history1:
@sh $(TESTSDIR)/history.sh bc 1 %%BC_TEST_EXEC%%
test_bc_history2:
@sh $(TESTSDIR)/history.sh bc 2 %%BC_TEST_EXEC%%
test_bc_history3:
@sh $(TESTSDIR)/history.sh bc 3 %%BC_TEST_EXEC%%
test_bc_history4:
@sh $(TESTSDIR)/history.sh bc 4 %%BC_TEST_EXEC%%
test_bc_history5:
@sh $(TESTSDIR)/history.sh bc 5 %%BC_TEST_EXEC%%
test_bc_history6:
@sh $(TESTSDIR)/history.sh bc 6 %%BC_TEST_EXEC%%
test_bc_history7:
@sh $(TESTSDIR)/history.sh bc 7 %%BC_TEST_EXEC%%
test_bc_history8:
@sh $(TESTSDIR)/history.sh bc 8 %%BC_TEST_EXEC%%
test_bc_history9:
@sh $(TESTSDIR)/history.sh bc 9 %%BC_TEST_EXEC%%
test_bc_history10:
@sh $(TESTSDIR)/history.sh bc 10 %%BC_TEST_EXEC%%
test_bc_history11:
@sh $(TESTSDIR)/history.sh bc 11 %%BC_TEST_EXEC%%
test_bc_history12:
@sh $(TESTSDIR)/history.sh bc 12 %%BC_TEST_EXEC%%
test_bc_history13:
@sh $(TESTSDIR)/history.sh bc 13 %%BC_TEST_EXEC%%
test_bc_history14:
@sh $(TESTSDIR)/history.sh bc 14 %%BC_TEST_EXEC%%
test_bc_history15:
@sh $(TESTSDIR)/history.sh bc 15 %%BC_TEST_EXEC%%
test_bc_history16:
@sh $(TESTSDIR)/history.sh bc 16 %%BC_TEST_EXEC%%
test_bc_history17:
@sh $(TESTSDIR)/history.sh bc 17 %%BC_TEST_EXEC%%
test_bc_history18:
@sh $(TESTSDIR)/history.sh bc 18 %%BC_TEST_EXEC%%
test_bc_history19:
@sh $(TESTSDIR)/history.sh bc 19 %%BC_TEST_EXEC%%
test_bc_history20:
@sh $(TESTSDIR)/history.sh bc 20 %%BC_TEST_EXEC%%
test_bc_history21:
@sh $(TESTSDIR)/history.sh bc 21 %%BC_TEST_EXEC%%
test_dc_history:%%DC_HISTORY_TEST_PREREQS%%
test_dc_history_all: test_dc_history0 test_dc_history1 test_dc_history2 test_dc_history3 test_dc_history4 test_dc_history5 test_dc_history6 test_dc_history7 test_dc_history8 test_dc_history9 test_dc_history10
test_dc_history_skip:
@printf 'No dc history tests to run\n'
test_dc_history0:
@sh $(TESTSDIR)/history.sh dc 0 %%DC_TEST_EXEC%%
test_dc_history1:
@sh $(TESTSDIR)/history.sh dc 1 %%DC_TEST_EXEC%%
test_dc_history2:
@sh $(TESTSDIR)/history.sh dc 2 %%DC_TEST_EXEC%%
test_dc_history3:
@sh $(TESTSDIR)/history.sh dc 3 %%DC_TEST_EXEC%%
test_dc_history4:
@sh $(TESTSDIR)/history.sh dc 4 %%DC_TEST_EXEC%%
test_dc_history5:
@sh $(TESTSDIR)/history.sh dc 5 %%DC_TEST_EXEC%%
test_dc_history6:
@sh $(TESTSDIR)/history.sh dc 6 %%DC_TEST_EXEC%%
test_dc_history7:
@sh $(TESTSDIR)/history.sh dc 7 %%DC_TEST_EXEC%%
test_dc_history8:
@sh $(TESTSDIR)/history.sh dc 8 %%DC_TEST_EXEC%%
test_dc_history9:
@sh $(TESTSDIR)/history.sh dc 9 %%DC_TEST_EXEC%%
test_dc_history10:
@sh $(TESTSDIR)/history.sh dc 10 %%DC_TEST_EXEC%%
test_history_header:
@printf '$(TEST_STARS)\n\nRunning history tests...\n\n'
library_test: $(LIBBC)
$(CC) $(CFLAGS) -lpthread $(BCL_TEST_C) $(LIBBC) -o $(BCL_TEST)
test_library: library_test
%%BCL_TEST_EXEC%%
karatsuba:
%%KARATSUBA%%
karatsuba_test:
%%KARATSUBA_TEST%%
coverage_output:
%%COVERAGE_OUTPUT%%
coverage:%%COVERAGE_PREREQS%%
manpages:
$(MANPAGE) bc
@@ -559,37 +330,25 @@ clean_config: clean clean_benchmarks
@$(RM) -f compile_commands.json
@$(RM) -f $(BCL_PC)
clean_coverage:
@printf 'Cleaning coverage files...\n'
@$(RM) -f *.gcov
@$(RM) -f *.html *.css
@$(RM) -f *.gcda *.gcno
@$(RM) -f *.profraw
@$(RM) -f $(GCDA) $(GCNO)
@$(RM) -f $(BC_GCDA) $(BC_GCNO)
@$(RM) -f $(DC_GCDA) $(DC_GCNO)
@$(RM) -f $(HISTORY_GCDA) $(HISTORY_GCNO)
@$(RM) -f $(RAND_GCDA) $(RAND_GCNO)
@$(RM) -f $(BC_LIB_GCDA) $(BC_LIB_GCNO)
@$(RM) -f $(BC_LIB2_GCDA) $(BC_LIB2_GCNO)
@$(RM) -f $(BC_HELP_GCDA) $(BC_HELP_GCNO)
@$(RM) -f $(DC_HELP_GCDA) $(DC_HELP_GCNO)
test:
@if [ $(BC_ENABLED) -ne 0 ]; then $(TESTSDIR)/all.sh -n bc $(BC_ENABLE_EXTRA_MATH) 1 $(GENERATE_TESTS) $(PROBLEMATIC_TESTS) $(BC_EXEC); fi
@if [ $(DC_ENABLED) -ne 0 ]; then $(TESTSDIR)/all.sh -n dc $(BC_ENABLE_EXTRA_MATH) 1 $(GENERATE_TESTS) $(PROBLEMATIC_TESTS) $(DC_EXEC); fi
clean_tests: clean clean_config clean_coverage
clean_tests: clean clean_config
@printf 'Cleaning test files...\n'
@$(RM) -fr $(BC_TEST_OUTPUTS) $(DC_TEST_OUTPUTS)
@$(RM) -fr $(BC_FUZZ_OUTPUTS) $(DC_FUZZ_OUTPUTS)
@$(RM) -f $(TESTSDIR)/bc/parse.txt $(TESTSDIR)/bc/parse_results.txt
@$(RM) -f $(TESTSDIR)/bc/print.txt $(TESTSDIR)/bc/print_results.txt
@$(RM) -f $(TESTSDIR)/bc/parse_*.txt $(TESTSDIR)/bc/parse_*_results.txt
@$(RM) -f $(TESTSDIR)/bc/print_*.txt $(TESTSDIR)/bc/print_*_results.txt
@$(RM) -f $(TESTSDIR)/bc/bessel.txt $(TESTSDIR)/bc/bessel_results.txt
@$(RM) -f $(TESTSDIR)/bc/strings2.txt $(TESTSDIR)/bc/strings2_results.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/bessel.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/parse.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/print.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/add.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/divide.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/multiply.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/subtract.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/add_*.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/divide_*.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/multiply_*.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/subtract_*.txt
@$(RM) -f $(TESTSDIR)/bc/scripts/strings2.txt
@$(RM) -f $(TESTSDIR)/dc/scripts/prime.txt
@$(RM) -f .log_*.txt
+23
View File
@@ -1,5 +1,27 @@
# News
## 7.1.0
This is an ***UNTESTED*** release. If you would like testing, see the
[maintenance terms][23].
This 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.
It also has a performance increase in the `band()` function and others in the
math library.
## 7.0.3
This is a production release that fixes build warnings on the musl libc.
Other users do ***NOT*** need to upgrade.
## 7.0.2
This is a production release that fixes `Ctrl+d` on FreeBSD and Linux when using
@@ -1588,3 +1610,4 @@ not thoroughly tested.
[20]: https://github.com/apjanke/ronn-ng
[21]: https://pandoc.org/
[22]: ./scripts/locale_uninstall.sh
[23]: ./MAINTENANCE-TERMS.md
+1 -1
View File
@@ -1,6 +1,6 @@
# Notice
Copyright 2018-2024 Gavin D. Howard and contributors.
Copyright 2018-2025 Gavin D. Howard and contributors.
## Contributors
+17 -4
View File
@@ -1,9 +1,7 @@
# `bc`
***WARNING: New user registration for <https://git.gavinhoward.com/> is disabled
because of spam. If you need to report a bug with `bc`, email gavin at this site
minus the `git.` part for an account, and I will create one for you. Or you can
report an issue at [GitHub][29].***
***WARNING: This project has moved back to GitHub temporarily; self-hosted Git
forges are not working for me, so I am trying to replace them.***
***WARNING: This project has moved to [https://git.gavinhoward.com/][20] for
[these reasons][21], though GitHub will remain a mirror.***
@@ -282,6 +280,12 @@ The easiest way to run this script is with `make karatsuba`.
If desired, maintainers can also skip running this script because there is a
sane default for the Karatsuba number.
##### `timeconst.bc`
The test suite will print a warning in normal usage. The warning is about a
missing `timeconst.bc`. This file [comes from][37] the [Linux kernel][38], which
has an incompatible license. The warning can be ignored.
## Status
This `bc` is robust.
@@ -432,6 +436,8 @@ Other projects based on this bc are:
* [macOS `bc`][35]. Any bugs in that `bc` should be reported to me, but do
expect bugs because the version is old.
* [Android Open Source `bc`][32]. Any bugs in that `bc` can be reported here.
* [A Fedora package][36]. If this package does not have any patches, you can
report bugs to me.
This is a non-comprehensive list of Linux distros that use this `bc` as the
system `bc`:
@@ -469,12 +475,16 @@ Files:
.gitignore The git ignore file (maintainer use only).
.gitattributes The git attributes file (maintainer use only).
bcl.pc.in A template pkg-config file for bcl.
build.gaml The GAML file with options for building under Rig.
build.pkg.rig The Rig build package file.
build.rig The Rig build script.
configure A symlink to configure.sh to make packaging easier.
configure.sh The configure script.
LICENSE.md A Markdown form of the BSD 2-clause License.
Makefile.in The Makefile template.
NEWS.md The changelog.
NOTICE.md List of contributors and copyright owners.
VERSION.txt A file containing the version.
Folders:
@@ -516,3 +526,6 @@ Folders:
[33]: https://github.com/gentoo/gentoo/blob/master/app-alternatives/bc/bc-0.ebuild#L8
[34]: https://www.linuxfromscratch.org/lfs/view/stable/chapter08/bc.html
[35]: https://github.com/apple-oss-distributions/bc/tree/main/bc
[36]: https://copr.fedorainfracloud.org/coprs/tkbcopr/bc-gh/
[37]: https://github.com/torvalds/linux/blob/master/kernel/time/timeconst.bc
[38]: https://github.com/torvalds/linux
+1
View File
@@ -0,0 +1 @@
7.1.0
+402
View File
@@ -0,0 +1,402 @@
/*
* *****************************************************************************
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *****************************************************************************
*
* The build options file.
*
*/
project: @com.gavinhoward.bc
language: @C11
version: {
min: @24.04.05
}
mode: {
language: @iterative
stampers: @metadata
dependencies: @dynamic
}
default_target: @all
presets: {
debug: {
debug: true
optimization: "0"
memcheck: true
devtools: true
strip: false
}
release: {
optimization: "3"
lto: true
}
// This is the predefined build for BSDs.
bsd: {
optimization: "3"
history: @editline
generated_tests: false
install_manpages: false
install_locales: @system
strip: true
bc_default_banner: false
bc_default_sigint_reset: true
dc_default_sigint_reset: true
bc_default_tty_mode: true
dc_default_tty_mode: false
bc_default_prompt: @off
dc_default_prompt: @off
bc_default_expr_exit: true
dc_default_expr_exit: true
bc_default_digit_clamp: false
dc_default_digit_clamp: false
}
// This is the predefined build to match the GNU bc/dc.
gnu: {
optimization: "3"
generated_tests: false
install_manpages: true
install_locales: @system
strip: true
bc_default_banner: true
bc_default_sigint_reset: true
dc_default_sigint_reset: false
bc_default_tty_mode: true
dc_default_tty_mode: false
bc_default_prompt: @tty_mode
dc_default_prompt: @tty_mode
bc_default_expr_exit: true
dc_default_expr_exit: true
bc_default_digit_clamp: false
dc_default_digit_clamp: false
}
// This is the preferred release build of the author, Gavin D. Howard.
gdh: {
optimization: "3"
install_manpages: true
install_locales: @none
bc/default_banner: true
bc/default_sigint_reset: true
dc/default_sigint_reset: true
bc/default_tty_mode: true
dc/default_tty_mode: true
bc/default_prompt: @tty_mode
dc/default_prompt: @tty_mode
bc/default_expr_exit: false
dc/default_expr_exit: false
bc/default_digit_clamp: true
dc/default_digit_clamp: true
}
// This is the preferred debug build of the author, Gavin D. Howard.
dbg: {
optimization: "0"
debug: true
strip: false
install_manpages: true
install_locales: @system
bc/default_banner: true
bc/default_sigint_reset: true
dc/default_sigint_reset: true
bc/default_tty_mode: true
dc/default_tty_mode: true
bc/default_prompt: @tty_mode
dc/default_prompt: @tty_mode
bc/default_expr_exit: false
dc/default_expr_exit: false
bc/default_digit_clamp: true
dc/default_digit_clamp: true
}
}
default_development: @debug
default_release: @release
options: {
build_mode: {
type: @option
options: [
@both
@bc
@dc
@library
]
default: @both
desc: "Which of the executables or library to build."
}
extra_math: {
type: @bool
default: true
desc: "Enable the extra math extensions."
}
history: {
type: @option
options: [
@none
@builtin
@editline
@readline
]
default: @builtin
desc: "Which history implementation should be used, if any."
}
locales: {
type: @option
options: [
@none
@system
@all
]
default: @system
desc: "Whether to disable locales, use just the system ones, or use all (for building a package)."
}
bc/default_banner: {
type: @bool
default: false
desc: "Whether to display the bc version banner by default when in interactive mode."
}
bc/default_sigint_reset: {
type: @bool
default: true
desc: "Whether SIGINT will reset bc by default, instead of exiting, when in interactive mode."
}
dc/default_sigint_reset: {
type: @bool
default: true
desc: "Whether SIGINT will reset dc by default, instead of exiting, when in interactive mode."
}
bc/default_tty_mode: {
type: @bool
default: true
desc: "Whether TTY mode for bc should be on by default when available."
}
dc/default_tty_mode: {
type: @bool
default: false
desc: "Whether TTY mode for dc should be on by default when available."
}
bc/default_prompt: {
type: @option
options: [
@off
@tty_mode
@on
]
default: @tty_mode
desc: "Whether the prompt for bc should be on by default in TTY mode. This defaults to match TTY mode."
}
dc/default_prompt: {
type: @option
options: [
@off
@tty_mode
@on
]
default: @tty_mode
desc: "Whether the prompt for dc should be on by default in TTY mode. This defaults to match TTY mode."
}
bc/default_expr_exit: {
type: @bool
default: true
desc: "Whether to exit bc by default if an expression or expression file is given with the -e or -f options."
}
dc/default_expr_exit: {
type: @bool
default: true
desc: "Whether to exit dc by default if an expression or expression file is given with the -e or -f options."
}
bc/default_digit_clamp: {
type: @bool
default: false
desc: "Whether to have bc, by default, clamp digits that are greater than or equal to the current ibase when parsing numbers."
}
dc/default_digit_clamp: {
type: @bool
default: false
desc: "Whether to have dc, by default, clamp digits that are greater than or equal to the current ibase when parsing numbers."
}
karatsuba_len: {
type: @num
default: 32
desc: "Set the Karatsuba length (default is 32). Must be a number and greater than or equal to 16."
}
execprefix: {
type: @string
default: ""
desc: "The prefix to prepend to the executable names, to prevent collisions."
}
execsuffix: {
type: @string
default: ""
desc: "The suffix to append to the executable names, to prevent collisions."
}
debug: {
type: @bool
default: false
desc: "Enable debug info."
}
optimization: {
type: @string
default: "0"
desc: "The optimization level for the C compiler."
}
lto: {
type: @bool
default: false
desc: "Build with link-time optimization, if available."
}
strip: {
type: @bool
default: true
desc: "Strip any binaries."
}
strict: {
type: @bool
default: true
desc: "Build with strict compiler options."
}
force: {
type: @bool
default: false
desc: "Force options that don't work. THIS IS FOR DEV ONLY!"
}
memcheck: {
type: @bool
default: false
desc: "Enable memcheck mode, to check for memory leaks."
}
valgrind: {
type: @bool
default: false
desc: "Enable Valgrind mode, to check for memory bugs."
}
afl: {
type: @bool
default: false
desc: "Enable AFL++ mode."
}
ossfuzz: {
type: @bool
default: false
desc: "Enable OSSFUZZ mode."
}
generated_tests: {
type: @bool
default: true
desc: "Enable tests generated from a GNU bc-compatible program."
}
problematic_tests: {
type: @bool
default: true
desc: "Enable tests that may be problematic."
}
coverage: {
type: @bool
default: false
desc: "Enable code coverage (only works on GCC)."
}
install_manpages: {
type: @bool
default: true
desc: "Whether to install manpages or not."
}
cflags: {
type: @list
default: []
desc: "The command-line flags for the C compiler."
}
ldflags: {
type: @list
default: []
desc: "The command-line flags for the C linker."
}
destdir: {
type: @path
default: ""
desc: "The equivalent of $DESTDIR in other build systems."
}
prefix: {
type: @path
default: "/usr/local"
desc: "The default prefix to install everything into."
}
bindir: {
type: @path
default: ""
desc: "The directory to install executables into. Defaults to \"$prefix/bin\"."
}
libdir: {
type: @path
default: ""
desc: "The directory to install libraries into. Defaults to \"$prefix/lib\"."
}
includedir: {
type: @path
default: ""
desc: "The location to install headers in. Defaults to \"$prefix/include\"."
}
nlspath: {
type: @path
default: "/usr/share/locale/%L/%N"
desc: "The location to install locales."
}
pc_path: {
type: @path
default: ""
desc: "The location to pkg-config files to. Defaults to the output of `pkg-config --variable=pc_path pkg-config`."
}
datarootdir: {
type: @path
default: ""
desc: "The root directory for data files. Defaults to `$prefix/share`."
}
datadir: {
type: @path
default: ""
desc: "The directory for data files. Defaults to `$datarootdir`."
}
mandir: {
type: @path
default: ""
desc: "The root directory for manpages. Defaults to `$datadir/man`."
}
man1dir: {
type: @path
default: ""
desc: "The directory for manpages in section 1. Defaults to `$mandir/man1`."
}
man3dir: {
type: @path
default: ""
desc: "The directory for manpages in section 3. Defaults to `$mandir/man3`."
}
}
File diff suppressed because it is too large. Load diff
+575
View File
@@ -0,0 +1,575 @@
/*
* *****************************************************************************
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *****************************************************************************
*
* The build script file.
*
*/
if OS == "Windows" && bool(config["lto"])
{
error("Link-time optimization is not supported on Windows");
}
if LIBRARY_ENABLED == "0"
{
if OS != "Windows" && NLS_ENABLED != "0"
{
io.eprint("Testing NLS...\n");
clang_flags: []str =
if CC contains "clang"
{
@[ "-Wno_unreachable-code" ];
};
flags: []str = clang_flags +~ @[
DEFOPT +~ "BC_ENABLE_NLS=1",
DEFOPT +~ "BC_ENABLED=" +~ BC_ENABLED,
DEFOPT +~ "DC_ENABLED=" +~ DC_ENABLED,
DEFOPT +~ "BC_ENABLE_HISTORY=0",
DEFOPT +~ "BC_ENABLE_LIBRARY=0",
DEFOPT +~ "BC_ENABLE_AFL=0",
DEFOPT +~ "BC_ENABLE_EXTRA_MATH=" +~ EXTRA_MATH_ENABLED,
DEFOPT +~ "BC_ENABLE_OSSFUZZ=0",
DEFOPT +~ "_POSIX_C_SOURCE=200809L",
DEFOPT +~ "_XOPEN_SOURCE=700",
INCOPT,
];
res := $ $CC %(flags) -c @(path.join(src_dir, "src/vm.c")) -E;
if res.exitcode != 0
{
if FORCE
{
io.eprint("Forcing NLS...\n");
}
else
{
error("NLS does not work\n");
}
}
else
{
if path.isfile("vm.o")
{
path.rm("vm.o");
}
io.eprint("NLS works.\n\n");
io.eprint("Testing gencat...\n");
res2 := $ gencat ./en_US.cat
@(path.join(src_dir, "locales/en_US.msg"));
if res2.exitcode != 0
{
if FORCE
{
io.eprint("Forcing NLS...\n");
}
else
{
error("gencat does not work\n");
}
}
else
{
io.eprint("gencat works.\n\n");
if platform != host
{
error("Cross compiles will not work!\n\n");
}
}
}
}
if OS != "Windows" && sym(config["history"]) != @none
{
io.eprint("Testing history...\n");
flags: []str = @[
DEFOPT +~ "BC_ENABLE_HISTORY=1",
DEFOPT +~ "BC_ENABLED=" +~ BC_ENABLED,
DEFOPT +~ "DC_ENABLED=" +~ DC_ENABLED,
DEFOPT +~ "BC_ENABLE_NLS=" +~ NLS_ENABLED,
DEFOPT +~ "BC_ENABLE_LIBRARY=0",
DEFOPT +~ "BC_ENABLE_AFL=0",
DEFOPT +~ "BC_ENABLE_EDITLINE=" +~ EDITLINE_ENABLED,
DEFOPT +~ "BC_ENABLE_READLINE=" +~ READLINE_ENABLED,
DEFOPT +~ "BC_ENABLE_EXTRA_MATH=" +~ EXTRA_MATH_ENABLED,
DEFOPT +~ "BC_ENABLE_OSSFUZZ=0",
DEFOPT +~ "_POSIX_C_SOURCE=200809L",
DEFOPT +~ "_XOPEN_SOURCE=700",
INCOPT,
];
res := $ $CC %(flags) -c @(path.join(src_dir, "src/history.c")) -E;
if res.exitcode != 0
{
if FORCE
{
io.eprint("Forcing history...\n");
}
else
{
error("History does not work\n");
}
}
else
{
if path.isfile("history.o")
{
path.rm("history.o");
}
io.eprint("History works.\n\n");
}
}
}
freebsd_flags: []str =
if OS != "FreeBSD"
{
@[ DEFOPT +~ "_POSIX_C_SOURCE=200809L", DEFOPT +~ "_XOPEN_SOURCE=700" ];
};
macos: bool = (OS == "Darwin");
macos_flags: []str =
if macos
{
@[ DEFOPT +~ "_DARWIN_C_SOURCE" ];
};
openbsd_flags: []str =
if OS == "OpenBSD"
{
if READLINE_ENABLED != "0"
{
error("Cannot use readline on OpenBSD");
}
@[ DEFOPT +~ "_BSD_SOURCE" ];
};
strip_flag: []str =
if OS != "Windows" && !bool(config["debug"]) && !macos && bool(config["strip"])
{
@[ "-s" ];
};
lto_flag: []str =
if bool(config["lto"])
{
@[ "-flto" ];
};
strict_flags: []str =
if bool(config["strict"])
{
// Strict build only works for GCC and Clang, so we do want to set that
// here.
if CC contains "gcc" || CC contains "clang"
{
// These are the standard strict build flags for both compilers.
std_strict: []str = @[ "-Wall", "-Wextra", "-Werror", "-pedantic" ];
// Clang has -Weverything, which I ensure Yc builds under.
//
// I also want unlimited errors because Clang is my development
// compiler; it caps at 20 by default.
compiler_strict: []str =
if CC contains "clang"
{
// Oh, and add the standard.
@[ "-Weverything", "-ferror-limit=100000", "-Wno-padded",
"-Wno-unknown-warning-option", "-Wno-unsafe-buffer-usage",
"-Wno-documentation-unknown-command", "-Wno-pre-c11-compat",
"-Wno-enum-enum-conversion", "-Wno-switch-default" ];
};
// Return the combination of the sets.
std_strict +~ compiler_strict;
}
else if OS == "Windows"
{
// Return the combo of the strict options, the standard, and the
// sanitizer defines.
@[ "/W4", "/WX", "/wd\"4996\"", "/permissive-" ];
}
};
version_contents: str = io.read_file(path.join(src_dir, "VERSION.txt"));
version_lines: []str = version_contents.split("\n");
version: str = version_lines[0];
version_flag: []str = @[ DEFOPT +~ "VERSION=" +~ version ];
other_flags: []str = freebsd_flags +~ macos_flags +~ openbsd_flags +~
lto_flag +~ strict_flags +~ version_flag +~
if bool(config["debug"])
{
@[ compiler_db["opt.debug"] ];
};
history_files: []str =
if HISTORY != @none
{
HISTORY_C_FILES;
};
c_files: []str =
if BUILD_MODE == @both
{
COMMON_C_FILES +~ EXEC_C_FILES +~ BC_C_FILES +~ DC_C_FILES +~ history_files;
}
else if BUILD_MODE == @bc
{
COMMON_C_FILES +~ EXEC_C_FILES +~ BC_C_FILES +~ history_files;
}
else if BUILD_MODE == @dc
{
COMMON_C_FILES +~ EXEC_C_FILES +~ DC_C_FILES +~ history_files;
}
else
{
COMMON_C_FILES +~ LIBRARY_C_FILES;
};
build_config: Gaml = @(gaml){
other_cflags: $other_flags
strip_flag: $strip_flag
};
targets: []str =
push build_config: config_stack
{
gen_o_files: []str =
if BUILD_MODE != @library
{
@[
txt2o("gen/lib.bc", "bc_lib", "bc_lib_name", "BC_ENABLED", true),
txt2o("gen/lib2.bc", "bc_lib2", "bc_lib2_name",
"BC_ENABLED && BC_ENABLE_EXTRA_MATH", true),
txt2o("gen/bc_help.txt", "bc_help", "", "BC_ENABLED", false),
txt2o("gen/dc_help.txt", "dc_help", "", "DC_ENABLED", false),
];
};
obj_files: []str = gen_o_files +~
for f: c_files
{
c2o(f);
};
if BUILD_MODE == @both || BUILD_MODE == @bc
{
if OS != "Windows" && bool(config["install_manpages"])
{
src: str = path.join("manuals/bc", BUILD_TYPE +~ ".1");
target BC_MANPAGE: src
{
$ cp -f @(file_dep) @(tgt);
}
}
exe(BC_BIN, obj_files);
}
if BUILD_MODE == @both || BUILD_MODE == @dc
{
if OS != "Windows" && bool(config["install_manpages"])
{
src: str = path.join("manuals/dc", BUILD_TYPE +~ ".1");
target DC_MANPAGE: src
{
$ cp -f @(file_dep) @(tgt);
}
}
if BUILD_MODE == @both
{
ln(DC_BIN, BC_BIN);
}
else
{
exe(DC_BIN, obj_files);
}
}
if BUILD_MODE == @library
{
lib(LIBRARY, obj_files);
}
if BUILD_MODE == @both
{
@[ BC_BIN, DC_BIN ];
}
else if BUILD_MODE == @bc
{
@[ DC_BIN ];
}
else if BUILD_MODE == @dc
{
@[ DC_BIN ];
}
else
{
includedir: str = get_includedir();
libdir: str = get_libdir();
pc_config: Gaml = @(gaml){
INCLUDEDIR: $includedir
LIBDIR: $libdir
VERSION: $version
};
push pc_config: config_stack
{
target PC_FILE: PC_FILE +~ ".in"
{
configure_file(file_dep, tgt, "%%");
}
}
@[ LIBRARY, PC_FILE ];
}
};
if OS != "Windows"
{
if LIBRARY_ENABLED == "0"
{
target @install: targets
{
bindir: str = get_bindir();
if BC_ENABLED != "0"
{
$ $SAFE_INSTALL $EXEC_INSTALL_MODE $BC_BIN
@(path.join(bindir, BC_BIN));
}
if DC_ENABLED != "0"
{
if BC_ENABLED != "0"
{
$ ln -sf @("./" +~ BC_BIN) @(path.join(bindir, DC_BIN));
}
else
{
$ $SAFE_INSTALL $EXEC_INSTALL_MODE $BC_BIN
@(path.join(bindir, BC_BIN));
}
}
if NLS_ENABLED != "0"
{
locale_install_args: []str =
if sym(config["locales"]) == @all
{
@[ "-l" ];
};
if DESTDIR != ""
{
$ @(path.join(src_dir, "scripts/locale_install.sh"))
%(locale_install_args) @(str(config["nlspath"]))
$MAINEXEC $DESTDIR;
}
else
{
$ @(path.join(src_dir, "scripts/locale_install.sh"))
%(locale_install_args) @(str(config["nlspath"]))
$MAINEXEC;
}
}
if bool(config["install_manpages"])
{
man1dir: str = get_man1dir();
if BC_ENABLED != "0"
{
$ rm -rf @(path.join(man1dir, BC_MANPAGE));
}
if DC_ENABLED != "0"
{
$ rm -rf @(path.join(man1dir, DC_MANPAGE));
}
}
}
target @uninstall
{
bindir: str = get_bindir();
if BC_ENABLED != "0"
{
$ rm -rf @(path.join(bindir, BC_BIN));
}
if DC_ENABLED != "0"
{
$ rm -rf @(path.join(bindir, DC_BIN));
}
if NLS_ENABLED != "0"
{
if DESTDIR != ""
{
$ @(path.join(src_dir, "scripts/locale_uninstall.sh"))
@(str(config["nlspath"])) $MAINEXEC $DESTDIR;
}
else
{
$ @(path.join(src_dir, "scripts/locale_uninstall.sh"))
@(str(config["nlspath"])) $MAINEXEC;
}
}
if bool(config["install_manpages"])
{
man1dir: str = get_man1dir();
$ rm -rf @(path.join(man1dir, BC_MANPAGE))
@(path.join(man1dir, DC_MANPAGE));
}
}
}
else
{
target @install: targets, BCL_HEADER_PATH
{
full_libdir: str = get_libdir();
$ $SAFE_INSTALL $EXEC_INSTALL_MODE @(file_dep)
@(path.join(full_libdir, file_dep));
full_pc_path: str = get_pc_path();
bcl_pc: str = file_deps[1];
$ $SAFE_INSTALL $MANPAGE_INSTALL_MODE $bcl_pc
@(path.join(full_pc_path, bcl_pc));
full_includedir: str = get_includedir();
$ $SAFE_INSTALL $MANPAGE_INSTALL_MODE @(file_deps[2])
@(path.join(full_includedir, BCL_HEADER));
if bool(config["install_manpages"])
{
$ $SAFE_INSTALL $MANPAGE_INSTALL_MODE
@(path.join(src_dir, path.join("manuals", BCL_MANPAGE)))
@(path.join(get_man3dir(), BCL_MANPAGE));
}
}
target @uninstall
{
$ rm -rf @(path.join(get_libdir(), LIBRARY))
@(path.join(get_pc_path(), PC_FILE))
@(path.join(get_includedir(), BCL_HEADER));
if bool(config["install_manpages"])
{
$ rm -rf @(path.join(get_man3dir(), BCL_MANPAGE));
}
}
}
}
// If the platform matches the host, we can run the test suite.
if platform == host
{
// If we have the library, build and run that test.
if BUILD_MODE == @library
{
libtesto: str = c2o("tests/bcl.c");
libtest: str = "bcl";
exe(libtest, @[ libtesto, targets[0] ]);
test @bcl: libtest
{
$ @(str(tgt_name));
}
}
else
{
if BUILD_MODE != @dc
{
exe_tests("bc");
}
if BUILD_MODE != @bc
{
exe_tests("dc");
}
target @clean_tests
{
for f: path.find_ext(build_dir, "txt")
{
path.rm(f);
}
}
}
}
target "bitfuncgen"
{
error("TODO: Make this");
}
target @bitfuncgen: "bitfuncgen"
{
error("TODO: Make this");
}
target "ministat"
{
error("TODO: Make this");
}
target @ministat: "ministat"
{
error("TODO: Make this");
}
target @all: targets;
+3
View File
@@ -1,6 +1,9 @@
-Weverything
-pedantic
-Wno-unsafe-buffer-usage
-Wno-pre-c11-compat
-Wno-unknown-warning-option
-Wno-switch-default
-D_POSIX_C_SOURCE=200809L
-D_XOPEN_SOURCE=700
-D_BSD_SOURCE
+24 -453
View File
@@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2018-2024 Gavin D. Howard and contributors.
# Copyright (c) 2018-2025 Gavin D. Howard and contributors.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -55,7 +55,7 @@ usage() {
printf ' %s [-a|-bD|-dB|-c] [-CeEfgGHilmMNPrtTvz] [-O OPT_LEVEL] [-k KARATSUBA_LEN]\\\n' "$script"
printf ' [-s SETTING] [-S SETTING] [-p TYPE]\n'
printf ' %s \\\n' "$script"
printf ' [--library|--bc-only --disable-dc|--dc-only --disable-bc|--coverage] \\\n'
printf ' [--library|--bc-only --disable-dc|--dc-only --disable-bc] \\\n'
printf ' [--force --debug --disable-extra-math --disable-generated-tests] \\\n'
printf ' [--disable-history --disable-man-pages --disable-nls --disable-strip] \\\n'
printf ' [--enable-editline] [--enable-readline] [--enable-internal-history] \\\n'
@@ -74,7 +74,7 @@ usage() {
printf '\n'
printf ' -a, --library\n'
printf ' Build the libbcl instead of the programs. This is meant to be used with\n'
printf ' Other software like programming languages that want to make use of the\n'
printf ' other software like programming languages that want to make use of the\n'
printf ' parsing and math capabilities. This option will install headers using\n'
printf ' `make install`.\n'
printf ' -b, --bc-only\n'
@@ -83,10 +83,6 @@ usage() {
printf ' -B, --disable-bc\n'
printf ' Disable bc. It is an error if "-b", "--bc-only", "-D", or "--disable-dc"\n'
printf ' are specified too.\n'
printf ' -c, --coverage\n'
printf ' Generate test coverage code. Requires gcov and gcovr.\n'
printf ' It is an error if either "-b" ("-D") or "-d" ("-B") is specified.\n'
printf ' Requires a compiler that use gcc-compatible coverage options\n'
printf ' -C, --disable-clean\n'
printf ' Disable the clean that configure.sh does before configure.\n'
printf ' -d, --dc-only\n'
@@ -133,8 +129,6 @@ usage() {
printf ' Installs all locales, regardless of how many are on the system. This\n'
printf ' option is useful for package maintainers who want to make sure that\n'
printf ' a package contains all of the locales that end users might need.\n'
printf ' -m, --enable-memcheck\n'
printf ' Enable memcheck mode, to ensure no memory leaks. For development only.\n'
printf ' -M, --disable-man-pages\n'
printf ' Disable installing manpages.\n'
printf ' -N, --disable-nls\n'
@@ -172,17 +166,9 @@ usage() {
printf ' Set the default named by SETTING to off. See below for possible values\n'
printf ' for SETTING. For multiple instances of the -s or -S for the the same\n'
printf ' setting, the last one is used.\n'
printf ' -t, --enable-test-timing\n'
printf ' Enable the timing of tests. This is for development only.\n'
printf ' -T, --disable-strip\n'
printf ' Disable stripping symbols from the compiled binary or binaries.\n'
printf ' Stripping symbols only happens when debug mode is off.\n'
printf ' -v, --enable-valgrind\n'
printf ' Enable a build appropriate for valgrind. For development only.\n'
printf ' -z, --enable-fuzz-mode\n'
printf ' Enable fuzzing mode. THIS IS FOR DEVELOPMENT ONLY.\n'
printf ' -Z, --enable-ossfuzz-mode\n'
printf ' Enable fuzzing mode for OSS-Fuzz. THIS IS FOR DEVELOPMENT ONLY.\n'
printf ' --prefix PREFIX\n'
printf ' The prefix to install to. Overrides "$PREFIX" if it exists.\n'
printf ' If PREFIX is "/usr", install path will be "/usr/bin".\n'
@@ -254,12 +240,12 @@ usage() {
printf ' path (or contain one). This is treated the same as the POSIX\n'
printf ' definition of $NLSPATH (see POSIX environment variables for\n'
printf ' more information). Default is "/usr/share/locale/%%L/%%N".\n'
printf ' PC_PATH The location to install pkg-config files to. Must be an\n'
printf ' PC_PATH The location to install pkg-config files to. Must be a\n'
printf ' path or contain one. Default is the first path given by the\n'
printf ' output of `pkg-config --variable=pc_path pkg-config`.\n'
printf ' EXECSUFFIX The suffix to append to the executable names, used to not\n'
printf ' interfere with other installed bc executables. Default is "".\n'
printf ' EXECPREFIX The prefix to append to the executable names, used to not\n'
printf ' EXECPREFIX The prefix to prepend to the executable names, used to not\n'
printf ' interfere with other installed bc executables. Default is "".\n'
printf ' DESTDIR For package creation. Default is "". If it is empty when\n'
printf ' `%s` is run, it can also be passed to `make install`\n' "$script"
@@ -482,7 +468,7 @@ find_src_files() {
}
# This function generates a list of files to go into the Makefile. It generates
# the list of object files, as well as the list of test coverage files.
# the list of object files.
#
# @param contents The contents of the Makefile template to put the list of
# files into.
@@ -503,8 +489,6 @@ gen_file_list() {
_gen_file_list_needle_src="SRC"
_gen_file_list_needle_obj="OBJ"
_gen_file_list_needle_gcda="GCDA"
_gen_file_list_needle_gcno="GCNO"
_gen_file_list_replacement=$(find_src_files $_gen_file_list_unneeded | tr '\n' ' ')
_gen_file_list_contents=$(replace "$_gen_file_list_contents" \
@@ -521,151 +505,9 @@ gen_file_list() {
_gen_file_list_contents=$(replace "$_gen_file_list_contents" \
"$_gen_file_list_needle_obj" "$_gen_file_list_replacement")
_gen_file_list_replacement=$(replace_exts "$_gen_file_list_replacement" "o" "gcda")
_gen_file_list_contents=$(replace "$_gen_file_list_contents" \
"$_gen_file_list_needle_gcda" "$_gen_file_list_replacement")
_gen_file_list_replacement=$(replace_exts "$_gen_file_list_replacement" "gcda" "gcno")
_gen_file_list_contents=$(replace "$_gen_file_list_contents" \
"$_gen_file_list_needle_gcno" "$_gen_file_list_replacement")
printf '%s\n' "$_gen_file_list_contents"
}
# Generates the proper test targets for each test to have its own target. This
# allows `make test` to run in parallel.
#
# @param name Which calculator to generate tests for.
# @param extra_math An integer that, if non-zero, activates extra math tests.
# @param time_tests An integer that, if non-zero, tells the test suite to time
# the execution of each test.
gen_std_tests() {
_gen_std_tests_name="$1"
shift
_gen_std_tests_extra_math="$1"
shift
_gen_std_tests_time_tests="$1"
shift
_gen_std_tests_extra_required=$(cat "$scriptdir/tests/extra_required.txt")
for _gen_std_tests_t in $(cat "$scriptdir/tests/$_gen_std_tests_name/all.txt"); do
if [ "$_gen_std_tests_extra_math" -eq 0 ]; then
if [ -z "${_gen_std_tests_extra_required##*$_gen_std_tests_t*}" ]; then
printf 'test_%s_%s:\n\t@printf "Skipping %s %s\\n"\n\n' \
"$_gen_std_tests_name" "$_gen_std_tests_t" "$_gen_std_tests_name" \
"$_gen_std_tests_t" >> "Makefile"
continue
fi
fi
printf 'test_%s_%s:\n\t@export BC_TEST_OUTPUT_DIR="%s/tests"; sh $(TESTSDIR)/test.sh %s %s %s %s %s\n\n' \
"$_gen_std_tests_name" "$_gen_std_tests_t" "$builddir" "$_gen_std_tests_name" \
"$_gen_std_tests_t" "$generate_tests" "$time_tests" \
"$*" >> "Makefile"
done
}
# Generates a list of test targets that will be used as prerequisites for other
# targets.
#
# @param name The name of the calculator to generate test targets for.
gen_std_test_targets() {
_gen_std_test_targets_name="$1"
shift
_gen_std_test_targets_tests=$(cat "$scriptdir/tests/${_gen_std_test_targets_name}/all.txt")
for _gen_std_test_targets_t in $_gen_std_test_targets_tests; do
printf ' test_%s_%s' "$_gen_std_test_targets_name" "$_gen_std_test_targets_t"
done
printf '\n'
}
# Generates the proper test targets for each error test to have its own target.
# This allows `make test_bc_errors` and `make test_dc_errors` to run in
# parallel.
#
# @param name Which calculator to generate tests for.
gen_err_tests() {
_gen_err_tests_name="$1"
shift
_gen_err_tests_fs=$(ls "$scriptdir/tests/$_gen_err_tests_name/errors/")
for _gen_err_tests_t in $_gen_err_tests_fs; do
printf 'test_%s_error_%s:\n\t@export BC_TEST_OUTPUT_DIR="%s/tests"; sh $(TESTSDIR)/error.sh %s %s %s %s\n\n' \
"$_gen_err_tests_name" "$_gen_err_tests_t" "$builddir" "$_gen_err_tests_name" \
"$_gen_err_tests_t" "$problematic_tests" "$*" >> "Makefile"
done
}
# Generates a list of error test targets that will be used as prerequisites for
# other targets.
#
# @param name The name of the calculator to generate test targets for.
gen_err_test_targets() {
_gen_err_test_targets_name="$1"
shift
_gen_err_test_targets_tests=$(ls "$scriptdir/tests/$_gen_err_test_targets_name/errors/")
for _gen_err_test_targets_t in $_gen_err_test_targets_tests; do
printf ' test_%s_error_%s' "$_gen_err_test_targets_name" "$_gen_err_test_targets_t"
done
printf '\n'
}
# Generates the proper script test targets for each script test to have its own
# target. This allows `make test` to run in parallel.
#
# @param name Which calculator to generate tests for.
# @param extra_math An integer that, if non-zero, activates extra math tests.
# @param generate An integer that, if non-zero, activates generated tests.
# @param time_tests An integer that, if non-zero, tells the test suite to time
# the execution of each test.
gen_script_tests() {
_gen_script_tests_name="$1"
shift
_gen_script_tests_extra_math="$1"
shift
_gen_script_tests_generate="$1"
shift
_gen_script_tests_time="$1"
shift
_gen_script_tests_tests=$(cat "$scriptdir/tests/$_gen_script_tests_name/scripts/all.txt")
for _gen_script_tests_f in $_gen_script_tests_tests; do
_gen_script_tests_b=$(basename "$_gen_script_tests_f" ".${_gen_script_tests_name}")
printf 'test_%s_script_%s:\n\t@export BC_TEST_OUTPUT_DIR="%s/tests"; sh $(TESTSDIR)/script.sh %s %s %s 1 %s %s %s\n\n' \
"$_gen_script_tests_name" "$_gen_script_tests_b" "$builddir" "$_gen_script_tests_name" \
"$_gen_script_tests_f" "$_gen_script_tests_extra_math" "$_gen_script_tests_generate" \
"$_gen_script_tests_time" "$*" >> "Makefile"
done
}
set_default() {
_set_default_on="$1"
@@ -710,7 +552,6 @@ predefined_build() {
BSD)
bc_only=0
dc_only=0
coverage=0
debug=0
optimization="3"
hist=1
@@ -723,11 +564,6 @@ predefined_build() {
strip_bin=1
all_locales=0
library=0
fuzz=0
ossfuzz=0
time_tests=0
vg=0
memcheck=0
clean=1
bc_default_banner=0
bc_default_sigint_reset=1
@@ -744,7 +580,6 @@ predefined_build() {
GNU)
bc_only=0
dc_only=0
coverage=0
debug=0
optimization="3"
hist=1
@@ -757,11 +592,6 @@ predefined_build() {
strip_bin=1
all_locales=0
library=0
fuzz=0
ossfuzz=0
time_tests=0
vg=0
memcheck=0
clean=1
bc_default_banner=1
bc_default_sigint_reset=1
@@ -777,10 +607,10 @@ predefined_build() {
GDH)
CFLAGS="-Weverything -Wno-padded -Wno-unsafe-buffer-usage -Wno-poison-system-directories"
CFLAGS="$CFLAGS -Wno-switch-default -Werror -pedantic -std=c11"
CFLAGS="$CFLAGS -Wno-unknown-warning-option -Wno-switch-default -Wno-pre-c11-compat"
CFLAGS="$CFLAGS -Werror -pedantic -std=c11"
bc_only=0
dc_only=0
coverage=0
debug=0
optimization="3"
hist=1
@@ -793,11 +623,6 @@ predefined_build() {
strip_bin=1
all_locales=0
library=0
fuzz=0
ossfuzz=0
time_tests=0
vg=0
memcheck=0
clean=1
bc_default_banner=1
bc_default_sigint_reset=1
@@ -813,10 +638,10 @@ predefined_build() {
DBG)
CFLAGS="-Weverything -Wno-padded -Wno-unsafe-buffer-usage -Wno-poison-system-directories"
CFLAGS="$CFLAGS -Wno-switch-default -Werror -pedantic -std=c11"
CFLAGS="$CFLAGS -Wno-unknown-warning-option -Wno-switch-default -Wno-pre-c11-compat"
CFLAGS="$CFLAGS -Werror -pedantic -std=c11"
bc_only=0
dc_only=0
coverage=0
debug=1
optimization="0"
hist=1
@@ -829,11 +654,6 @@ predefined_build() {
strip_bin=1
all_locales=0
library=0
fuzz=0
ossfuzz=0
time_tests=0
vg=0
memcheck=1
clean=1
bc_default_banner=1
bc_default_sigint_reset=1
@@ -852,36 +672,12 @@ predefined_build() {
esac
}
# Generates a list of script test targets that will be used as prerequisites for
# other targets.
#
# @param name The name of the calculator to generate script test targets for.
gen_script_test_targets() {
_gen_script_test_targets_name="$1"
shift
_gen_script_test_targets_tests=$(cat "$scriptdir/tests/$_gen_script_test_targets_name/scripts/all.txt")
for _gen_script_test_targets_f in $_gen_script_test_targets_tests; do
_gen_script_test_targets_b=$(basename "$_gen_script_test_targets_f" \
".$_gen_script_test_targets_name")
printf ' test_%s_script_%s' "$_gen_script_test_targets_name" \
"$_gen_script_test_targets_b"
done
printf '\n'
}
# This is a list of defaults, but it is also the list of possible options for
# users to change.
#
# The development options are: force (force options even if they fail), valgrind
# (build in a way suitable for valgrind testing), memcheck (same as valgrind),
# and fuzzing (build in a way suitable for fuzzing).
# The development options are: force (force options even if they fail).
bc_only=0
dc_only=0
coverage=0
karatsuba_len=32
debug=0
hist=1
@@ -895,11 +691,6 @@ force=0
strip_bin=1
all_locales=0
library=0
fuzz=0
ossfuzz=0
time_tests=0
vg=0
memcheck=0
clean=1
problematic_tests=1
@@ -920,13 +711,12 @@ dc_default_digit_clamp=0
# getopts is a POSIX utility, but it cannot handle long options. Thus, the
# handling of long options is done by hand, and that's the reason that short and
# long options cannot be mixed.
while getopts "abBcdDeEfgGhHik:lMmNO:p:PrS:s:tTvzZ-" opt; do
while getopts "abBcdDeEfgGhHik:lMNO:p:PrS:s:T-" opt; do
case "$opt" in
a) library=1 ;;
b) bc_only=1 ;;
B) dc_only=1 ;;
c) coverage=1 ;;
C) clean=0 ;;
d) dc_only=1 ;;
D) bc_only=1 ;;
@@ -940,7 +730,6 @@ while getopts "abBcdDeEfgGhHik:lMmNO:p:PrS:s:tTvzZ-" opt; do
i) hist_impl="internal" ;;
k) karatsuba_len="$OPTARG" ;;
l) all_locales=1 ;;
m) memcheck=1 ;;
M) install_manpages=0 ;;
N) nls=0 ;;
O) optimization="$OPTARG" ;;
@@ -949,11 +738,7 @@ while getopts "abBcdDeEfgGhHik:lMmNO:p:PrS:s:tTvzZ-" opt; do
r) hist_impl="readline" ;;
S) set_default 0 "$OPTARG" ;;
s) set_default 1 "$OPTARG" ;;
t) time_tests=1 ;;
T) strip_bin=0 ;;
v) vg=1 ;;
z) fuzz=1 ;;
Z) ossfuzz=1 ;;
-)
arg="$1"
arg="${arg#--}"
@@ -963,7 +748,6 @@ while getopts "abBcdDeEfgGhHik:lMmNO:p:PrS:s:tTvzZ-" opt; do
library) library=1 ;;
bc-only) bc_only=1 ;;
dc-only) dc_only=1 ;;
coverage) coverage=1 ;;
debug) debug=1 ;;
force) force=1 ;;
prefix=?*) PREFIX="$LONG_OPTARG" ;;
@@ -1077,27 +861,20 @@ while getopts "abBcdDeEfgGhHik:lMmNO:p:PrS:s:tTvzZ-" opt; do
enable-editline) hist_impl="editline" ;;
enable-readline) hist_impl="readline" ;;
enable-internal-history) hist_impl="internal" ;;
enable-test-timing) time_tests=1 ;;
enable-valgrind) vg=1 ;;
enable-fuzz-mode) fuzz=1 ;;
enable-ossfuzz-mode) ossfuzz=1 ;;
enable-memcheck) memcheck=1 ;;
install-all-locales) all_locales=1 ;;
help* | bc-only* | dc-only* | coverage* | debug*)
help* | bc-only* | dc-only* | debug*)
usage "No arg allowed for --$arg option" ;;
disable-bc* | disable-dc* | disable-clean*)
usage "No arg allowed for --$arg option" ;;
disable-extra-math*)
usage "No arg allowed for --$arg option" ;;
disable-generated-tests* | disable-history*)
disable-history*)
usage "No arg allowed for --$arg option" ;;
disable-man-pages* | disable-nls* | disable-strip*)
usage "No arg allowed for --$arg option" ;;
disable-problematic-tests*)
usage "No arg allowed for --$arg option" ;;
enable-fuzz-mode* | enable-test-timing* | enable-valgrind*)
usage "No arg allowed for --$arg option" ;;
enable-memcheck* | install-all-locales*)
install-all-locales*)
usage "No arg allowed for --$arg option" ;;
enable-editline* | enable-readline*)
usage "No arg allowed for --$arg option" ;;
@@ -1221,33 +998,7 @@ link="@printf 'No link necessary\\\\n'"
main_exec="BC"
executable="BC_EXEC"
tests="test_bc timeconst test_dc"
bc_test="@export BC_TEST_OUTPUT_DIR=\"$builddir/tests\"; \$(TESTSDIR)/all.sh bc $extra_math 1 $generate_tests $problematic_tests $time_tests \$(BC_EXEC)"
bc_test_np="@export BC_TEST_OUTPUT_DIR=\"$builddir/tests\"; \$(TESTSDIR)/all.sh -n bc $extra_math 1 $generate_tests $problematic_tests $time_tests \$(BC_EXEC)"
dc_test="@export BC_TEST_OUTPUT_DIR=\"$builddir/tests\"; \$(TESTSDIR)/all.sh dc $extra_math 1 $generate_tests $problematic_tests $time_tests \$(DC_EXEC)"
dc_test_np="@export BC_TEST_OUTPUT_DIR=\"$builddir/tests\"; \$(TESTSDIR)/all.sh -n dc $extra_math 1 $generate_tests $problematic_tests $time_tests \$(DC_EXEC)"
timeconst="@export BC_TEST_OUTPUT_DIR=\"$builddir/tests\"; \$(TESTSDIR)/bc/timeconst.sh \$(TESTSDIR)/bc/scripts/timeconst.bc \$(BC_EXEC)"
# In order to have cleanup at exit, we need to be in
# debug mode, so don't run valgrind without that.
if [ "$vg" -ne 0 ]; then
debug=1
bc_test_exec='valgrind $(VALGRIND_ARGS) $(BC_EXEC)'
dc_test_exec='valgrind $(VALGRIND_ARGS) $(DC_EXEC)'
bcl_test_exec='valgrind $(VALGRIND_ARGS) $(BCL_TEST)'
else
bc_test_exec='$(BC_EXEC)'
dc_test_exec='$(DC_EXEC)'
bcl_test_exec='$(BCL_TEST)'
fi
test_bc_history_prereqs="test_bc_history_all"
test_dc_history_prereqs="test_dc_history_all"
karatsuba="@printf 'karatsuba cannot be run because one of bc or dc is not built\\\\n'"
karatsuba_test="@printf 'karatsuba cannot be run because one of bc or dc is not built\\\\n'"
bc_lib="\$(GEN_DIR)/lib.o"
bc_help="\$(GEN_DIR)/bc_help.o"
@@ -1274,9 +1025,6 @@ if [ "$library" -ne 0 ]; then
default_target_prereqs="\$(BIN) \$(OBJ)"
default_target_cmd="ar -r -cu \$(LIBBC) \$(OBJ)"
default_target="\$(LIBBC)"
tests="test_library"
test_bc_history_prereqs=" test_bc_history_skip"
test_dc_history_prereqs=" test_dc_history_skip"
install_prereqs=" install_library"
uninstall_prereqs=" uninstall_library"
@@ -1292,10 +1040,6 @@ elif [ "$bc_only" -eq 1 ]; then
executables="bc"
dc_test="@printf 'No dc tests to run\\\\n'"
dc_test_np="@printf 'No dc tests to run\\\\n'"
test_dc_history_prereqs=" test_dc_history_skip"
install_prereqs=" install_execs"
install_man_prereqs=" install_bc_manpage"
uninstall_prereqs=" uninstall_bc"
@@ -1303,7 +1047,6 @@ elif [ "$bc_only" -eq 1 ]; then
default_target="\$(BC_EXEC)"
second_target="\$(DC_EXEC)"
tests="test_bc timeconst"
elif [ "$dc_only" -eq 1 ]; then
@@ -1318,58 +1061,11 @@ elif [ "$dc_only" -eq 1 ]; then
main_exec="DC"
executable="DC_EXEC"
bc_test="@printf 'No bc tests to run\\\\n'"
bc_test_np="@printf 'No bc tests to run\\\\n'"
test_bc_history_prereqs=" test_bc_history_skip"
timeconst="@printf 'timeconst cannot be run because bc is not built\\\\n'"
install_prereqs=" install_execs"
install_man_prereqs=" install_dc_manpage"
uninstall_prereqs=" uninstall_dc"
uninstall_man_prereqs=" uninstall_dc_manpage"
tests="test_dc"
elif [ "$ossfuzz" -eq 1 ]; then
if [ "$bc_only" -ne 0 ] || [ "$dc_only" -ne 0 ]; then
usage "An OSS-Fuzz build must build both fuzzers."
fi
bc=1
dc=1
# Expressions *cannot* exit in an OSS-Fuzz build.
bc_default_expr_exit=0
dc_default_expr_exit=0
executables="bc_fuzzer and dc_fuzzer"
karatsuba="@\$(KARATSUBA) 30 0 \$(BC_EXEC)"
karatsuba_test="@\$(KARATSUBA) 1 100 \$(BC_EXEC)"
if [ "$library" -eq 0 ]; then
install_prereqs=" install_execs"
install_man_prereqs=" install_bc_manpage install_dc_manpage"
uninstall_prereqs=" uninstall_bc uninstall_dc"
uninstall_man_prereqs=" uninstall_bc_manpage uninstall_dc_manpage"
else
install_prereqs=" install_library install_bcl_header"
install_man_prereqs=" install_bcl_manpage"
uninstall_prereqs=" uninstall_library uninstall_bcl_header"
uninstall_man_prereqs=" uninstall_bcl_manpage"
tests="test_library"
fi
second_target_prereqs="src/bc_fuzzer.o $default_target_prereqs"
default_target_prereqs="\$(BC_FUZZER) src/dc_fuzzer.o $default_target_prereqs"
default_target_cmd="\$(CXX) \$(CFLAGS) src/dc_fuzzer.o \$(LIB_FUZZING_ENGINE) \$(OBJS) \$(LDFLAGS) -o \$(DC_FUZZER) \&\& ln -sf ./dc_fuzzer_c \$(DC_FUZZER_C)"
second_target_cmd="\$(CXX) \$(CFLAGS) src/bc_fuzzer.o \$(LIB_FUZZING_ENGINE) \$(OBJS) \$(LDFLAGS) -o \$(BC_FUZZER) \&\& ln -sf ./bc_fuzzer_c \$(BC_FUZZER_C)"
default_target="\$(DC_FUZZER) \$(DC_FUZZER_C)"
second_target="\$(BC_FUZZER) \$(BC_FUZZER_C)"
else
bc=1
@@ -1378,7 +1074,6 @@ else
executables="bc and dc"
karatsuba="@\$(KARATSUBA) 30 0 \$(BC_EXEC)"
karatsuba_test="@\$(KARATSUBA) 1 100 \$(BC_EXEC)"
if [ "$library" -eq 0 ]; then
install_prereqs=" install_execs"
@@ -1390,7 +1085,6 @@ else
install_man_prereqs=" install_bcl_manpage"
uninstall_prereqs=" uninstall_library uninstall_bcl_header"
uninstall_man_prereqs=" uninstall_bcl_manpage"
tests="test_library"
fi
second_target_prereqs="$default_target_prereqs"
@@ -1399,18 +1093,6 @@ else
fi
if [ "$fuzz" -ne 0 ] && [ "$ossfuzz" -ne 0 ]; then
usage "Fuzzing mode and OSS-Fuzz mode are mutually exclusive"
fi
# We need specific stuff for fuzzing.
if [ "$fuzz" -ne 0 ] || [ "$ossfuzz" -ne 0 ]; then
debug=1
hist=0
nls=0
optimization="3"
fi
# This sets some necessary things for debug mode.
if [ "$debug" -eq 1 ]; then
@@ -1429,26 +1111,6 @@ if [ -n "$optimization" ]; then
CFLAGS="-O$optimization $CFLAGS"
fi
# Set test coverage defaults.
if [ "$coverage" -eq 1 ]; then
if [ "$bc_only" -eq 1 ] || [ "$dc_only" -eq 1 ]; then
usage "Can only specify -c without -b or -d"
fi
CFLAGS="-fprofile-arcs -ftest-coverage -g -O0 $CFLAGS"
CPPFLAGS="-DNDEBUG $CPPFLAGS"
COVERAGE_OUTPUT="@gcov -pabcdf \$(GCDA) \$(BC_GCDA) \$(DC_GCDA) \$(HISTORY_GCDA) \$(RAND_GCDA)"
COVERAGE_OUTPUT="$COVERAGE_OUTPUT;\$(RM) -f \$(GEN)*.gc*"
COVERAGE_OUTPUT="$COVERAGE_OUTPUT;gcovr --exclude-unreachable-branches --exclude-throw-branches --html-details --output index.html"
COVERAGE_PREREQS=" test coverage_output"
else
COVERAGE_OUTPUT="@printf 'Coverage not generated\\\\n'"
COVERAGE_PREREQS=""
fi
# Set some defaults.
if [ -z "${DESTDIR+set}" ]; then
destdir=""
@@ -1567,7 +1229,7 @@ if [ "$nls" -ne 0 ]; then
printf 'NLS works.\n\n'
printf 'Testing gencat...\n'
gencat "./en_US.cat" "$scriptdir/locales/en_US.msg" > /dev/null
gencat "./en_US.cat" "$scriptdir/locales/en_US.msg" 2>&1
err="$?"
@@ -1672,26 +1334,10 @@ else
fi
# We have to disable the history tests if it is disabled or valgrind is on. Or
# if we are using editline or readline.
if [ "$hist" -eq 0 ] || [ "$vg" -ne 0 ]; then
test_bc_history_prereqs=" test_bc_history_skip"
test_dc_history_prereqs=" test_dc_history_skip"
history_tests="@printf 'Skipping history tests...\\\\n'"
if [ "$hist" -eq 0 ]; then
CFLAGS="$CFLAGS -DBC_ENABLE_EDITLINE=0 -DBC_ENABLE_READLINE=0"
else
if [ "$editline" -eq 0 ] && [ "$readline" -eq 0 ]; then
history_tests="@printf '\$(TEST_STARS)\\\\n\\\\nRunning history tests...\\\\n\\\\n'"
history_tests="$history_tests \&\& \$(TESTSDIR)/history.sh bc -a \&\&"
history_tests="$history_tests \$(TESTSDIR)/history.sh dc -a \&\& printf"
history_tests="$history_tests '\\\\nAll history tests passed.\\\\n\\\\n\$(TEST_STARS)\\\\n'"
else
test_bc_history_prereqs=" test_bc_history_skip"
test_dc_history_prereqs=" test_dc_history_skip"
history_tests="@printf 'Skipping history tests...\\\\n'"
fi
# We are also setting the CFLAGS and LDFLAGS here.
if [ "$editline" -ne 0 ]; then
LDFLAGS="$LDFLAGS -ledit"
@@ -1795,7 +1441,7 @@ GEN_DIR="$scriptdir/gen"
# `gen/strgen.sh` is used.
GEN="strgen"
GEN_EXEC_TARGET="\$(HOSTCC) -DBC_ENABLE_AFL=0 -DBC_ENABLE_OSSFUZZ=0 -I$scriptdir/include/ \$(HOSTCFLAGS) -o \$(GEN_EXEC) \$(GEN_C)"
CLEAN_PREREQS=" clean_gen clean_coverage"
CLEAN_PREREQS=" clean_gen"
if [ -z "${GEN_HOST+set}" ]; then
GEN_HOST=1
@@ -1803,7 +1449,6 @@ else
if [ "$GEN_HOST" -eq 0 ]; then
GEN="strgen.sh"
GEN_EXEC_TARGET="@printf 'Do not need to build gen/strgen.c\\\\n'"
CLEAN_PREREQS=" clean_coverage"
fi
fi
@@ -1848,9 +1493,7 @@ else
headers="$headers \$(DC_HEADERS)"
fi
# This convoluted mess does pull the version out. If you change the format of
# include/version.h, you may have to change this line.
version=$(cat "$scriptdir/include/version.h" | grep "VERSION " - | awk '{ print $3 }' -)
version=$(cat "$scriptdir/VERSION.txt" | head -n1)
if [ "$library" -ne 0 ]; then
@@ -1880,14 +1523,6 @@ if [ "$library" -ne 0 ]; then
fi
elif [ "$ossfuzz" -ne 0 ]; then
unneeded="$unneeded library.c main.c"
PC_PATH=""
pkg_config_install=""
pkg_config_uninstall=""
else
unneeded="$unneeded library.c"
@@ -1909,10 +1544,6 @@ if [ "$manpage_args" = "" ]; then
manpage_args="A"
fi
if [ "$vg" -ne 0 ] || [ "$ossfuzz" -ne 0 ]; then
memcheck=1
fi
if [ "$bc_default_prompt" = "" ]; then
bc_default_prompt="$bc_default_tty_mode"
fi
@@ -1921,14 +1552,6 @@ if [ "$dc_default_prompt" = "" ]; then
dc_default_prompt="$dc_default_tty_mode"
fi
# Generate the test targets and prerequisites.
bc_tests=$(gen_std_test_targets bc)
bc_script_tests=$(gen_script_test_targets bc)
bc_err_tests=$(gen_err_test_targets bc)
dc_tests=$(gen_std_test_targets dc)
dc_script_tests=$(gen_script_test_targets dc)
dc_err_tests=$(gen_err_test_targets dc)
printf 'unneeded: %s\n' "$unneeded"
# Print out the values; this is for debugging.
@@ -1949,7 +1572,6 @@ printf 'BC_ENABLE_LIBRARY=%s\n\n' "$library"
printf 'BC_ENABLE_HISTORY=%s\n' "$hist"
printf 'BC_ENABLE_EXTRA_MATH=%s\n' "$extra_math"
printf 'BC_ENABLE_NLS=%s\n\n' "$nls"
printf 'BC_ENABLE_AFL=%s\n' "$fuzz"
printf '\n'
printf 'BC_NUM_KARATSUBA_LEN=%s\n' "$karatsuba_len"
printf '\n'
@@ -2046,26 +1668,11 @@ contents=$(replace "$contents" "BUILDDIR" "$builddir")
contents=$(replace "$contents" "HEADERS" "$headers")
contents=$(replace "$contents" "VERSION" "$version")
contents=$(replace "$contents" "BC_ENABLED" "$bc")
contents=$(replace "$contents" "DC_ENABLED" "$dc")
contents=$(replace "$contents" "BC_ALL_TESTS" "$bc_test")
contents=$(replace "$contents" "BC_ALL_TESTS_NP" "$bc_test_np")
contents=$(replace "$contents" "BC_TESTS" "$bc_tests")
contents=$(replace "$contents" "BC_SCRIPT_TESTS" "$bc_script_tests")
contents=$(replace "$contents" "BC_ERROR_TESTS" "$bc_err_tests")
contents=$(replace "$contents" "BC_TEST_EXEC" "$bc_test_exec")
contents=$(replace "$contents" "TIMECONST_ALL_TESTS" "$timeconst")
contents=$(replace "$contents" "DC_ALL_TESTS" "$dc_test")
contents=$(replace "$contents" "DC_ALL_TESTS_NP" "$dc_test_np")
contents=$(replace "$contents" "DC_TESTS" "$dc_tests")
contents=$(replace "$contents" "DC_SCRIPT_TESTS" "$dc_script_tests")
contents=$(replace "$contents" "DC_ERROR_TESTS" "$dc_err_tests")
contents=$(replace "$contents" "DC_TEST_EXEC" "$dc_test_exec")
contents=$(replace "$contents" "BCL_TEST_EXEC" "$bcl_test_exec")
contents=$(replace "$contents" "BUILD_TYPE" "$manpage_args")
contents=$(replace "$contents" "EXCLUDE_EXTRA_MATH" "$exclude_extra_math")
@@ -2073,10 +1680,6 @@ contents=$(replace "$contents" "LIBRARY" "$library")
contents=$(replace "$contents" "HISTORY" "$hist")
contents=$(replace "$contents" "EXTRA_MATH" "$extra_math")
contents=$(replace "$contents" "NLS" "$nls")
contents=$(replace "$contents" "FUZZ" "$fuzz")
contents=$(replace "$contents" "OSSFUZZ" "$ossfuzz")
contents=$(replace "$contents" "MEMCHECK" "$memcheck")
contents=$(replace "$contents" "LIB_FUZZING_ENGINE" "$LIB_FUZZING_ENGINE")
contents=$(replace "$contents" "BC_LIB_O" "$bc_lib")
contents=$(replace "$contents" "BC_HELP_O" "$bc_help")
@@ -2099,8 +1702,6 @@ contents=$(replace "$contents" "CPPFLAGS" "$CPPFLAGS")
contents=$(replace "$contents" "LDFLAGS" "$LDFLAGS")
contents=$(replace "$contents" "CC" "$CC")
contents=$(replace "$contents" "HOSTCC" "$HOSTCC")
contents=$(replace "$contents" "COVERAGE_OUTPUT" "$COVERAGE_OUTPUT")
contents=$(replace "$contents" "COVERAGE_PREREQS" "$COVERAGE_PREREQS")
contents=$(replace "$contents" "INSTALL_PREREQS" "$install_prereqs")
contents=$(replace "$contents" "INSTALL_MAN_PREREQS" "$install_man_prereqs")
contents=$(replace "$contents" "INSTALL_LOCALES" "$install_locales")
@@ -2126,22 +1727,14 @@ contents=$(replace "$contents" "BC_EXEC_CMD" "$bc_exec_cmd")
contents=$(replace "$contents" "DC_EXEC_PREREQ" "$dc_exec_prereq")
contents=$(replace "$contents" "DC_EXEC_CMD" "$dc_exec_cmd")
contents=$(replace "$contents" "GENERATE_TESTS" "$generate_tests")
contents=$(replace "$contents" "PROBLEMATIC_TESTS" "$problematic_tests")
contents=$(replace "$contents" "EXECUTABLES" "$executables")
contents=$(replace "$contents" "MAIN_EXEC" "$main_exec")
contents=$(replace "$contents" "EXEC" "$executable")
contents=$(replace "$contents" "TESTS" "$tests")
contents=$(replace "$contents" "BC_HISTORY_TEST_PREREQS" "$test_bc_history_prereqs")
contents=$(replace "$contents" "DC_HISTORY_TEST_PREREQS" "$test_dc_history_prereqs")
contents=$(replace "$contents" "HISTORY_TESTS" "$history_tests")
contents=$(replace "$contents" "VG_BC_TEST" "$vg_bc_test")
contents=$(replace "$contents" "VG_DC_TEST" "$vg_dc_test")
contents=$(replace "$contents" "TIMECONST" "$timeconst")
contents=$(replace "$contents" "KARATSUBA" "$karatsuba")
contents=$(replace "$contents" "KARATSUBA_TEST" "$karatsuba_test")
contents=$(replace "$contents" "LONG_BIT_DEFINE" "$LONG_BIT_DEFINE")
@@ -2169,28 +1762,6 @@ contents=$(replace "$contents" "DC_DEFAULT_DIGIT_CLAMP" "$dc_default_digit_clamp
# Do the first print to the Makefile.
printf '%s\n%s\n\n' "$contents" "$SRC_TARGETS" > "Makefile"
# Generate the individual test targets.
if [ "$bc" -ne 0 ]; then
gen_std_tests bc "$extra_math" "$time_tests" $bc_test_exec
gen_script_tests bc "$extra_math" "$generate_tests" "$time_tests" $bc_test_exec
gen_err_tests bc $bc_test_exec
fi
if [ "$dc" -ne 0 ]; then
gen_std_tests dc "$extra_math" "$time_tests" $dc_test_exec
gen_script_tests dc "$extra_math" "$generate_tests" "$time_tests" $dc_test_exec
gen_err_tests dc $dc_test_exec
fi
if [ "$ossfuzz" -ne 0 ]; then
printf 'bc_fuzzer_c: $(BC_FUZZER)\n\tln -sf $(BC_FUZZER) bc_fuzzer_c\n' >> Makefile
printf 'bc_fuzzer_C: $(BC_FUZZER)\n\tln -sf $(BC_FUZZER) bc_fuzzer_C\n' >> Makefile
printf 'dc_fuzzer_c: $(DC_FUZZER)\n\tln -sf $(DC_FUZZER) dc_fuzzer_c\n' >> Makefile
printf 'dc_fuzzer_C: $(DC_FUZZER)\n\tln -sf $(DC_FUZZER) dc_fuzzer_C\n' >> Makefile
fi
# Copy the correct manuals to the expected places.
mkdir -p manuals
cp -f "$scriptdir/manuals/bc/$manpage_args.1.md" manuals/bc.1.md
+2 -2
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -37,7 +37,7 @@ usage: %s [options] [file...]
bc is a command-line, arbitrary-precision calculator with a Turing-complete
language. For details, use `man %s` or see the online documentation at
https://git.gavinhoward.com/gavin/bc/src/tag/%s/manuals/bc/%s.1.md.
https://github.com/gavinhoward/bc/tree/%s/manuals/bc/%s.1.md .
This bc is compatible with both the GNU bc and the POSIX bc spec. See the GNU bc
manual (https://www.gnu.org/software/bc/manual/bc.html) and bc spec
+2 -2
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -37,7 +37,7 @@ usage: %s [options] [file...]
dc is a reverse-polish notation command-line calculator which supports unlimited
precision arithmetic. For details, use `man %s` or see the online documentation
at https://git.gavinhoward.com/gavin/bc/src/tag/%s/manuals/bc/%s.1.md.
at https://github.com/gavinhoward/bc/tree/%s/manuals/dc/%s.1.md .
This dc is (mostly) compatible with the OpenBSD dc and the GNU dc. See the
OpenBSD man page (http://man.openbsd.org/OpenBSD-current/man1/dc.1) and the GNU
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+45 -70
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -444,108 +444,77 @@ define void uint64(x){uintn(x,8)}
define void int64(x){intn(x,8)}
define void uint(x){uintn(x,ubytes(x))}
define void int(x){intn(x,sbytes(x))}
define bunrev(t){
auto a,s,m[]
s=scale
scale=0
t=abs(t)$
while(t!=1){
t=divmod(t,2,m[])
a*=2
a+=m[0]
}
scale=s
return a
}
define band(a,b){
auto s,t,m[],n[]
auto r,p,s,m[]
a=abs(a)$
b=abs(b)$
if(b>a){
t=b
b=a
a=t
}
r=0
p=1
s=scale
scale=0
t=1
while(b){
while(a&&b) {
a=divmod(a,2,m[])
b=divmod(b,2,n[])
t*=2
t+=(m[0]&&n[0])
if(m[0]){
b=divmod(b,2,m[])
if(m[0])r+=p
}else b/=2
p*=2
}
scale=s
return bunrev(t)
return r
}
define bor(a,b){
auto s,t,m[],n[]
auto r,p,s,m[]
a=abs(a)$
b=abs(b)$
if(b>a){
t=b
b=a
a=t
}
r=0
p=1
s=scale
scale=0
t=1
while(b){
while(a||b){
a=divmod(a,2,m[])
b=divmod(b,2,n[])
t*=2
t+=(m[0]||n[0])
}
while(a){
a=divmod(a,2,m[])
t*=2
t+=m[0]
if(!m[0])b=divmod(b,2,m[])
else b/=2
if(m[0])r+=p
p*=2
}
scale=s
return bunrev(t)
return r
}
define bxor(a,b){
auto s,t,m[],n[]
auto r,p,s,m[],n[]
a=abs(a)$
b=abs(b)$
if(b>a){
t=b
b=a
a=t
}
r=0
p=1
s=scale
scale=0
t=1
while(b){
while(a||b){
a=divmod(a,2,m[])
b=divmod(b,2,n[])
t*=2
t+=(m[0]+n[0]==1)
}
while(a){
a=divmod(a,2,m[])
t*=2
t+=m[0]
if(m[0]+n[0]==1)r+=p
p*=2
}
scale=s
return bunrev(t)
return r
}
define bshl(a,b){return abs(a)$*2^abs(b)$}
define bshr(a,b){return(abs(a)$/2^abs(b)$)$}
define bnotn(x,n){
auto s,t,m[]
auto r,p,s,t,m[]
s=scale
scale=0
t=2^(abs(n)$*8)
x=abs(x)$%t+t
t=1
r=2^(abs(n)$*8)
x=abs(x)$%r+r
r=0
p=1
while(x!=1){
x=divmod(x,2,m[])
t*=2
t+=!m[0]
if(!m[0])r+=p
p*=2
}
scale=s
return bunrev(t)
return r
}
define bnot8(x){return bnotn(x,1)}
define bnot16(x){return bnotn(x,2)}
@@ -553,13 +522,19 @@ define bnot32(x){return bnotn(x,4)}
define bnot64(x){return bnotn(x,8)}
define bnot(x){return bnotn(x,ubytes(x))}
define brevn(x,n){
auto s,t,m[]
auto a,s,m[]
s=scale
scale=0
t=2^(abs(n)$*8)
x=abs(x)$%t+t
a=2^(abs(n)$*8)
x=abs(x)$%a+a
a=0
while(x!=1){
x=divmod(x,2,m[])
a*=2
a+=m[0]
}
scale=s
return bunrev(x)
return a
}
define brev8(x){return brevn(x,1)}
define brev16(x){return brevn(x,2)}
+2 -2
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -68,7 +68,7 @@ static const char* const bc_gen_ex_end = "{{ end }}";
// This is exactly what it looks like. It just slaps a simple license header on
// the generated C source file.
static const char* const bc_gen_header =
"// Copyright (c) 2018-2024 Gavin D. Howard and contributors.\n"
"// Copyright (c) 2018-2025 Gavin D. Howard and contributors.\n"
"// Licensed under the 2-clause BSD license.\n"
"// *** AUTOMATICALLY GENERATED FROM %s. DO NOT MODIFY. ***\n\n";
// clang-format on
+2 -2
View File
@@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: BSD-2-Clause
#
# Copyright (c) 2018-2024 Gavin D. Howard and contributors.
# Copyright (c) 2018-2025 Gavin D. Howard and contributors.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -96,7 +96,7 @@ if [ -n "$remove_tabs" ]; then
fi
cat<<EOF
// Copyright (c) 2018-2024 Gavin D. Howard and contributors.
// Copyright (c) 2018-2025 Gavin D. Howard and contributors.
// Licensed under the 2-clause BSD license.
// *** AUTOMATICALLY GENERATED FROM ${input}. DO NOT MODIFY. ***
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+4 -4
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -265,9 +265,9 @@ bc_lex_token(BcLex* l);
* @return An expression entry for bc_parse_exprs[].
*/
#define BC_PARSE_EXPR_ENTRY(e1, e2, e3, e4, e5, e6, e7, e8) \
((UINTMAX_C(e1) << 7) | (UINTMAX_C(e2) << 6) | (UINTMAX_C(e3) << 5) | \
(UINTMAX_C(e4) << 4) | (UINTMAX_C(e5) << 3) | (UINTMAX_C(e6) << 2) | \
(UINTMAX_C(e7) << 1) | (UINTMAX_C(e8) << 0))
((UINT8_C(e1) << 7) | (UINT8_C(e2) << 6) | (UINT8_C(e3) << 5) | \
(UINT8_C(e4) << 4) | (UINT8_C(e5) << 3) | (UINT8_C(e6) << 2) | \
(UINT8_C(e7) << 1) | (UINT8_C(e8) << 0))
/**
* Returns true if token @a i is a token that belongs in an expression.
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+1 -25
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -120,30 +120,6 @@ typedef struct BcHistory
extern const char bc_history_editrc[];
extern const size_t bc_history_editrc_len;
#ifdef __APPLE__
/**
* Returns true if the line is a valid line, false otherwise.
* @param line The line.
* @param len The length of the line.
* @return True if the line is valid, false otherwise.
*/
#define BC_HISTORY_INVALID_LINE(line, len) \
((line) == NULL && ((len) == -1 || errno == EINTR))
#else // __APPLE__
/**
* Returns true if the line is a valid line, false otherwise.
* @param line The line.
* @param len The length of the line.
* @return True if the line is valid, false otherwise.
*/
#define BC_HISTORY_INVALID_LINE(line, len) \
((line) == NULL && (len) == -1 && errno == EINTR)
#endif // __APPLE__
#else // BC_ENABLE_EDITLINE
#if BC_ENABLE_READLINE
+5 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -533,6 +533,10 @@ typedef enum BcType
} BcType;
#if BC_ENABLED
/// Check if type array or array reference
#define BC_IS_ARRAY(e) (e == BC_TYPE_ARRAY || e == BC_TYPE_REF)
/// An auto variable in bc.
typedef struct BcAuto
{
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+12 -4
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -145,6 +145,9 @@ typedef struct BcProgram
#endif // BC_ENABLED
/// The number of results that have not been retired.
size_t nresults;
// The BcDig array for strmb. This uses BC_NUM_LONG_LOG10 because it is used
// in bc_num_ulong2num(), which attempts to realloc, unless it is big
// enough. This is big enough.
@@ -207,11 +210,16 @@ typedef struct BcProgram
* operands while preserving the result (which we assumed was pushed before the
* actual operation).
* @param p The program.
* @param nres The number of results returned by the instruction.
* @param nops The number of operands used by the instruction.
*/
#define bc_program_retire(p, nres, nops) \
(bc_vec_npopAt(&(p)->results, (nops), (p)->results.len - (nres + nops)))
#define bc_program_retire(p, nops) \
do \
{ \
bc_vec_npopAt(&(p)->results, (nops), \
(p)->results.len - ((p)->nresults + nops)); \
p->nresults = 0; \
} \
while (0)
#if DC_ENABLED
+1 -1
View File
@@ -13,7 +13,7 @@
* This code is under the following license:
*
* Copyright (c) 2014-2017 Melissa O'Neill and PCG Project contributors
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
+1 -6
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -683,12 +683,7 @@ typedef enum BcMode
#define BC_NO_SIG_EXC(vm) \
BC_LIKELY((vm)->status == (sig_atomic_t) BC_STATUS_SUCCESS && !(vm)->sig)
#ifndef _WIN32
#define BC_SIG_INTERRUPT(vm) \
BC_UNLIKELY((vm)->sig != 0 && (vm)->sig != SIGWINCH)
#else // _WIN32
#define BC_SIG_INTERRUPT(vm) BC_UNLIKELY((vm)->sig != 0)
#endif // _WIN32
#if BC_DEBUG
+1 -1
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
-42
View File
@@ -1,42 +0,0 @@
/*
* *****************************************************************************
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* *****************************************************************************
*
* The version of bc.
*
*/
#ifndef BC_VERSION_H
#define BC_VERSION_H
/// The current version.
#define VERSION 7.0.2
#endif // BC_VERSION_H
+1 -2
View File
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2018-2024 Gavin D. Howard and contributors.
* Copyright (c) 2018-2025 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -52,7 +52,6 @@
#endif // BC_ENABLE_NLS
#include <version.h>
#include <status.h>
#include <num.h>
#include <lex.h>
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+1 -1
View File
@@ -1,7 +1,7 @@
$ $
$ SPDX-License-Identifier: BSD-2-Clause
$ $
$ Copyright (c) 2018-2024 Gavin D. Howard and contributors.
$ Copyright (c) 2018-2025 Gavin D. Howard and contributors.
$ $
$ Redistribution and use in source and binary forms, with or without
$ modification, are permitted provided that the following conditions are met:
+2 -13
View File
@@ -1,7 +1,7 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2018-2024 Gavin D. Howard and contributors.
.\" Copyright (c) 2018-2025 Gavin D. Howard and contributors.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
@@ -2109,17 +2109,6 @@ If you want to a use signed two\[cq]s complement argument, use
\f[B]s2u(x)\f[R] to convert.
.RE
.TP
\f[B]bunrev(t)\f[R]
Assumes \f[B]t\f[R] is a bitwise\-reversed number with an extra set bit
one place more significant than the real most significant bit (which was
the least significant bit in the original number).
This number is reversed and returned without the extra set bit.
.RS
.PP
This function is used to implement other bitwise functions; it is not
meant to be used by users, but it can be.
.RE
.TP
\f[B]plz(x)\f[R]
If \f[B]x\f[R] is not equal to \f[B]0\f[R] and greater that
\f[B]\-1\f[R] and less than \f[B]1\f[R], it is printed with a leading
@@ -2943,7 +2932,7 @@ Before version \f[B]6.1.0\f[R], this bc(1) had incorrect behavior for
the \f[B]quit\f[R] statement.
.PP
No other bugs are known.
Report bugs at https://git.gavinhoward.com/gavin/bc .
Report bugs at https://github.com/gavinhoward/bc .
.SH AUTHORS
Gavin D. Howard \c
.MT [email protected]
+2 -12
View File
@@ -2,7 +2,7 @@
SPDX-License-Identifier: BSD-2-Clause
Copyright (c) 2018-2024 Gavin D. Howard and contributors.
Copyright (c) 2018-2025 Gavin D. Howard and contributors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -1766,16 +1766,6 @@ The extended library is a **non-portable extension**.
If you want to a use signed two's complement argument, use **s2u(x)** to
convert.
**bunrev(t)**
: Assumes **t** is a bitwise-reversed number with an extra set bit one place
more significant than the real most significant bit (which was the least
significant bit in the original number). This number is reversed and
returned without the extra set bit.
This function is used to implement other bitwise functions; it is not meant
to be used by users, but it can be.
**plz(x)**
: If **x** is not equal to **0** and greater that **-1** and less than **1**,
@@ -2521,7 +2511,7 @@ This bc(1) supports error messages for different locales, and thus, it supports
Before version **6.1.0**, this bc(1) had incorrect behavior for the **quit**
statement.
No other bugs are known. Report bugs at https://git.gavinhoward.com/gavin/bc .
No other bugs are known. Report bugs at https://github.com/gavinhoward/bc .
# AUTHORS
+2 -2
View File
@@ -1,7 +1,7 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2018-2024 Gavin D. Howard and contributors.
.\" Copyright (c) 2018-2025 Gavin D. Howard and contributors.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
@@ -1758,7 +1758,7 @@ Before version \f[B]6.1.0\f[R], this bc(1) had incorrect behavior for
the \f[B]quit\f[R] statement.
.PP
No other bugs are known.
Report bugs at https://git.gavinhoward.com/gavin/bc .
Report bugs at https://github.com/gavinhoward/bc .
.SH AUTHORS
Gavin D. Howard \c
.MT [email protected]
+2 -2
View File
@@ -2,7 +2,7 @@
SPDX-License-Identifier: BSD-2-Clause
Copyright (c) 2018-2024 Gavin D. Howard and contributors.
Copyright (c) 2018-2025 Gavin D. Howard and contributors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -1509,7 +1509,7 @@ This bc(1) supports error messages for different locales, and thus, it supports
Before version **6.1.0**, this bc(1) had incorrect behavior for the **quit**
statement.
No other bugs are known. Report bugs at https://git.gavinhoward.com/gavin/bc .
No other bugs are known. Report bugs at https://github.com/gavinhoward/bc .
# AUTHORS
+2 -2
View File
@@ -1,7 +1,7 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2018-2024 Gavin D. Howard and contributors.
.\" Copyright (c) 2018-2025 Gavin D. Howard and contributors.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
@@ -1731,7 +1731,7 @@ Before version \f[B]6.1.0\f[R], this bc(1) had incorrect behavior for
the \f[B]quit\f[R] statement.
.PP
No other bugs are known.
Report bugs at https://git.gavinhoward.com/gavin/bc .
Report bugs at https://github.com/gavinhoward/bc .
.SH AUTHORS
Gavin D. Howard \c
.MT [email protected]
+2 -2
View File
@@ -2,7 +2,7 @@
SPDX-License-Identifier: BSD-2-Clause
Copyright (c) 2018-2024 Gavin D. Howard and contributors.
Copyright (c) 2018-2025 Gavin D. Howard and contributors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -1483,7 +1483,7 @@ This bc(1) supports error messages for different locales, and thus, it supports
Before version **6.1.0**, this bc(1) had incorrect behavior for the **quit**
statement.
No other bugs are known. Report bugs at https://git.gavinhoward.com/gavin/bc .
No other bugs are known. Report bugs at https://github.com/gavinhoward/bc .
# AUTHORS
+2 -2
View File
@@ -1,7 +1,7 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2018-2024 Gavin D. Howard and contributors.
.\" Copyright (c) 2018-2025 Gavin D. Howard and contributors.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
@@ -1725,7 +1725,7 @@ Before version \f[B]6.1.0\f[R], this bc(1) had incorrect behavior for
the \f[B]quit\f[R] statement.
.PP
No other bugs are known.
Report bugs at https://git.gavinhoward.com/gavin/bc .
Report bugs at https://github.com/gavinhoward/bc .
.SH AUTHORS
Gavin D. Howard \c
.MT [email protected]
+2 -2
View File
@@ -2,7 +2,7 @@
SPDX-License-Identifier: BSD-2-Clause
Copyright (c) 2018-2024 Gavin D. Howard and contributors.
Copyright (c) 2018-2025 Gavin D. Howard and contributors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -1475,7 +1475,7 @@ use a period (**.**) as a radix point, regardless of the value of
Before version **6.1.0**, this bc(1) had incorrect behavior for the **quit**
statement.
No other bugs are known. Report bugs at https://git.gavinhoward.com/gavin/bc .
No other bugs are known. Report bugs at https://github.com/gavinhoward/bc .
# AUTHORS
+2 -2
View File
@@ -1,7 +1,7 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2018-2024 Gavin D. Howard and contributors.
.\" Copyright (c) 2018-2025 Gavin D. Howard and contributors.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
@@ -1752,7 +1752,7 @@ Before version \f[B]6.1.0\f[R], this bc(1) had incorrect behavior for
the \f[B]quit\f[R] statement.
.PP
No other bugs are known.
Report bugs at https://git.gavinhoward.com/gavin/bc .
Report bugs at https://github.com/gavinhoward/bc .
.SH AUTHORS
Gavin D. Howard \c
.MT [email protected]
+2 -2
View File
@@ -2,7 +2,7 @@
SPDX-License-Identifier: BSD-2-Clause
Copyright (c) 2018-2024 Gavin D. Howard and contributors.
Copyright (c) 2018-2025 Gavin D. Howard and contributors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -1501,7 +1501,7 @@ use a period (**.**) as a radix point, regardless of the value of
Before version **6.1.0**, this bc(1) had incorrect behavior for the **quit**
statement.
No other bugs are known. Report bugs at https://git.gavinhoward.com/gavin/bc .
No other bugs are known. Report bugs at https://github.com/gavinhoward/bc .
# AUTHORS
+2 -13
View File
@@ -1,7 +1,7 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2018-2024 Gavin D. Howard and contributors.
.\" Copyright (c) 2018-2025 Gavin D. Howard and contributors.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
@@ -2109,17 +2109,6 @@ If you want to a use signed two\[cq]s complement argument, use
\f[B]s2u(x)\f[R] to convert.
.RE
.TP
\f[B]bunrev(t)\f[R]
Assumes \f[B]t\f[R] is a bitwise\-reversed number with an extra set bit
one place more significant than the real most significant bit (which was
the least significant bit in the original number).
This number is reversed and returned without the extra set bit.
.RS
.PP
This function is used to implement other bitwise functions; it is not
meant to be used by users, but it can be.
.RE
.TP
\f[B]plz(x)\f[R]
If \f[B]x\f[R] is not equal to \f[B]0\f[R] and greater that
\f[B]\-1\f[R] and less than \f[B]1\f[R], it is printed with a leading
@@ -2916,7 +2905,7 @@ Before version \f[B]6.1.0\f[R], this bc(1) had incorrect behavior for
the \f[B]quit\f[R] statement.
.PP
No other bugs are known.
Report bugs at https://git.gavinhoward.com/gavin/bc .
Report bugs at https://github.com/gavinhoward/bc .
.SH AUTHORS
Gavin D. Howard \c
.MT [email protected]
+2 -12
View File
@@ -2,7 +2,7 @@
SPDX-License-Identifier: BSD-2-Clause
Copyright (c) 2018-2024 Gavin D. Howard and contributors.
Copyright (c) 2018-2025 Gavin D. Howard and contributors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -1766,16 +1766,6 @@ The extended library is a **non-portable extension**.
If you want to a use signed two's complement argument, use **s2u(x)** to
convert.
**bunrev(t)**
: Assumes **t** is a bitwise-reversed number with an extra set bit one place
more significant than the real most significant bit (which was the least
significant bit in the original number). This number is reversed and
returned without the extra set bit.
This function is used to implement other bitwise functions; it is not meant
to be used by users, but it can be.
**plz(x)**
: If **x** is not equal to **0** and greater that **-1** and less than **1**,
@@ -2495,7 +2485,7 @@ This bc(1) supports error messages for different locales, and thus, it supports
Before version **6.1.0**, this bc(1) had incorrect behavior for the **quit**
statement.
No other bugs are known. Report bugs at https://git.gavinhoward.com/gavin/bc .
No other bugs are known. Report bugs at https://github.com/gavinhoward/bc .
# AUTHORS
+2 -13
View File
@@ -1,7 +1,7 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2018-2024 Gavin D. Howard and contributors.
.\" Copyright (c) 2018-2025 Gavin D. Howard and contributors.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
@@ -2109,17 +2109,6 @@ If you want to a use signed two\[cq]s complement argument, use
\f[B]s2u(x)\f[R] to convert.
.RE
.TP
\f[B]bunrev(t)\f[R]
Assumes \f[B]t\f[R] is a bitwise\-reversed number with an extra set bit
one place more significant than the real most significant bit (which was
the least significant bit in the original number).
This number is reversed and returned without the extra set bit.
.RS
.PP
This function is used to implement other bitwise functions; it is not
meant to be used by users, but it can be.
.RE
.TP
\f[B]plz(x)\f[R]
If \f[B]x\f[R] is not equal to \f[B]0\f[R] and greater that
\f[B]\-1\f[R] and less than \f[B]1\f[R], it is printed with a leading
@@ -2910,7 +2899,7 @@ Before version \f[B]6.1.0\f[R], this bc(1) had incorrect behavior for
the \f[B]quit\f[R] statement.
.PP
No other bugs are known.
Report bugs at https://git.gavinhoward.com/gavin/bc .
Report bugs at https://github.com/gavinhoward/bc .
.SH AUTHORS
Gavin D. Howard \c
.MT [email protected]
+2 -12
View File
@@ -2,7 +2,7 @@
SPDX-License-Identifier: BSD-2-Clause
Copyright (c) 2018-2024 Gavin D. Howard and contributors.
Copyright (c) 2018-2025 Gavin D. Howard and contributors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -1766,16 +1766,6 @@ The extended library is a **non-portable extension**.
If you want to a use signed two's complement argument, use **s2u(x)** to
convert.
**bunrev(t)**
: Assumes **t** is a bitwise-reversed number with an extra set bit one place
more significant than the real most significant bit (which was the least
significant bit in the original number). This number is reversed and
returned without the extra set bit.
This function is used to implement other bitwise functions; it is not meant
to be used by users, but it can be.
**plz(x)**
: If **x** is not equal to **0** and greater that **-1** and less than **1**,
@@ -2487,7 +2477,7 @@ use a period (**.**) as a radix point, regardless of the value of
Before version **6.1.0**, this bc(1) had incorrect behavior for the **quit**
statement.
No other bugs are known. Report bugs at https://git.gavinhoward.com/gavin/bc .
No other bugs are known. Report bugs at https://github.com/gavinhoward/bc .
# AUTHORS
+2 -13
View File
@@ -1,7 +1,7 @@
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2018-2024 Gavin D. Howard and contributors.
.\" Copyright (c) 2018-2025 Gavin D. Howard and contributors.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
@@ -2109,17 +2109,6 @@ If you want to a use signed two\[cq]s complement argument, use
\f[B]s2u(x)\f[R] to convert.
.RE
.TP
\f[B]bunrev(t)\f[R]
Assumes \f[B]t\f[R] is a bitwise\-reversed number with an extra set bit
one place more significant than the real most significant bit (which was
the least significant bit in the original number).
This number is reversed and returned without the extra set bit.
.RS
.PP
This function is used to implement other bitwise functions; it is not
meant to be used by users, but it can be.
.RE
.TP
\f[B]plz(x)\f[R]
If \f[B]x\f[R] is not equal to \f[B]0\f[R] and greater that
\f[B]\-1\f[R] and less than \f[B]1\f[R], it is printed with a leading
@@ -2937,7 +2926,7 @@ Before version \f[B]6.1.0\f[R], this bc(1) had incorrect behavior for
the \f[B]quit\f[R] statement.
.PP
No other bugs are known.
Report bugs at https://git.gavinhoward.com/gavin/bc .
Report bugs at https://github.com/gavinhoward/bc .
.SH AUTHORS
Gavin D. Howard \c
.MT [email protected]
Loaded 100 of 3235 files, more files were not shown because too many files have changed in this diff. Show more