HardenedBSD/src 663efd8lib/libc/gen rtld_get_var.3, lib/msun/arm fenv.c

Merge remote-tracking branch 'origin/hardened/current/master' into hardened/current/cross-dso-cfi
DeltaFile
+152-36libexec/rtld-elf/rtld.c
+38-0libexec/rtld-elf/tests/set_var_test.c
+14-7sys/x86/x86/cpu_machdep.c
+17-0lib/libc/gen/rtld_get_var.3
+6-3sys/x86/x86/tsc.c
+6-1lib/msun/arm/fenv.c
+233-4711 files not shown
+286-5917 files

HardenedBSD/src 381a8e7lib/libc/gen rtld_get_var.3, lib/msun/riscv fenv.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+152-36libexec/rtld-elf/rtld.c
+38-0libexec/rtld-elf/tests/set_var_test.c
+14-7sys/x86/x86/cpu_machdep.c
+17-0lib/libc/gen/rtld_get_var.3
+6-3sys/x86/x86/tsc.c
+6-1lib/msun/riscv/fenv.c
+233-4711 files not shown
+286-5917 files

HardenedBSD/src f7b368dlib/libc/gen rtld_get_var.3

rtld_get_var(3): provide explicit list of rtld vars that can be modified

Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D56055
DeltaFile
+17-0lib/libc/gen/rtld_get_var.3
+17-01 files

HardenedBSD/src b9f046dlibexec/rtld-elf rtld.c

rtld: properly handle update of several vars in rtld_set_var()

Besides setting the value in the array of the values, rtld sometimes
needs to recalculate some internal control variable for the change to
take effect.  Allow the variable description to supply a method called
on the update.  Lock the function with the bind lock for safe operation.

Mark several variables as allowed for update, since the on_update method
is provided for them.  The list is LD_BIND_NOW, LD_BIND_NOT,
LD_LIBMAP_DISABLE, LD_LOADFLTR.

Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D56055
DeltaFile
+152-36libexec/rtld-elf/rtld.c
+152-361 files

HardenedBSD/src 9f16078libexec/rtld-elf/tests set_var_test.c Makefile

rtld: add a test for rtld_set_var (with LIBRARY_PATH_FDS)

PR:     294054
Reviewed by:    kib
MFC after:      1 week
DeltaFile
+38-0libexec/rtld-elf/tests/set_var_test.c
+1-0libexec/rtld-elf/tests/Makefile
+39-02 files

HardenedBSD/src f39754dlib/msun/aarch64 fenv.c fenv.h, lib/msun/amd64 fenv.c

fenv.h: stop declaring feclearexcept() extern inline

The function is already exported from libm.  We only need to stop
declare it extern inline, and instead provide a macro which uses the
internal inline function __feclearexcept_int() instead.

PR:     277958
Reviewed by:    dim (x86)
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D55975
DeltaFile
+5-2lib/msun/x86/fenv.h
+6-1lib/msun/aarch64/fenv.c
+5-2lib/msun/aarch64/fenv.h
+6-1lib/msun/amd64/fenv.c
+6-1lib/msun/arm/fenv.c
+6-1lib/msun/i387/fenv.c
+34-85 files not shown
+58-1311 files

HardenedBSD/src 7e7d4e7sys/x86/x86 cpu_machdep.c tsc.c

x86: Handle when MPERF/APERF MSRs aren't writable

For performance and/or correct reasons some hypervisors allow
MPERF/APERF MSRs to be read but not written to. This change
modifies the handling of these MSRs to not rely on writes.
This patch is part of Google Cloud Engine (GCE) C4-LSSD turnup.

Sponsored by:           Google
Tested by:              NetApp (previous)
PR:                     292808
MFC after:              3 days
Co-authored-by:         Jim Mattson <jmattson at google.com>
Reviewed by:            jrtc27, imp, kib, markj, olce, obiwac
Differential Revision:  https://reviews.freebsd.org/D55996
DeltaFile
+7-7sys/x86/x86/cpu_machdep.c
+6-3sys/x86/x86/tsc.c
+13-102 files

HardenedBSD/src c505fc1sys/x86/x86 cpu_machdep.c

x86: Guard clock frequency against a divide by 0

We may be running in a Virtual Machine which may not fully support
hardware performance counters. If the MPERF counter somehow ends up
at zero, return an error and fail gracefully instead of panicking.
This patch is part of Google Cloud Engine (GCE) C4-LSSD turnup.

Sponsored by:           Google
Tested by:              NetApp (previous)
PR:                     292808
MFC after:              3 days
Co-authored-by:         Aymeric Wibo <obiwac at google.com>
Co-authored-by:         Jim Mattson <jmattson at google.com>
Suggested by:           jrtc27 (split out this part)
Reviewed by:            imp, obiwac, olce
Differential Revision:  https://reviews.freebsd.org/D56056
DeltaFile
+8-1sys/x86/x86/cpu_machdep.c
+8-11 files

HardenedBSD/src e17b011lib/libc/amd64/string strrchr.S, lib/libsys kldload.2

Merge remote-tracking branch 'origin/hardened/current/master' into hardened/current/cross-dso-cfi
DeltaFile
+15-2lib/libsys/kldload.2
+4-4lib/libc/amd64/string/strrchr.S
+3-3sbin/dmesg/dmesg.8
+2-4usr.sbin/syslogd/syslog.conf.5
+3-3share/man/man7/hier.7
+2-4usr.sbin/newsyslog/newsyslog.conf.5
+29-203 files not shown
+35-259 files

HardenedBSD/src 89606calib/libc/amd64/string strrchr.S, lib/libsys kldload.2

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+15-2lib/libsys/kldload.2
+4-4lib/libc/amd64/string/strrchr.S
+3-3sbin/dmesg/dmesg.8
+2-4usr.sbin/newsyslog/newsyslog.conf.5
+2-4usr.sbin/syslogd/syslog.conf.5
+3-3share/man/man7/hier.7
+29-203 files not shown
+35-259 files

HardenedBSD/src 7a86177sys/fs/fuse fuse_node.h, tests/sys/fs/fusefs read.cc bmap.cc

Merge branch 'freebsd/15-stable/main' into hardened/15-stable/main
DeltaFile
+309-0tests/sys/kern/pdwait.c
+192-0tests/sys/fs/fusefs/read.cc
+109-8tests/sys/fs/fusefs/bmap.cc
+98-0tests/sys/kern/procdesc.c
+80-11sys/fs/fuse/fuse_node.h
+90-0tests/sys/fs/fusefs/rename.cc
+878-1913 files not shown
+1,113-8519 files

HardenedBSD/src 4b16ff4tests/sys/kern timerfd.c

timerfd: Guard expected performance failure

During the timerfd__periodic_timer_performance test, only expect
failures when the expiration count is less than 400000000. This
prevents the test from being reported as a true failure in environments
where scheduling latency is high enough to delay timerfd wakeups.

Fixes:          cb692380f1e0 ("timerfd: Expect periodic timer ...")
MFC after:      1 week
DeltaFile
+2-1tests/sys/kern/timerfd.c
+2-11 files

HardenedBSD/src 6a1ebd1sys/fs/fuse fuse_node.h fuse_node.c, tests/sys/fs/fusefs read.cc rename.cc

fusefs: redo vnode attribute locking

Previously most fields in fuse_vnode_data were protected by the vnode
lock.  But because DEBUG_VFS_LOCKS was never enabled by default until
stable/15 the assertions were never checked, and many were wrong.
Others were missing.  This led to panics in stable/15 and 16.0-CURRENT,
when a vnode was expected to be exclusively locked but wasn't, for fuse
file systems that mount with "-o async".

In some places it isn't possible to exclusively lock the vnode when
accessing these fields.  So protect them with a new mutex instead.  This
fixes panics and unprotected field accesses in VOP_READ,
VOP_COPY_FILE_RANGE, VOP_GETATTR, VOP_BMAP, and FUSE_NOTIFY_INVAL_ENTRY.
Add assertions everywhere the protected fields are accessed.

Lock the vnode exclusively when handling FUSE_NOTIFY_INVAL_INODE.

During fuse_vnode_setsize, if the vnode isn't already exclusively
locked, use the vn_delayed_setsize mechanism.  This fixes panics during

    [14 lines not shown]
DeltaFile
+192-0tests/sys/fs/fusefs/read.cc
+80-11sys/fs/fuse/fuse_node.h
+90-0tests/sys/fs/fusefs/rename.cc
+71-18sys/fs/fuse/fuse_node.c
+74-7sys/fs/fuse/fuse_vnops.c
+24-18sys/fs/fuse/fuse_internal.c
+531-545 files not shown
+609-7911 files

HardenedBSD/src 9ac21f8tests/sys/fs/fusefs bmap.cc

fusefs: add a regression test for a cluster_read bug

VOP_BMAP is purely advisory.  If VOP_BMAP returns an error during
readahead, cluster_read should still succeed, because the actual data
was still read just fine.

Add a regression test for PR 264196, wherein cluster_read would fail if
VOP_BMAP did.

PR:             264196
Reported by:    danfe
Reviewed by:    arrowd
Differential Revision: https://reviews.freebsd.org/D51316

(cherry picked from commit 6d408ac490730614b3ed0ebd3caffcd23f303fb4)
DeltaFile
+87-0tests/sys/fs/fusefs/bmap.cc
+87-01 files

HardenedBSD/src 1ebccc3sys/kern vfs_cluster.c

vfs_cluster.c: Do not propagate VOP_BMAP errors to the caller

The code that makes this VOP_BMAP call tries to perform a read-ahead I/O
operation. Failing to do that for any reason isn't fatal for `cluster_read()`,
because we still can return some data to the caller. This change is consistent
with other places within `cluster_read()`, where error returned by VOP_BMAP is
not returned to the caller - see the `if (nblks > 1)` block above the changed
lines and `if (reqbp)` at the end of the function.

PR:     264196
Approved by:    markj, kib
Differential Revision: https://reviews.freebsd.org/D51254

(cherry picked from commit 62aef3f73f38db9fb68bffc12cc8900fecd58f0e)
DeltaFile
+3-1sys/kern/vfs_cluster.c
+3-11 files

HardenedBSD/src d069250sys/fs/fuse fuse_ipc.c fuse_ipc.h

fusefs: remove the obsolete rename_lock

This lock was included in the original GSoC submission.  Its purpose
seems to have been to prevent concurrent FUSE_RENAME operations for the
current mountpoint, as well as to synchronize FUSE_RENAME with
fuse_vnode_setparent.  But it's obsolete, now that ef6ea91593e added
mnt_renamelock .

Sponsored by:   ConnectWise
Reviewed by:    kib
Differential Revision: https://reviews.freebsd.org/D55231

(cherry picked from commit 7755a406a6ae3801e885a79f714155f97c4d2bc6)
DeltaFile
+0-2sys/fs/fuse/fuse_ipc.c
+0-2sys/fs/fuse/fuse_ipc.h
+0-2sys/fs/fuse/fuse_vnops.c
+0-63 files

HardenedBSD/src 1ce3d3ftests/sys/aio aio_test.c

aio(4) tests: do not rely on (int *)-1 being invalid address

Explicitly mmap guard and use it as the invalid address instead.

(cherry picked from commit dc9a8d300ba5c4c319589d78231e9d0e76576cbf)
DeltaFile
+6-1tests/sys/aio/aio_test.c
+6-11 files

HardenedBSD/src 34ecd90tests/sys/kern pdwait.c Makefile

Add tests for pdwait

Sponsored by:   ConnectWise

(cherry picked from commit 277539ae7f2f07a8dd29d4deb318d66414f8ae2a)

pdwait(2) tests: do not rely on (int *)-1 being invalid address

Explicitly mmap guard and use it as the invalid address instead.

(cherry picked from commit 05492ff6f636108c4fac40c259defe9b2eac7833)
DeltaFile
+309-0tests/sys/kern/pdwait.c
+1-0tests/sys/kern/Makefile
+310-02 files

HardenedBSD/src c595e21tests/sys/kern procdesc.c Makefile

procdesc: Add a test for pid recycling behavior

Sponsored by:   ConnectWise

(cherry picked from commit e35df41f68916cc23893a29e0284f386ec727462)
DeltaFile
+98-0tests/sys/kern/procdesc.c
+1-0tests/sys/kern/Makefile
+99-02 files

HardenedBSD/src e3e71c6tests/sys/capsicum Makefile

tests: sys/capsicum/functional requires mqueuefs

Skip this test if mqueuefs isn't loaded.  Unfortunately, that will skip
the entire googletest test program, including test cases that don't
require mqueuefs.  But the test's own skipping logic doesn't work, and
we don't yet have a googletest-compatible require_kmods() function.

Sponsored by:   ConnectWise
Reviewed by:    emaste, ngie
Differential Revision: https://reviews.freebsd.org/D54902

(cherry picked from commit df68a09ea2ec18ee975fb937d46a18250d4663c8)
DeltaFile
+1-0tests/sys/capsicum/Makefile
+1-01 files

HardenedBSD/src 04c8a5dsys/vm vm_mmap.c

HBSD: Resolve merge conflict

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>
DeltaFile
+9-22sys/vm/vm_mmap.c
+9-221 files

HardenedBSD/src 5b42ccelib/librpcsec_gss svc_rpcsec_gss.c, sbin/route route_netlink.c

Merge remote-tracking branch 'origin/freebsd/15-stable/main' into hardened/15-stable/main

Conflicts:
        sys/vm/vm_mmap.c (unresolved)
DeltaFile
+31-12sys/vm/vm_mmap.c
+11-1sys/netlink/route/rt.c
+9-1sys/rpc/rpcsec_gss/svc_rpcsec_gss.c
+4-6sbin/route/route_netlink.c
+8-1lib/librpcsec_gss/svc_rpcsec_gss.c
+3-2usr.bin/netstat/route_netlink.c
+66-232 files not shown
+70-238 files

HardenedBSD/src 04d58d5lib/libc/gen syslog.3, sbin/dmesg dmesg.8

manuals: System message vs kernel message

Wordsmith mentions throughout the manual of syslog and dmesg, to clearly
differentiate them in an externally consisteny way, increasing operator
onboarding speed and elegance.

The daemon that handles general system messages, syslog, describes them
as "system messages", and "messages" is the standard filename. Rewrite
syslog related manual titles to align search results with this, and hier
entries to align the index. Use care to maintain keywords and not add
extra lines. Newsyslog trades "maintain" with "rotate" for visibility.

MFC after:      3 days
Reviewed by:    markj
Closes:         https://github.com/freebsd/freebsd-src/pull/2067
DeltaFile
+2-4usr.sbin/newsyslog/newsyslog.conf.5
+2-4usr.sbin/syslogd/syslog.conf.5
+3-3sbin/dmesg/dmesg.8
+3-3share/man/man7/hier.7
+2-2usr.sbin/newsyslog/newsyslog.8
+2-2lib/libc/gen/syslog.3
+14-186 files

HardenedBSD/src 1e2c9bclib/libsys kldload.2

kldload.2: Provide more info about file argument

The information is basically taken from kldload(8).

Reviewed by:            kib, ziaee
Differential Revision:  https://reviews.freebsd.org/D55170
DeltaFile
+15-2lib/libsys/kldload.2
+15-21 files

HardenedBSD/src 23d6516lib/libc/amd64/string strrchr.S

libc/amd64/strrchr.S: fix rebase error

I accidentally dropped a part of the patch on squash rebase.
Should be fine now.

Fixes:          253f15c016ca699906f78b8e522a3f7ed675929b
PR:             293915
MFC after:      1 week
DeltaFile
+4-4lib/libc/amd64/string/strrchr.S
+4-41 files

HardenedBSD/src 3ced14flib/libc/amd64/string strrchr.S, usr.bin/diff pr.c diffreg.c

Merge remote-tracking branch 'origin/hardened/current/master' into hardened/current/cross-dso-cfi
DeltaFile
+26-52lib/libc/amd64/string/strrchr.S
+39-23usr.bin/diff/pr.c
+30-18usr.bin/diff3/diff3.c
+5-0usr.bin/diff/diffreg.c
+100-934 files

HardenedBSD/src 66f039flib/libc/amd64/string strrchr.S, usr.bin/diff pr.c diffreg.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+26-52lib/libc/amd64/string/strrchr.S
+39-23usr.bin/diff/pr.c
+30-18usr.bin/diff3/diff3.c
+5-0usr.bin/diff/diffreg.c
+100-934 files

HardenedBSD/src 253f15clib/libc/amd64/string strrchr.S

libc/amd64/strrchr.S: rewrite and fix scalar implementation

The original scalar implementation of strrchr() had incorrect
logic that failed if the character searched for was the NUL
character.  It was also possibly affected by the issue fixed
in 3d8ef251a for strchrnul().

Rewrite the function with logic that actually works.  We defer
checking for the character until after we have checked for NUL.
When we encounter the final NUL byte, we mask out the characters
beyond the tail before checking for a match.

This bug only affects users running on amd64 with ARCHLEVEL=scalar
(cf. simd(7)).  The default configuration is not affected.

The bug was unfortunately not caught by the unit test inherited
from NetBSD.  An extended unit test catching the issue is proposed
in D56037.


    [6 lines not shown]
DeltaFile
+26-52lib/libc/amd64/string/strrchr.S
+26-521 files

HardenedBSD/src 9b98c4busr.bin/diff diffreg.c

diff: handle read(2) failures

MFC After:      1 week
DeltaFile
+5-0usr.bin/diff/diffreg.c
+5-01 files

HardenedBSD/src f088a26sbin/route route_netlink.c

route(8): Fix -expire argument when using netlink

Also fixes nexthop expire value on route get using netlink.

Reviewed by: glebius
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D55444

(cherry picked from commit 8230cf1aa18d9215ee17fec743fc7c7c8fa2da13)
DeltaFile
+4-6sbin/route/route_netlink.c
+4-61 files