HardenedBSD/ports f3737f1Mk bsd.hardening.mk, Mk/Uses hardcflags.mk

HBSD: Add "general compilation hardening" USES

This commit introduces a general catch all for compiler hardening flags
that aren't paired with a specific feature (unlike CFI, for example).
The USES for this is "hardcflags" and the USE_HARDENING flag is
"HARDCFLAGS".

We also enable this by default, though we will most likely need to fix a
number of ports (possibly a large number.) The biggest issue will likely
be the -Wformat-security compilation flag.

As of this writing, the HardenedBSD infrastructure lacks a server that
can perform experimental builds. So we need to apply a broad stroke
initially and resolve failed ports.

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>
DeltaFile
+29-1Mk/bsd.hardening.mk
+20-0Mk/Uses/hardcflags.mk
+49-12 files

HardenedBSD/src 6d0ee20share/mk bsd.sys.mk

HBSD: Use the right Makefile variables

The -fno-delete-null-pointer-checks is not a warning, but rather a
normal compiler flag.

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>
MFC-to:         15-STABLE
MFC-to:         14-STABLE
Fixes:          ca0a80281e4ee936f0bf9df8f40448d37cd6667d
DeltaFile
+2-2share/mk/bsd.sys.mk
+2-21 files

HardenedBSD/src ca0a802contrib/diff/src diff3.c, lib/clang/liblldb LLDBWrapLua.cpp

HBSD: Add various C/C++ hardening flags

One common optimization is to remove NULL pointer checks when the
compiler thinks it's not truly needed. We want to keep those checks in
place (-fno-delete-null-pointer-checks).

Another C/C++ compiler flag enabled by this commit is to check for
potential format string vulnerabilities (-Werror=format-security).

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>
MFC-to:         15-STABLE
MFC-to:         14-STABLE
DeltaFile
+6-0share/mk/bsd.sys.mk
+1-1contrib/diff/src/diff3.c
+1-1lib/clang/liblldb/LLDBWrapLua.cpp
+8-23 files

HardenedBSD/src 9c8dbf3contrib/diff/lib getopt.h, libexec/rc rc.subr

Merge remote-tracking branch 'origin/hardened/current/master' into hardened/current/cross-dso-cfi
DeltaFile
+0-176contrib/diff/lib/getopt.h
+158-0usr.sbin/setaudit/setaudit.c
+134-0sys/dev/fdt/simplebus.c
+68-46libexec/rc/rc.subr
+88-0usr.sbin/setaudit/setaudit.8
+85-0sys/arm64/arm64/nexus.c
+533-22215 files not shown
+628-24921 files

HardenedBSD/src d7cf7ebcontrib/diff/lib getopt.h, libexec/rc rc.subr

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+0-176contrib/diff/lib/getopt.h
+158-0usr.sbin/setaudit/setaudit.c
+134-0sys/dev/fdt/simplebus.c
+68-46libexec/rc/rc.subr
+88-0usr.sbin/setaudit/setaudit.8
+85-0sys/arm64/arm64/nexus.c
+533-22215 files not shown
+628-24921 files

HardenedBSD/src bc7bd9bcddl/contrib/opensolaris/cmd/dtrace dtrace.1, share/man/man4 geom_zero.4 dtrace_callout_execute.4

Merge branch 'freebsd/14-stable/main' into hardened/14-stable/master
DeltaFile
+174-0share/man/man4/geom_zero.4
+68-0share/man/man4/dtrace_callout_execute.4
+3-1share/man/man9/callout.9
+2-1share/man/man4/zero.4
+3-0share/man/man4/Makefile
+1-0cddl/contrib/opensolaris/cmd/dtrace/dtrace.1
+251-26 files

HardenedBSD/src 786ff1bshare/man/man4 geom_zero.4, share/man/man7 d.7

Merge branch 'freebsd/15-stable/main' into hardened/15-stable/main
DeltaFile
+174-0share/man/man4/geom_zero.4
+36-125sys/amd64/vmm/vmm.c
+124-0share/man/man7/d.7
+15-91sys/arm64/vmm/vmm.c
+6-86sys/riscv/vmm/vmm.c
+83-8sys/dev/vmm/vmm_dev.c
+438-31020 files not shown
+578-38526 files

HardenedBSD/ports 692bfeedns/aardvark-dns distinfo Makefile.crates, multimedia/librespot distinfo Makefile.crates

Merge branch 'freebsd/main' into hardenedbsd/main
DeltaFile
+343-343multimedia/librespot/distinfo
+351-0dns/aardvark-dns/distinfo
+171-171multimedia/librespot/Makefile.crates
+174-0dns/aardvark-dns/Makefile.crates
+65-29textproc/difftastic/distinfo
+84-0net/dhcpcd/files/patch-src_privsep-root.c
+1,188-54332 files not shown
+1,453-67238 files

HardenedBSD/src abcb80fcontrib/diff/src diff3.c

diff3: Use logical-not, not bitwise for booleans

And compare impcompat != 0 as it's actually an integer incremented on
each use of one of the AeExX3 options.

Reviewed by:    fuz
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53808
DeltaFile
+3-3contrib/diff/src/diff3.c
+3-31 files

HardenedBSD/ports 994a7c1net/dhcpcd Makefile

net/dhcpcd: bump port revision
DeltaFile
+1-0net/dhcpcd/Makefile
+1-01 files

HardenedBSD/ports 1fafcbfprint/hplip pkg-plist distinfo, print/hplip-plugin Makefile

print/hplip(-plugin): Update to 3.25.8
DeltaFile
+40-12print/hplip/files/patch-Makefile.in
+20-22print/hplip/files/patch-prnt_cups.py
+36-0print/hplip/pkg-plist
+20-0print/hplip/files/patch-ui5_setupdialog.py
+7-3print/hplip-plugin/Makefile
+3-3print/hplip/distinfo
+126-402 files not shown
+131-458 files

HardenedBSD/ports a25e46dnet/dhcpcd/files patch-src_privsep-root.c

net/dhcpcd: ensure we recv for real after a successful recv MSG_PEEk

PR:     291081
DeltaFile
+84-0net/dhcpcd/files/patch-src_privsep-root.c
+84-01 files

HardenedBSD/ports c6ba0famultimedia/librespot distinfo Makefile.crates

multimedia/librespot: update to 8.0.0

Changes:        https://github.com/librespot-org/librespot/releases/tag/v0.8.0

PR:             291035
DeltaFile
+343-343multimedia/librespot/distinfo
+171-171multimedia/librespot/Makefile.crates
+1-2multimedia/librespot/Makefile
+515-5163 files

HardenedBSD/src 7446569sys/conf files.arm64

conf: Mark vchiq as depending on fdt

Fix an ACPI only kernel by only building the vchiq files when FDT is
enabled.

Fixes:  745c4aa5e8f0 ("Make BRCM2837 port conform FreeBSD/ARM64 guidelines")
Sponsored by:   Arm Ltd
DeltaFile
+9-9sys/conf/files.arm64
+9-91 files

HardenedBSD/src a695ac2sys/arm64/arm64 mp_machdep.c

arm64: Move intr_pic_init_secondary earlier

This may have been called after intr_irq_shuffle. For most interrupt
controllers this appears to be safe, however for the GICv5 we need to
read a per-CPU ID register before we can assign interrupts to a given
CPU.

Fix the race by moving intr_pic_init_secondary earlier in the boot,
after devices have been enumerated and before the interrupts are moved
to their assigned CPUs.

Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D53685
DeltaFile
+2-2sys/arm64/arm64/mp_machdep.c
+2-21 files

HardenedBSD/src 3ef673esys/arm64/arm64 gicv3_its.c

arm64: Switch to gic_get_support_lpis in gicv3_its

The old gicv3_get_support_lpis will be removed.

Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D53664
DeltaFile
+2-2sys/arm64/arm64/gicv3_its.c
+2-21 files

HardenedBSD/src 2188e77sys/arm64/arm64 gic_v3_var.h gic_v3.c

arm64: Remove gicv3_get_support_lpis

It's no longer used after moving to gic_get_support_lpis.

Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D53665
DeltaFile
+0-2sys/arm64/arm64/gic_v3_var.h
+0-1sys/arm64/arm64/gic_v3.c
+0-32 files

HardenedBSD/src 8178a4esys/arm/arm gic.c gic_common.h, sys/arm64/arm64 gic_v3.c

arm/gic: Make GICV3_IVAR_SUPPORT_LPIS generic

GICv5 will need this too, so move to the GIC_IVAR namespace.

Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D53663
DeltaFile
+3-0sys/arm/arm/gic.c
+2-0sys/arm/arm/gic_common.h
+1-0sys/arm64/arm64/gic_v3.c
+6-03 files

HardenedBSD/src 262faddsys/arm/arm gic.c

arm: Handle GIC_IVAR_VGIC in the gic driver

We don't have a GICv2 vgic so can just return 0.

Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D53662
DeltaFile
+3-0sys/arm/arm/gic.c
+3-01 files

HardenedBSD/src 4713f54sys/arm64/arm64 nexus.c

arm64: Add non-PCI MSI support

Add the arm64 parts to support for non-PCI MSI and MSI-X interrupts.

Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D53331
DeltaFile
+85-0sys/arm64/arm64/nexus.c
+85-01 files

HardenedBSD/src 68e6422sys/dev/fdt simplebus.c

dev/fdt: Add support for non-PCI MSI interrupts

Some non-PCI devices can send interrupts, e.g. the Arm SMMU or GICv5
Interrupt Wire Bridge. Add support for these by implementing pci_get_id
and pci_alloc_msi and the MSI/MSI-X parts of the PCIB interface.

Only the MSI parts of the PCI interface are added as that is all I am
able to test.

Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D53330
DeltaFile
+134-0sys/dev/fdt/simplebus.c
+134-01 files

HardenedBSD/src 6b12b94sys/dev/ofw ofw_cpu.c

dev/ofw: Teach ofw_cpu to find the pcpu on arm64

Use the midr value to ensure we find the correct PCPU pointer on arm64.

Sponsored by:   Arm Ltd
Differential Revision:  https://reviews.freebsd.org/D53327
DeltaFile
+26-2sys/dev/ofw/ofw_cpu.c
+26-21 files

HardenedBSD/src 75fd26fsbin/geom Makefile

HBSD: Resolve merge conflict

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>
DeltaFile
+0-4sbin/geom/Makefile
+0-41 files

HardenedBSD/src dfb7319sbin/geom Makefile, sbin/geom/core geom.c

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

Conflicts:
        sbin/geom/Makefile (unresolved)
DeltaFile
+178-76sbin/geom/core/geom.c
+37-16sbin/mount/getmntopts.c
+11-4sys/kern/kern_thread.c
+9-0usr.sbin/bhyve/amd64/xmsr.c
+4-0sbin/geom/Makefile
+239-965 files

HardenedBSD/src 81bb2a2sbin/geom Makefile

HBSD: Resolve merge conflict

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>
DeltaFile
+0-4sbin/geom/Makefile
+0-41 files

HardenedBSD/ports e9e78b0science/mbdyn/files patch-libraries_libmbwrap_umfpackwrap.h

science/mbdyn: Fix build

Reported by:    fallout
DeltaFile
+19-0science/mbdyn/files/patch-libraries_libmbwrap_umfpackwrap.h
+19-01 files

HardenedBSD/src 75e67d6sbin/geom/core geom.c, sys/contrib/openzfs/module/zfs spa.c dnode.c

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

Conflicts:
        sbin/geom/Makefile (unresolved)
DeltaFile
+175-106sys/contrib/openzfs/module/zfs/spa.c
+178-76sbin/geom/core/geom.c
+205-0tests/sys/sound/polling.c
+17-182sys/dev/sound/pcm/buffer.c
+68-88sys/contrib/openzfs/module/zfs/dnode.c
+76-76sys/dev/sound/pcm/channel.c
+719-528176 files not shown
+2,384-1,880182 files

HardenedBSD/ports bfd9af5audio/odin2-synthesizer Makefile

audio/odin2-synthesizer: Fix compilation by adding mixxing xorg dependencies

Reported by:    fallout
DeltaFile
+3-1audio/odin2-synthesizer/Makefile
+3-11 files

HardenedBSD/src d795c75sys/kern kern_event.c

kevent: Hold the knlist mutex when invoking f_event(NOTE_FORK)

In general f_event is supposed to be called with the knlist mutex held,
so lock it earlier to follow this protocol.  Also make sure that the
update to kn_fflags is synchronized.

Lock the kqueue itself earlier in the case where the knote is activated,
to avoid locking and unlocking the kqueue twice.

PR:             291005
Reported by:    Qiu-ji Chen <chenqiuji666 at gmail.com>
Reviewed by:    kib
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D53762
DeltaFile
+12-4sys/kern/kern_event.c
+12-41 files

HardenedBSD/src 71f6592libexec/rc rc.subr

rc.subr: Remove misguided cpuset usage

When running an rc command, if the target rc script defines
<command>_cmd, e.g., start_cmd=..., then the run_rc_command() executes
that instead of $command.  In general it's a shell function, and
"cpuset -l <n> <shell function>" doesn't work.

Moreover, it doesn't really make sense to run cpuset for anything other
than start_cmd.

Other optional isolation mechanisms (e.g., <name>_fib,
<name>_chroot) are only used when invoking $command directly as part of
the "start" command.  Make <name>_cpuset consistent with everything else
by removing these extraneous cpuset invocations.

Reviewed by:    0mp
MFC after:      2 weeks
Sponsored by:   Modirum MDPay
Sponsored by:   Klara, Inc.
Differential Revision:  https://reviews.freebsd.org/D53746
DeltaFile
+4-4libexec/rc/rc.subr
+4-41 files