HardenedBSD/src 39c2e99share/man/man9 hashalloc.9, sys/kern subr_hash.c

Merge remote-tracking branch 'origin/hardened/current/master' into hardened/current/cross-dso-cfi
DeltaFile
+350-54sys/kern/subr_hash.c
+314-0share/man/man9/hashalloc.9
+54-92sys/netpfil/pf/pf.c
+30-22sys/netinet/in_pcb.c
+26-15sys/netinet/ip_input.c
+37-0sys/sys/hash.h
+811-18311 files not shown
+887-23217 files

HardenedBSD/src 6ee0e50share/man/man9 hashalloc.9, sys/kern subr_hash.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+350-54sys/kern/subr_hash.c
+314-0share/man/man9/hashalloc.9
+54-92sys/netpfil/pf/pf.c
+30-22sys/netinet/in_pcb.c
+26-15sys/netinet/ip_input.c
+37-0sys/sys/hash.h
+811-18311 files not shown
+887-23217 files

HardenedBSD/src cd5ff4esys/net pfvar.h, sys/netpfil/pf pf.c

pf: use hashalloc(9) for key, id, src-node and udp-endpoint hashes

Reviewed by:            kp
Differential Revision:  https://reviews.freebsd.org/D56113
DeltaFile
+54-92sys/netpfil/pf/pf.c
+1-2sys/net/pfvar.h
+55-942 files

HardenedBSD/src 87ef306sys/netinet tcp_lro.c

tcp lro: use hashalloc(9)

Reviewed by:            tuexen, rrs
Differential Revision:  https://reviews.freebsd.org/D56177
DeltaFile
+20-6sys/netinet/tcp_lro.c
+20-61 files

HardenedBSD/src 9992eb4sys/net if_gif.c if_gif.h, sys/netinet in_gif.c

gif: use hashalloc(9)

Functional change is that on destruction INVARIANTS checks will run.  Also
the mask is no longer hardcoded, so makes it easier to make hash size a
tunable.

Reviewed by:            ae
Differential Revision:  https://reviews.freebsd.org/D56176
DeltaFile
+21-6sys/netinet/in_gif.c
+21-6sys/netinet6/in6_gif.c
+0-21sys/net/if_gif.c
+0-4sys/net/if_gif.h
+42-374 files

HardenedBSD/src adba114sys/netinet ip_input.c

netinet: use hashalloc(9) for IP address hash

While here, slightly restyle ip_vnet_init() and use sparse initializer for
pfil_head_args.  There is no functional change wrt to pfil(9) hook
registration.

Differential Revision:  https://reviews.freebsd.org/D56175
DeltaFile
+26-15sys/netinet/ip_input.c
+26-151 files

HardenedBSD/src 8e1513dsys/netinet in_pcb.c in_pcb.h, sys/netinet6 in6_pcb.c

inpcb: use hashalloc(9)

While here remove ipi_lbgrouphashmask, as it is always has the same value
as ipi_porthashmask.

Differential Revision:  https://reviews.freebsd.org/D56174
DeltaFile
+30-22sys/netinet/in_pcb.c
+1-2sys/netinet/in_pcb.h
+1-1sys/netinet6/in6_pcb.c
+32-253 files

HardenedBSD/src abf68d1share/man/man9 hashalloc.9 hashinit.9, sys/kern subr_hash.c

hash(9): introduce hashalloc()/hashfree() KPI

This is a more extendable version than traditional hashinit(9).  It allows
different kinds of slot headers with optional locks.

Implement traditional hashinit()/hashdestroy() on top of it.

Reviewed by:            pouria, gallatin
Differential Revision:  https://reviews.freebsd.org/D55904
DeltaFile
+350-54sys/kern/subr_hash.c
+314-0share/man/man9/hashalloc.9
+37-0sys/sys/hash.h
+8-1share/man/man9/hashinit.9
+2-0share/man/man9/Makefile
+711-555 files

HardenedBSD/src e9a6994usr.sbin/daemon daemon.c

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
DeltaFile
+1-0usr.sbin/daemon/daemon.c
+1-01 files

HardenedBSD/src 0c3ef48lib/libc/gen Makefile.inc

Merge branch 'freebsd/15-stable/main' into hardened/15-stable/main
DeltaFile
+1-0lib/libc/gen/Makefile.inc
+1-01 files

HardenedBSD/src 9605248sys/dev/ixgbe if_ix.c if_sriov.c

Merge remote-tracking branch 'origin/hardened/current/master' into hardened/current/cross-dso-cfi
DeltaFile
+2-2sys/dev/ixgbe/if_ix.c
+1-1sys/dev/ixgbe/if_sriov.c
+1-1sys/dev/ixgbe/ixgbe_sriov.h
+4-43 files

HardenedBSD/src b5e8c5asys/dev/ixgbe if_ix.c if_sriov.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+2-2sys/dev/ixgbe/if_ix.c
+1-1sys/dev/ixgbe/if_sriov.c
+1-1sys/dev/ixgbe/ixgbe_sriov.h
+4-43 files

HardenedBSD/src 74e3e1ecrypto/openssl CHANGES.md NEWS.md, crypto/openssl/doc/man1 openssl-ciphers.pod.in

Merge branch 'freebsd/15-stable/main' into hardened/15-stable/main
DeltaFile
+442-346secure/usr.bin/openssl/man/openssl-ciphers.1
+438-329crypto/openssl/doc/man1/openssl-ciphers.pod.in
+363-212crypto/openssl/CHANGES.md
+232-195crypto/openssl/NEWS.md
+152-213crypto/openssl/util/platform_symbols/windows-symbols.txt
+258-16sys/dev/tpm/tpm_crb.c
+1,885-1,3111,200 files not shown
+6,253-3,5341,206 files

HardenedBSD/src 8bd82e3lib/libc/gen Makefile.inc

libc: Add missing MLINK for stravis(3)

MFC after:      1 week
Fixes:          8dfeba04eb36 ("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 a09d06bc5bff64baab76220a66c3501b89899134)
DeltaFile
+1-0lib/libc/gen/Makefile.inc
+1-01 files

HardenedBSD/src 207094asys/compat/freebsd32 freebsd32.h, sys/kern subr_devstat.c

devstat: Provide 32-bit compatibility

If a 32-bit process running on a 64-bit kernel requests kern.devstat.all,
translate each struct devstat to its 32-bit equivalent before copying it
out.

Also fix a bug where an early error would be ignored if there were no
devices to report.

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

(cherry picked from commit a11d132f6c62f32abe44b19f7527d97ddc239058)

freebsd32: Fix includes

The previous commit added <sys/cdefs.h>, which isn't actually needed.
Conversely, <sys/event.h> is needed (and has been for a long time) but

    [7 lines not shown]
DeltaFile
+49-7sys/kern/subr_devstat.c
+27-0sys/compat/freebsd32/freebsd32.h
+76-72 files

HardenedBSD/src 938c076sys/dev/ixgbe if_ix.c ixgbe_sriov.h

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 <naito.yuichiro at gmail.com>

MFC after:      1 week
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2132
DeltaFile
+2-2sys/dev/ixgbe/if_ix.c
+1-1sys/dev/ixgbe/ixgbe_sriov.h
+1-1sys/dev/ixgbe/if_sriov.c
+4-43 files

HardenedBSD/src fee3ebasys/amd64/amd64 machdep.c

kern/amd64/machdep: Replace memset in wrmsr_early_safe_end

GENERIC-KASAN kernel failed to boot on a Dell PowerEdge C6615 with
an AMD EPYC 8224P CPU; UEFI BIOS caught a #GP exception with %RIP
in kasan_memset where %GS relative pointer (curthread->td_pflags2)
was dereferenced. Investigation led to wrmsr_early_safe_end which
calls memset to clear early #GP IDT entry. Replacing memset with
__builtin_memset_inline still resulted in the compiler emitting a
call to the memset resolver in GENERIC-KASAN build and the kernel
stil faulted during boot. This version which has been successfully
tested with both GENERIC and GENERIC-KASAN kernels uses memset_early.

Signed-off-by: Kristofer Peterson <kris at tranception.com>
Reviewed-by: kib
(cherry picked from commit 615f1b9eb17c921bbcb0cce2b9ad61910361325b)
DeltaFile
+1-1sys/amd64/amd64/machdep.c
+1-11 files

HardenedBSD/src 7bb6c19bin/ls ls.c, bin/ls/tests ls_tests.sh

ls: check fts_children() for errors that may not surface otherwise

In particular, if one simply does a non-recursive `ls` on a directory
that is not accessible, there are some classes of errors that may cause
it to fail that wouldn't be surfaced unless we do an fts_read() that
will recurse into the inaccessible directory.  Catch those kinds of
errors here since we cannot expect to an FTS_ERR/FTS_DNR entry to follow
up on them.

PR:             287451
Reviewed by:    kib
Discusssed with:        des

(cherry picked from commit 7bf81e39d83087dc7f984077b5eed5a48df794d4)
DeltaFile
+30-0bin/ls/tests/ls_tests.sh
+17-0bin/ls/ls.c
+47-02 files

HardenedBSD/src cc5125ausr.sbin/bhyveload bhyveload.c

bhyveload: simplify cb_open() and eliminate minor TOCTOU

It's not at all clear why I wrote it like this, but we can do better.

I wouldn't think this really has any meaningful security implications
since the hierarchy in question can't really be modified by the guest
scripts, but it would seem to make it a little more robust.

Reviewed by:    bnovkov, markj

(cherry picked from commit 6da9d465c54bf2e3496e83db025c5d22f3b3cc17)
DeltaFile
+12-14usr.sbin/bhyveload/bhyveload.c
+12-141 files

HardenedBSD/src a41c4d9release Makefile.vm

release: Pass optional VM_IMAGE_CONFIG to vm-image

`make vm-image` calls mk-vmimage.sh, which supports
`-c CONFFILE`. This file gets sourced before building the image.

One example of how to use it is to define
vm_extra_filter_base_packages() to filter the list of packages
installed into the VM image:

    # vm-nodbg32.conf
    vm_extra_filter_base_packages() {
        grep -v -E '(-dbg|lib32)'
    }

    $ make VM_IMAGE_CONFIG=path/to/vm-nodbg32.conf \
        VMFORMATS=raw \
        -DWITH_VMIMAGES \
        vm-image


    [3 lines not shown]
DeltaFile
+1-0release/Makefile.vm
+1-01 files

HardenedBSD/src 2b5087elib/libbe be.c libbe.3, lib/libbe/tests target_prog.c be_create.sh

bectl: Add -E flag to create an empty boot environment

Signed-off-by: Pat Maddox <pat at patmaddox.com>
Reviewed by:    kevans
(cherry picked from commit 2e020c84cb5ee1452e448f27ff7a7b6076c0147a)
DeltaFile
+50-14lib/libbe/be.c
+14-2sbin/bectl/bectl.c
+13-1sbin/bectl/bectl.8
+7-4lib/libbe/tests/target_prog.c
+8-1lib/libbe/libbe.3
+9-0lib/libbe/tests/be_create.sh
+101-223 files not shown
+111-239 files

HardenedBSD/src 2129e62. ObsoleteFiles.inc

ObsoleteFiles: remove the shar(1) manpage as well

Fixes:  3fde39073c ("shar: remove from the tree [...]")
(cherry picked from commit bb0734cf2446ce2be829edfa421af3aa558d2c70)
DeltaFile
+1-0ObsoleteFiles.inc
+1-01 files

HardenedBSD/src 21fcae1sys/dev/tpm tpm20.c tpm20.h

tpm20: fix suspend/resume and entropy harvesting

There were a few problem here:
  - TPM2_Shutdown results in a response that we need to either process
    or ignore, otherwise any tpm20_write or tpm20_harvest call will
    trivially hang on an `sc->pending_data_length != 0`
  - We should have a matching TPM2_Startup upon resume to restore any
    state that should have persisted
  - We must drain the harvest task before we suspend to avoid problems
    there

This commit is sufficient to avoid breaking suspend/resume.

PR:             291067
Co-authored-by: markj
Tested by:      garga

(cherry picked from commit 38a4995eb52db21116f8b37ed942e66a8c2f050f)
DeltaFile
+65-0sys/dev/tpm/tpm20.c
+1-0sys/dev/tpm/tpm20.h
+1-0sys/dev/tpm/tpm_crb.c
+1-0sys/dev/tpm/tpm_tis_core.c
+68-04 files

HardenedBSD/src 07ce814tools/build/mk OptionalObsoleteFiles.inc

OptionalObsoleteFiles: Add etc/zfs/compatibility.d

If the world is built and installed with WITHOUT_ZFS, then make
-DBATCH_DELETE_OLD_FILES delete-old-dirs will give the error:

> rmdir: /etc/zfs: Directory not empty

because /etc/zfs/compatibility.d is still there.  While we're here,
clean out /usr/share/zfs as well.

Co-authored-by: kevans

(cherry picked from commit 5c9d988d865cc4ce849507173c0a2e2f399d0f62)
DeltaFile
+58-0tools/build/mk/OptionalObsoleteFiles.inc
+58-01 files

HardenedBSD/src afe262bsys/dev/tpm tpm_crb.c

tpm: crb: add support for the Pluton startmethod

The Pluton startmethod uses a simple doorbell mechanism to wakeup the
TPM unit after we've issued various forms of state change, with the
registers to use specified in the startmethod-specific segment of the
TPM2 table (up to 12 bytes after the StartMethod).

At the very least, this is the kind of TPM in use by my AMD Zen 4-based
Minisforum machine.

(cherry picked from commit e6fa918c4a3ebeb4bcae7614dbb281bda35e06e1)
DeltaFile
+207-5sys/dev/tpm/tpm_crb.c
+207-51 files

HardenedBSD/src b6321b9sys/dev/uart uart_tty.c

uart: fix sleeping while holding mutex in uart_tty_detach()

Move swi_remove() call before acquiring the tty lock. swi_remove() calls
intr_event_remove_handler() which may sleep via msleep(), causing a lock
order violation when called with the tty mutex held.

The software interrupt handler removal operates on the interrupt event
structure independently and does not require the tty lock. This matches
the pattern used in other drivers such as tcp_hpts.c where swi_remove()
is called without holding other locks.

Reviewed by:    imp, kevans

(cherry picked from commit ed3a2469a71e0ef48cf8e636c35e64a011756da3)
DeltaFile
+2-1sys/dev/uart/uart_tty.c
+2-11 files

HardenedBSD/src caa3700sys/kern subr_firmware.c

firmware: Fix inverted FIRMWARE_GET_NOWARN logic

The try_binary_file() function has inverted logic for the
FIRMWARE_GET_NOWARN flag.  When the flag is set (meaning "don't warn"),
the code sets warn=true and makes noise anyway.

Invert the assignment to warn to correctly suppress warnings when
FIRMWARE_GET_NOWARN is set.

Reviewed by:    kevans

(cherry picked from commit fdcd67be8274d237ae2c87d6475d9d34b440b8d8)
DeltaFile
+1-1sys/kern/subr_firmware.c
+1-11 files

HardenedBSD/src ebf890dlibexec/rc/rc.d zfs

rc: run the zfs rc script before tmp

The tmp rc script has much the same problem that the var does: it wants
to test if /tmp is writable, and mount a tmpfs if it's not.  This means
that we actually want our zfs datasets mounted first, because we might
have a /tmp dataset that changes the story.

The ordering problem is particularly noticable with a r/o zfs root,
since the write test will fail and we'll mount a tmpfs that later gets
covered by our /tmp dataset.  If that /tmp dataset inherited readonly,
then we're still in trouble.

This also fixes `tmpmfs=yes`, which would again get covered by a zfs
dataset with the existing ordering.

Reviewed by:    des

(cherry picked from commit d3f21856aa72c28408660ed40ce76bbd0716a991)
DeltaFile
+1-1libexec/rc/rc.d/zfs
+1-11 files

HardenedBSD/src cf62b00usr.bin/truncate truncate.c, usr.bin/truncate/tests truncate_test.sh

truncate: fix a minor nit + add a hole-punching test

The struct spacectl_range we use is only really used in these three
lines of code, so re-scope it down to just the dealloc branch.  This is
marginally easier to reason about what might be necessary to replace in
porting our truncate(1) to other platforms.

While we're here, add a test for the -d flag to be sure it really does
punch a hole in the file.  The test also tries to confirm that it does
not disturb other segments of the file in the process, just to inspire
some confidence that it's not corrupting the file somehow.

Sponsored by:   Klara, Inc.
Reviewed by:    markj

(cherry picked from commit eacc501eff52db16b7b784c89a3a4a03c9a3ef34)
DeltaFile
+48-0usr.bin/truncate/tests/truncate_test.sh
+2-1usr.bin/truncate/truncate.c
+50-12 files

HardenedBSD/src 6c143ffsys/dev/vt vt_core.c vt.h

vt(4): allow up to _SIG_MAXSIG (128) for VT_SETMODE

VT_SETMODE ioctl currently checks the provided signal numbers with its
own ISSIGVALID macro that uses NSIG (32) as a maximum, although the code
that will actually send the signal in sys/kern/kern_sig.c uses
_SIG_VALID which allows up to _SIG_MAXSIG (128).

This change aligns the vt code with the kernel internals and enables the
use of higher signal numbers so that applications are not limited to
SIGUSR1 and SIGUSR2 for vt release and acquire signals.

Signed-off-by:  Quentin Thébault <quentin.thebault at defenso.fr>
Reviewed by:    emaste, imp, kevans

(cherry picked from commit 5e1c7867e1b9a8abe7307d01087cddc057e39859)
DeltaFile
+3-3sys/dev/vt/vt_core.c
+0-1sys/dev/vt/vt.h
+3-42 files