FreeBSD/src d582187contrib/file/magic/Magdir archive firmware, contrib/file/src readelf.c funcs.c

MFV: file 5.47.

(cherry picked from commit e949ce9dc0e6fff26e83904f1008b76d36ba0a37)

file: normalize .result files to ensure trailing newline on install

Some upstream result files introduced in file 5.47 (e.g., bgcode.result)
lack a trailing newline, causing the contrib_file_tests ATF test to
fail with "cmp: EOF on bgcode.result".  Generate normalized copies
of the expected results and install those instead.

Fixes:          e949ce9dc0e6fff26e83904f1008b76d36ba0a37

(cherry picked from commit f7c0bd206fe4f3a956b3ecb4dc11a7386b85fa22)
DeltaFile
+143-74contrib/file/magic/Magdir/archive
+109-96contrib/file/src/readelf.c
+140-5contrib/file/magic/Magdir/firmware
+112-0contrib/file/magic/Magdir/sf3
+77-26contrib/file/src/funcs.c
+101-1contrib/file/magic/Magdir/database
+682-20278 files not shown
+2,054-59784 files

FreeBSD/src 5f5fd36contrib/file/magic/Magdir archive firmware, contrib/file/src readelf.c funcs.c

MFV: file 5.47.

(cherry picked from commit e949ce9dc0e6fff26e83904f1008b76d36ba0a37)

file: normalize .result files to ensure trailing newline on install

Some upstream result files introduced in file 5.47 (e.g., bgcode.result)
lack a trailing newline, causing the contrib_file_tests ATF test to
fail with "cmp: EOF on bgcode.result".  Generate normalized copies
of the expected results and install those instead.

Fixes:          e949ce9dc0e6fff26e83904f1008b76d36ba0a37

(cherry picked from commit f7c0bd206fe4f3a956b3ecb4dc11a7386b85fa22)
DeltaFile
+143-74contrib/file/magic/Magdir/archive
+109-96contrib/file/src/readelf.c
+140-5contrib/file/magic/Magdir/firmware
+112-0contrib/file/magic/Magdir/sf3
+77-26contrib/file/src/funcs.c
+101-1contrib/file/magic/Magdir/database
+682-20278 files not shown
+2,054-59784 files

FreeBSD/src 94d7f7erelease Makefile.gce

GCE: Apply public-image label on GCE images

Update the GCE image creation process to automatically apply the
'public-image=true' label when publishing new images. This aligns
with standard labeling expectations for images hosted in public
projects.

(cherry picked from commit c85542b92acd286d9e4b034b2ab4d6b6cd46c740)
DeltaFile
+1-0release/Makefile.gce
+1-01 files

FreeBSD/src 6c2ea28release Makefile.gce

GCE: Apply public-image label on GCE images

Update the GCE image creation process to automatically apply the
'public-image=true' label when publishing new images. This aligns
with standard labeling expectations for images hosted in public
projects.

(cherry picked from commit c85542b92acd286d9e4b034b2ab4d6b6cd46c740)
DeltaFile
+1-0release/Makefile.gce
+1-01 files

FreeBSD/src 22d6695usr.sbin/ifmcstat ifmcstat.8 ifmcstat.c

ifmcstat: Fixup getopt args to match reality.

Reviewed by:    emaste
Fixes:          ad0e698e642e ("ifmcstat: remove libkvm(3) code")
Event:          BSDCan 2026
DeltaFile
+0-3usr.sbin/ifmcstat/ifmcstat.8
+1-1usr.sbin/ifmcstat/ifmcstat.c
+1-42 files

FreeBSD/src 640ddf8sys/sys stdatomic.h

libc: Enforce lock-free atomic_flag and C23-safe initialisation

Select the `atomic_flag` backing type according to the C standard
requirements that `atomic_flag` operations be lock-free.

C11 §7.17.1.5 defines `atomic_flag` as:

> a structure type representing a lock-free, primitive atomic flag

and §7.17.8.2 further requires:

> Operations on an object of type atomic_flag shall be lock free

Therefore:

- Prefer `atomic_bool` when `ATOMIC_BOOL_LOCK_FREE == 2`
- Fall back to `atomic_uchar` when `ATOMIC_CHAR_LOCK_FREE == 2`
- Trigger a translation failure if neither type is lock-free


    [13 lines not shown]
DeltaFile
+12-4sys/sys/stdatomic.h
+12-41 files

FreeBSD/src 0f8941ftools/regression/include/stdatomic logic.c

tools/regression: Expand stdatomic conformance tests

Extend the existing test utility to cover recent stdatomic
changes and improve validation of interface semantics,
compile-time assertions, and behavioural conformance.

Signed-off-by: Faraz Vahedi <kfv at kfv.io>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/2185
DeltaFile
+109-0tools/regression/include/stdatomic/logic.c
+109-01 files

FreeBSD/src 26bf9fcsys/sys stdatomic.h

libc: Fix GCC pointer semantics for atomic_fetch_add/sub

Correct the GCC implementation of `atomic_fetch_add_explicit()`
and `atomic_fetch_sub_explicit()` for atomic pointer types.

The previous implementation passed the operand directly to the
builtins. For pointer objects, this could result in raw byte-wise
address arithmetic rather than the required C atomic pointer
semantics, where the operand is interpreted as a `ptrdiff_t`
element count.

As a result, operations such as `atomic_fetch_sub_explicit(&p, 2, ...)`
could produce an incorrect post-operation pointer value.

Fix this by applying pointer scaling in the GCC path before invoking
the builtin, mirroring the existing legacy fallback implementation.
Pointer operands are now scaled by the size of the pointed-to type,
while integer atomic behaviour remains unchanged.


    [3 lines not shown]
DeltaFile
+6-2sys/sys/stdatomic.h
+6-21 files

FreeBSD/src 54ac231sys/sys stdatomic.h

libc: Fix atomic_init for GCC atomic objects

Add a dedicated `__GNUC_ATOMICS` path that initialises via
`atomic_store_explicit(obj, value, memory_order_relaxed)`.

This ensures the required initialisation semantics without
assuming any particular object representation.

Previously, `atomic_init` on GCC fell through to the legacy
`__val` member path intended only for old struct-backed
atomic objects. For current atomic objects, this caused the
following compilation error:

> error: request for member '__val' in something not a
  structure or union

As a result, valid code such as `atomic_init(&x, 1)` failed
to compile when using GCC.


    [6 lines not shown]
DeltaFile
+3-0sys/sys/stdatomic.h
+3-01 files

FreeBSD/src cb88e7bsys/sys stdatomic.h

libc: Reorder atomic operations to match ISO C standard

Reorder definitions of specified generic operations on atomic types
so they follow the sequence in ISO/IEC 9899:2024 §7.17.7:

1. `atomic_store`
2. `atomic_load`
3. `atomic_exchange`
4. `atomic_compare_exchange`
5. `atomic_fetch`

This aligns the header layout with the standard, making it easier
to cross-check against the normative text and maintain consistency
with the rest of the header.

The behaviour of the macros remains unchanged; this is purely a
reorganisation and documentation improvement.

Signed-off-by: Faraz Vahedi <kfv at kfv.io>

    [2 lines not shown]
DeltaFile
+50-50sys/sys/stdatomic.h
+50-501 files

FreeBSD/src 9d87c1asys/sys stdatomic.h

libc: Add missing kill_dependency macro

Add `kill_dependency` as specified by C11 §7.17.3.1.

The macro is required to break dependency chains in
expressions without affecting the value.

No functional impact beyond providing the required,
value-preserving definition.

Signed-off-by: Faraz Vahedi <kfv at kfv.io>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/2185
DeltaFile
+2-0sys/sys/stdatomic.h
+2-01 files

FreeBSD/src 4b14655sys/contrib/dev/rtw88 main.c

rtw88: Fix typo in portability glue

Fix typo in if statement for compiling rtw88 against a Linux target.

Signed-off-by: Lambert Lim <lambert at sanesecurityguy.com>
Reviewed by: imp,ziaee
Pull Request: https://github.com/freebsd/freebsd-src/pull/2262
DeltaFile
+1-1sys/contrib/dev/rtw88/main.c
+1-11 files

FreeBSD/src 28cecfesys/sys stdatomic.h

libc: Restrict ATOMIC_VAR_INIT for C23 conformance

Omit `ATOMIC_VAR_INIT` when targeting C23, where it has been removed.
Retain it for earlier C standards and for C++ (as it still remains in
C++23, albeit marked as deprecated since C17 and C++20.)

Also separate `atomic_init` definitions from `ATOMIC_VAR_INIT` to
avoid coupling with a deprecated initialisation mechanism.

No functional change intended for `atomic_init`; this is purely a
conformance and cleanup adjustment.

Signed-off-by: Faraz Vahedi <kfv at kfv.io>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/2185
DeltaFile
+7-1sys/sys/stdatomic.h
+7-11 files

FreeBSD/src e17fddcsys/sys stdatomic.h

libc: Reorganise memory_order enumeration constants

Place the `memory_order` enumeration constants alongside the corresponding
typedef under the §7.17.3 heading.

The previous layout separated the fallback constant definitions from the
enum, which could obscure their relationship. These fallbacks exist only
to provide values when the compiler does not supply the builtins.

The removed comment encoded implementation-specific assumptions about
compiler-provided definitions and implied a relationship between Clang/GCC
macros and fallback values. In practice, the fallback definitions exist
solely to ensure the enumerators are defined when compiler intrinsics are
absent, and do not depend on any particular numeric mapping.

No functional change; this is a mere structural and clarity improvement.

Signed-off-by: Faraz Vahedi <kfv at kfv.io>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/2185
DeltaFile
+4-10sys/sys/stdatomic.h
+4-101 files

FreeBSD/src 85becdasys/sys stdatomic.h

libc: Add atomics C23 feature test macro

Signed-off-by: Faraz Vahedi <kfv at kfv.io>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/2185
DeltaFile
+3-3sys/sys/stdatomic.h
+3-31 files

FreeBSD/src 255538clib/libc/powerpc64 _fpmath.h, lib/libcompiler_rt Makefile.inc comparekf2.c

powerpc64le: switch long double to IEEE binary128

Change powerpc64le's long double from 64-bit double to IEEE 754
binary128 (quad, 113-bit mantissa), matching aarch64 and riscv64.

Gated on FreeBSD 16 and powerpc64le only.

Differential Revision: https://reviews.freebsd.org/D57388
Reviewed by:    adrian
Relnotes:       yes
DeltaFile
+59-0lib/libcompiler_rt/Makefile.inc
+43-0lib/msun/powerpc/ld128_compat.c
+43-0lib/libcompiler_rt/comparekf2.c
+36-0lib/msun/powerpc/Symbol_f128.map
+24-5lib/libc/powerpc64/_fpmath.h
+17-0sys/powerpc/include/float.h
+222-515 files not shown
+292-2021 files

FreeBSD/src 7386c06share/mk dirdeps.mk meta2deps.py

Update dirdpes.mk et al

Update to latest dirdeps related makefiles.

dirdeps.mk tweaks useful for universe among other corner cases.
           also additional filtering for bogus paths ending in /

gendirdeps.mk allow more debugging
           also additional filtering for bogus paths ending in /

install-new.mk fix bug when isPOSIX_SHELL is true

meta2deps.?? handle file names with spaces by ignoring them

Reviewed by: stevek
Differential Revision:  https://reviews.freebsd.org/D57683
DeltaFile
+19-9share/mk/dirdeps.mk
+16-9share/mk/meta2deps.py
+13-2share/mk/meta2deps.sh
+10-4share/mk/gendirdeps.mk
+2-2share/mk/install-new.mk
+60-265 files

FreeBSD/src 389c124sys/kern imgact_elf.c kern_exec.c, sys/sys imgact.h

imgact_elf.c indicate that interpreter is an interpreter

Use a value that do_execve will ignore since there's nothing there to do.
With this we can set the 'indirect' flag on rtld, to prevent direct execution
being used to bypass the 'indirect' flag on python3:

root at vuefi:~ # /libexec/ld-elf32.so.1 /usr/bin/python3 -c 'print("pwned")'
pwned
root at vuefi:~ # veriexec -z enforce
root at vuefi:~ # /libexec/ld-elf32.so.1 /usr/bin/python3 -c 'print("pwned")'
/libexec/ld-elf32.so.1: Operation not permitted.
root at vuefi:~ #

load_file seems missnamed since it is only used by load_interp
so rename it to load_interp_file.

Reviewed by:    imp
Sponsored by:   Hewlett Packard Enterprise Development LP
Differential Revision:  https://reviews.freebsd.org/D57649
DeltaFile
+6-5sys/kern/imgact_elf.c
+2-1sys/kern/kern_exec.c
+1-0sys/sys/imgact.h
+9-63 files

FreeBSD/src 9fd0c7cshare/man/man4 thunderbolt.4

thunderbolt.4: Explain what driver does in manpage

Reviewed by:    ziaee, ngie
Approved by:    ziaee
Fixes:  2f7a796b590e ("thunderbolt.4: Initial manual for HW Relnotes")
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D57668
DeltaFile
+45-6share/man/man4/thunderbolt.4
+45-61 files

FreeBSD/src b3dfd5dbin/rmdir rmdir.1

rmdir.1: Document non-POSIX -v option

MFC after:              3 days
Reviewed by:            ziaee
Differential Revision:  https://reviews.freebsd.org/D57675
DeltaFile
+5-1bin/rmdir/rmdir.1
+5-11 files

FreeBSD/src e91e8ebsys/kern kern_jail.c

jail: call PR_METHOD_ATTACH again (with old jail) if the first call fails

jail_attach lets modules do attachment-specific work by calling
osd_jail_call(PR_METHOD_ATTACH).  If one of the modules returns an
error, the call needs to be repeated with the thread's current prison,
so possible earlier modules and undo any changes they may have made.

MFC after:      5 days
DeltaFile
+6-6sys/kern/kern_jail.c
+6-61 files

FreeBSD/src 9919c1asys/dev/firewire fw_net.h if_fwip.c

firewire: extract shared helpers from fwe and fwip

Add fw_net.h with common inline helpers used by both if_fwe and
if_fwip: ISO chunk init, TX xfer allocation, xferlist free,
send queue drain, and DEVICE_POLLING ioctl handling.

Reviewed by:    imp
Differential Revision:  https://reviews.freebsd.org/D57615
DeltaFile
+109-0sys/dev/firewire/fw_net.h
+10-50sys/dev/firewire/if_fwip.c
+9-45sys/dev/firewire/if_fwe.c
+128-953 files

FreeBSD/src 2db353eshare/man/man9 cdefs.9, sys/compat/linuxkpi/common/include/linux compiler_attributes.h

sys/cdefs.h: Introduce __maybe_unused attribute

The __maybe_unused attribute should be used for variables which may or
may not be used, such as when their only use is in an assertion. This
attribute is functionally identical to __unused, suppressing compiler
warnings for particular variable if it remains unused.

Reviewed by:    Minsoo Choo <minsoo at minsoo.io>, imp
Differential Revision:  https://reviews.freebsd.org/D56517

(cherry picked from commit 84a95741805d84f0074a34d61b93ccf86f422cf3)
DeltaFile
+4-2share/man/man9/cdefs.9
+1-0sys/sys/cdefs.h
+0-1sys/compat/linuxkpi/common/include/linux/compiler_attributes.h
+5-33 files

FreeBSD/src 5ca5b57libexec/rc/rc.d routing

rc.d/routing: Silence errors for loopback routes

_loopback entry in `static_routes` ensures a loopback route
exists in all routing tables.
However, loopback routes may already be added by the kernel.
Therefore, re-adding them triggers an `EEXIST` error on every boot.
This change suppresses those harmless errors.

PR:             259553
MFC after:      1 week
Reviewed by:    glebius, jlduran, markj
Differential Revision:  https://reviews.freebsd.org/D57470

(cherry picked from commit 9f80c8b90bdaa8ffac887a8c478a16c84d74a87b)
DeltaFile
+16-3libexec/rc/rc.d/routing
+16-31 files

FreeBSD/src 8fd4d1cetc/mtree BSD.tests.dist, tests/sys/fs Makefile

tests: Add pjdfstest integration

Use ATF to wrap the new reimplementation of pjdfstest that came out of
GSOC 2022, now available in the ports tree as filesystems/pjdfstest.

So far I added tests for UFS (with several different option
combinations), tmpfs and ZFS, plus ZFS+nullfs.  All of these create a
memory disk, initialize the filesystem, and point the pjdfstest
executable at it.

In the future it would be good to add tests for at least NFS and p9fs.

Reviewed by:    asomers
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D56605
DeltaFile
+130-0tests/sys/fs/pjdfstest/ufs.sh
+96-0tests/sys/fs/pjdfstest/zfs.sh
+60-0tests/sys/fs/pjdfstest/tmpfs.sh
+12-0tests/sys/fs/pjdfstest/Makefile
+2-0etc/mtree/BSD.tests.dist
+1-0tests/sys/fs/Makefile
+301-06 files

FreeBSD/src d7c1106lib/libc/gen ctermid.c

ctermid(3): Fix return

Reported by:    bnovkov
Fixes:  dc24f31b67f5 ("ctermid(3): Fix return values section")
Sponsored by:   Klara, Inc.
DeltaFile
+1-1lib/libc/gen/ctermid.c
+1-11 files

FreeBSD/src dc24f31lib/libc/gen ctermid.3 ctermid.c

ctermid(3): Fix return values section

ctermid() doesn't, and has never, set errno.

While here, add ctermid_r to the name section and align the parameter
name in the source file.

Reviewed by:    bnovkov
Approved by:    bnovkov
MFC after:      3 days
Obtained from:  https://github.com/apple-oss-distributions/libc
Sponsored by:   Klara, Inc.
Differential Revision:  https://reviews.freebsd.org/D57396
DeltaFile
+15-10lib/libc/gen/ctermid.3
+7-7lib/libc/gen/ctermid.c
+22-172 files

FreeBSD/src 1665954sys/dev/uart uart_dev_ns8250.c

uart: Add support for the Intel XScale controller

The ns8250 driver avoids clearing IER bit 0x10 to account for the
split "receiver time-out interrupt enable" bit, but it never sets
it in `ier_rxbits` even though a comment in `ns8250_init` implies so.

Fix this by setting `IER_RXTMOUT` if we've matched an XScale uart.

Differential Revision:  https://reviews.freebsd.org/D57629
Reviewed by:    imp
MFC after:      2 weeks
DeltaFile
+7-0sys/dev/uart/uart_dev_ns8250.c
+7-01 files

FreeBSD/src d735666share/man/man4 rtnetlink.4, sys/netlink/route interface.h

netlink: Indicate that ifinfomsg uses IFT_* types

On Linux struct ifinfomsg uses ARPHRD_* values, while we used IFT_*
types (which derive from SNMP ifType definitions in RFC 1573).
Update the header to reflect this.

PR:             272144
Reviewed by:    pouria
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57334

(cherry picked from commit 21a75a85f0e0cc328b6e9b437d783ef0c25dc52e)
(cherry picked from commit 76f29211f0dde8907250b77def3e58082e03afe1)
DeltaFile
+16-3share/man/man4/rtnetlink.4
+2-2sys/netlink/route/interface.h
+18-52 files

FreeBSD/src 76f2921share/man/man4 rtnetlink.4, sys/netlink/route interface.h

netlink: Indicate that ifinfomsg uses IFT_* types

On Linux struct ifinfomsg uses ARPHRD_* values, while we used IFT_*
types (which derive from SNMP ifType definitions in RFC 1573).
Update the header to reflect this.

PR:             272144
Reviewed by:    pouria
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57334

(cherry picked from commit 21a75a85f0e0cc328b6e9b437d783ef0c25dc52e)
DeltaFile
+15-2share/man/man4/rtnetlink.4
+2-2sys/netlink/route/interface.h
+17-42 files