HardenedBSD/src d5b04d2 — sys/dev/asmc asmcvar.h asmc_debug.c, sys/dev/intel intel_pmc.c

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+28-1,561sys/dev/asmc/asmc.c
+1,144-0sys/dev/asmc/asmc_sysctl.c
+309-70sys/dev/intel/intel_pmc.c
+323-0sys/dev/asmc/asmc_pio.c
+217-0sys/dev/asmc/asmc_debug.c
+20-50sys/dev/asmc/asmcvar.h
+2,041-1,68145 files not shown
+2,356-1,79051 files

HardenedBSD/src ad8f475 — sys/kern link_elf.c

link_elf: bounds-check the DT_HASH offset

parse_dynamic() builds the symbol hash table at ef->address + d_ptr
without checking that d_ptr lies within the mapped image, so a crafted
DT_HASH entry causes an out-of-bounds read of the hash header.  Reject
the object with ENOEXEC when the header does not fit in the image.

Reviewed by:    kib
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D61323
DeltaFile
+8-1sys/kern/link_elf.c
+8-11 files

HardenedBSD/src 4b1963d — sys/kern link_elf_obj.c

link_elf_obj: validate section name offsets

A section name offset (sh_name) indexes the section name string table
without being checked against shstrcnt, and the result is passed to
strcmp(), so a corrupt object causes an out-of-bounds read.  Check that
the table is NUL-terminated and that every sh_name lies within it, in
both the preload and file paths, and reject the object with ENOEXEC.

Reviewed by:    kib
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D61338
DeltaFile
+27-0sys/kern/link_elf_obj.c
+27-01 files

HardenedBSD/src f068327 — sys/kern link_elf_obj.c

link_elf_obj: bounds-check e_shstrndx in link_elf_load_file()

e_shstrndx is used to index the section header array after only being
checked against zero, so a malformed object can make the linker read up
to about 64K entries past the end of shdr[].  Reject such a file with
ENOEXEC, as link_elf_link_preload() already does.

Reported by:    llm-postcr
Reviewed by:    kib
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D61321
DeltaFile
+6-0sys/kern/link_elf_obj.c
+6-01 files

HardenedBSD/src 4e2c284 — sys/kern link_elf_obj.c

link_elf_obj: validate symbol name offsets

A symbol name offset (st_name) indexes the string table in several
places without being checked against ddbstrcnt, so a corrupt object
causes an out-of-bounds read.  Check that the string table is
NUL-terminated and that every st_name lies within it, in both the
preload and file paths, and reject the object with ENOEXEC.

Reviewed by:    kib
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D61322
DeltaFile
+25-0sys/kern/link_elf_obj.c
+25-01 files

HardenedBSD/src 8686152 — sys/netpfil/ipfilter/netinet ip_nat.c

ipfilter: Remove erroneous ntohs()

The original commit was wrong.  ipf_nat_builddivertmp() builds the UDP
template with the length in host byte order

M_DUP() copies that value unchanged. The old code was therefore correct.
It added fin_plen in host order and then did a single htons().

The original patch was discussed with Co-Pilot, which pointed out the
original bug. claude-opus-5-5 discovered the ntohs() error that
co-pilot suggested.

Interestingly this code had been running here for a couple of months.

Reported by:    llm-postcr
Fixes:          72cc9e3766f4
DeltaFile
+0-1sys/netpfil/ipfilter/netinet/ip_nat.c
+0-11 files

HardenedBSD/src d0fd709 — lib/libcasper/libcasper zygote.c

libcasper: Use casper_pdfork()

Fixes:          425e4c102f8a ("libcasper: Use pdfork() for the zygote")
DeltaFile
+1-1lib/libcasper/libcasper/zygote.c
+1-11 files

HardenedBSD/src 72cc9e3 — sys/netpfil/ipfilter/netinet ip_nat.c

ipfilter: Only recalculate the UDP header when we have one

When ipf_nat_out processes NAT_DIVERTOUT (ipnat rdr statements)
it also fixes the checksum in the UDP header. Test for a UDP header
before adjusting its length.

While we are here, the length in the UDP header must be converted
from network byte order to host byte order. Add the missing ntohs().

PR:             296944
MFC after:      3 days
DeltaFile
+6-3sys/netpfil/ipfilter/netinet/ip_nat.c
+6-31 files

HardenedBSD/src 425e4c1 — lib/libcasper/libcasper zygote.c libcasper_service.c

libcasper: Use pdfork() for the zygote

Use pdfork(2) rather than fork(2) to fork the zygote, and close the
descriptor when the main loop terminates.

MFC after:      1 week
Sponsored by:   Klara, Inc.
Sponsored by:   Qualys, Inc.
Reviewed by:    oshogbo
Differential Revision:  https://reviews.freebsd.org/D60176
DeltaFile
+8-4lib/libcasper/libcasper/libcasper_service.c
+3-3lib/libcasper/libcasper/zygote.c
+11-72 files

HardenedBSD/src 71979d8 — usr.sbin/bsnmpd/modules/snmp_hostres snmp_hostres.3

snmp_hostres.3: fix .Fx macro in the middle of a line

Reported by: bjk
DeltaFile
+3-1usr.sbin/bsnmpd/modules/snmp_hostres/snmp_hostres.3
+3-11 files

HardenedBSD/src 8c9be10 — tests/sys/netpfil/pf return.py

pf tests: make return.py more robust

Sometimes ICMP echo packets get lost, so send more than one during
the sanity check. This should resolve the intermittent failure of the
return.py:TestReturn::test_tcp test.

PR:             300511
Sponsored by:   Rubicon Communications, LLC ("Netgate")
DeltaFile
+3-3tests/sys/netpfil/pf/return.py
+3-31 files

HardenedBSD/src fdf948e — share/man/man4 intel_pmc.4, sys/conf files.x86

intel/intel_pmc: Add support for Cannon Lake through Meteor Lake

Match the platform by CPU model and attach on acpi with PWRM at
0xfe000000; the PMC is not PCI-enumerable on these platforms.
SLP_S0_RES offsets and granularities follow each generation's PCH
Family Datasheet Volume 2.  A mismatch between the LPIT residency
counter address and SLP_S0_RES is reported on attach.

Reviewed by:    olce, adrian
Differential Revision:  https://reviews.freebsd.org/D59596
DeltaFile
+309-70sys/dev/intel/intel_pmc.c
+36-29share/man/man4/intel_pmc.4
+1-1sys/modules/intel_pmc/Makefile
+1-1sys/conf/files.x86
+347-1014 files

HardenedBSD/src a62d316 — sys/i386/linux linux_sysvec.c

HBSD: Resolve merge conflict

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>
DeltaFile
+0-43sys/i386/linux/linux_sysvec.c
+0-431 files

HardenedBSD/src fd65747 — crypto/openssh README.tun configure.ac, crypto/openssh/regress sshfp-connect.sh

Merge remote-tracking branch 'rad/freebsd/current/main' into hardened/current/master

Conflicts:
        sys/i386/linux/linux_sysvec.c (unresolved)
DeltaFile
+696-111crypto/openssh/ChangeLog
+308-0crypto/openssh/kexmlkem768ecdh.c
+144-41crypto/openssh/regress/sshfp-connect.sh
+140-19crypto/openssh/sshconnect2.c
+41-102crypto/openssh/configure.ac
+0-132crypto/openssh/README.tun
+1,329-405101 files not shown
+2,321-1,240107 files

HardenedBSD/src 86b9d62 — sys/dev/nvme nvme.h

nvme: Fix the data length in the Reservation Report command builder

nvme_ns_resv_report_cmd() put its length argument, which callers
supply in bytes, directly into cdw10.  The NUMD field is a 0's
based count of dwords, so the command asked the controller to
transfer nearly four times the size of the supplied data buffer.
In practice controllers limit the transfer to the length described
by the PRP entries, which is why this worked in testing, but the
command was incorrect.

Convert the byte count to a 0's based dword count in the builder.

Reported by:    llm-postcr
Fixes:          7a9e4375316b
MFC after:      1 week
Sponsored by:   Spectra Logic
Co-authored-by: Claude Fable 5 <noreply at anthropic.com>
DeltaFile
+2-1sys/dev/nvme/nvme.h
+2-11 files

HardenedBSD/src f7c24ef — sbin/camcontrol camcontrol.c

camcontrol: Don't close the CAM device in nvme_get_data()

nvme_get_data() closed the supplied CAM device on every error
path, but its callers either pass the device that main() opened
and closes, or close the device themselves, so an error resulted
in a double cam_close_device() and a double free.  Move the error
path close into print_dev_nvme(), the one caller that opens its
own device, and leave the device alone in nvme_get_data().

This predates the recent camcontrol NVMe additions, but they added
more callers.

Reported by:    llm-postcr
Fixes:          6ee13c54dad0
MFC after:      1 week
Sponsored by:   Spectra Logic
Co-authored-by: Claude Fable 5 <noreply at anthropic.com>
DeltaFile
+3-3sbin/camcontrol/camcontrol.c
+3-31 files

HardenedBSD/src 2dd34af — sbin/camcontrol nvfeature.c, sys/cam/nvme nvme_all.h nvme_all.c

camcontrol: Fix extended host identifier retrieval

The Get Features command for the host identifier always requested
the 64-bit form (cdw11 EXHID=0), but the decoding logic sized the
identifier from the controller's CTRATT extended host identifier
capability bit, or always treated it as 128 bits when -U was
given.  On a controller supporting the extended host identifier,
the printed value did not match what was requested from the
controller.

Fetch the controller data before issuing the command, request the
extended form when the controller supports it, and decode the form
that was requested.  Reject -U when the controller only supports
64-bit host identifiers, since an 8 byte value cannot be shown as
a UUID.

sys/cam/nvme/nvme_all.c,
sys/cam/nvme/nvme_all.h:
        Add an exhid argument to nvme_get_feature_hostid(),

    [17 lines not shown]
DeltaFile
+35-22sbin/camcontrol/nvfeature.c
+7-2sys/cam/nvme/nvme_all.c
+3-2sys/cam/nvme/nvme_all.h
+45-263 files

HardenedBSD/src b95e2b2 — sbin/camcontrol nvres.c

camcontrol: Require a reservation type for reserve, preempt and release

res_type was initialized to 0, but the checks that enforce the -T
argument for the reserve, preempt and release reservation actions
compare it against -1, so they could never fire and camcontrol
silently sent a reservation type of 0, which is invalid.
Initialize res_type to -1 so the checks work, and default the
reservation type to 0 for the release action's clear variant,
which does not take -T and ignores the field.

Reported by:    llm-postcr
Fixes:          ba75cf05727e
MFC after:      1 week
Sponsored by:   Spectra Logic
Co-authored-by: Claude Fable 5 <noreply at anthropic.com>
DeltaFile
+4-1sbin/camcontrol/nvres.c
+4-11 files

HardenedBSD/src ef69484 — sbin/camcontrol nvformat.c

camcontrol: Fix swapped protection information defaults in nvformat

When no -p or -l arguments are given, the nvformat subcommand fills
in the protection information type and location from the
namespace's current settings.  The two were swapped: pi was taken
from the DPS metadata location bit and pil from the protection
information type field.  Formatting a namespace with protection
information enabled would therefore silently change its PI
settings, and before the Format NVM command builder masked its
fields, a namespace with PI type 2 enabled would set bit 9 of
cdw10, turning the format into a user data erase.

Reported by:    llm-postcr
Fixes:          80f090111ae4
MFC after:      1 week
Sponsored by:   Spectra Logic
Co-authored-by: Claude Fable 5 <noreply at anthropic.com>
DeltaFile
+4-4sbin/camcontrol/nvformat.c
+4-41 files

HardenedBSD/src f262bdc — sys/dev/nvme nvme_ctrlr.c

nvme: Restore the host memory buffer size calculation

When the nvme_ctrlr_cmd_set_feature() call in
nvme_ctrlr_hmb_enable() was rewritten for the widened Set Features
API, the HSIZE calculation reverted to dividing by a hard coded
4096 instead of the controller page size, undoing commit
3740a8db13ba.  The Host Memory Buffer Size field is in units of
the current memory page size (CC.MPS), so the wrong size would be
programmed on controllers configured with a page size other than
4KB.

Reported by:    llm-postcr
Fixes:          7a9e4375316b
MFC after:      1 week
Sponsored by:   Spectra Logic
Co-authored-by: Claude Fable 5 <noreply at anthropic.com>
DeltaFile
+1-1sys/dev/nvme/nvme_ctrlr.c
+1-11 files

HardenedBSD/src 3892a64 — sbin/camcontrol nvformat.c, sys/dev/nvme nvme.h

nvme: Mask the fields in the Format NVM command builder

nvme_admin_format_cmd() did not mask any of the fields it composes
into cdw10, so an out of range value in one field would corrupt
neighboring fields.  In particular, an LBA format index greater
than 15 would bleed into the metadata settings and protection
information fields.  It also had no support for LBA format indexes
above 15, which NVMe 2.0 encodes via the separate LBAFU field.

Mask all of the fields, and encode bits 5:4 of the LBA format index
in the LBAFU field (cdw10 bits 13:12).

Also reject out of range LBA format indexes in camcontrol's
nvformat global (-G) mode, which has no namespace data to validate
against.  The per-namespace mode already validates the index
against NLBAF.

sys/dev/nvme/nvme.h:
        Mask the SES, PIL, PI, MSET and LBAF fields in

    [12 lines not shown]
DeltaFile
+6-0sbin/camcontrol/nvformat.c
+3-2sys/dev/nvme/nvme.h
+9-22 files

HardenedBSD/src 3a6dbe7 — sys/dev/nvme nvme.h

nvme: Byte-swap the nsid in the Get/Set Features command builders

nvme_admin_get_feature_cmd() and nvme_admin_set_feature_cmd() stored
the namespace ID in the command without converting it to little
endian, unlike the other command building functions.  Any caller
passing a non-zero namespace ID would send the wrong namespace ID on
big endian machines.

Reported by:    llm-postcr
Fixes:          7a9e4375316b
MFC after:      1 week
Sponsored by:   Spectra Logic
Co-authored-by: Claude Fable 5 <noreply at anthropic.com>
DeltaFile
+2-2sys/dev/nvme/nvme.h
+2-21 files

HardenedBSD/src 88e0df0 — sys/dev/asmc asmcmmio.c asmc_sysctl.c

asmc: compare integer results to zero explicitly

No functional change.

MFC After: 1 Week
Approved-by: ngie (co-mentor)

Reviewed by:    ngie, adrian
Differential Revision:  https://reviews.freebsd.org/D61303
DeltaFile
+15-14sys/dev/asmc/asmc_pio.c
+4-4sys/dev/asmc/asmc_debug.c
+4-3sys/dev/asmc/asmc.c
+2-2sys/dev/asmc/asmc_sysctl.c
+1-1sys/dev/asmc/asmcmmio.c
+26-245 files

HardenedBSD/src b391f3f — sys/dev/asmc asmcvar.h asmc_pio.c

asmc: Fix style(9) issues

fix operator and comma spacing and three long lines

MFC After: 1 Week
Approved-by: ngie (co-mentor)

Reviewed by:    ngie, imp
Differential Revision:  https://reviews.freebsd.org/D61302
DeltaFile
+4-3sys/dev/asmc/asmc_sysctl.c
+3-2sys/dev/asmc/asmc_debug.c
+3-2sys/dev/asmc/asmc.c
+1-1sys/dev/asmc/asmcvar.h
+1-1sys/dev/asmc/asmc_pio.c
+12-95 files

HardenedBSD/src a3468ea — sys/dev/asmc asmcmmio.c asmc_debug.c

asmc: Use c99 initializers with for-loop counters to improve scoping

declared loop indices in the for statement
Index types are unchanged.

No functional change.

MFC After: 1 Week
Approved-by: ngie (co-mentor)

Reviewed by:    ngie, imp
Differential Revision:  https://reviews.freebsd.org/D61301
DeltaFile
+3-8sys/dev/asmc/asmc.c
+4-6sys/dev/asmc/asmc_pio.c
+2-6sys/dev/asmc/asmc_sysctl.c
+1-2sys/dev/asmc/asmcmmio.c
+1-2sys/dev/asmc/asmc_debug.c
+11-245 files

HardenedBSD/src c714cde — sys/conf files.amd64, sys/dev/asmc asmc_sysctl.h asmcvar.h

asmc: split the sysctl layer into asmcsysctl.c

Moved the dev.asmc.N tree out of asmc.c

No functional change

MFC After: 1 Week
Approved-by: ngie (co-mentor)

Reviewed by:    ngie
Differential Revision:  https://reviews.freebsd.org/D61300
DeltaFile
+1,147-0sys/dev/asmc/asmc_sysctl.c
+5-1,052sys/dev/asmc/asmc.c
+4-53sys/dev/asmc/asmcvar.h
+25-0sys/dev/asmc/asmc_sysctl.h
+1-1sys/modules/asmc/Makefile
+1-0sys/conf/files.amd64
+1,183-1,1066 files

HardenedBSD/src 0b545e5 — sys/conf files.amd64, sys/dev/asmc asmc_pio.h asmc.c

asmc: split the PIO backend into asmcpio.c

Moved the inline PIO transactions out of the key transport routines,
which now only dispatch on sc_is_mmio, matching asmcmmio.c. getbyindex and
getinfo stay fused: PIO needs both halves under one hold of sc_mtx.

No functional change.

MFC After: 1 Week
Approved-by: ngie (co-mentor)

Reviewed by:    ngie
Differential Revision:  https://reviews.freebsd.org/D61296
DeltaFile
+324-0sys/dev/asmc/asmc_pio.c
+7-274sys/dev/asmc/asmc.c
+28-0sys/dev/asmc/asmc_pio.h
+1-1sys/modules/asmc/Makefile
+1-0sys/conf/files.amd64
+361-2755 files

HardenedBSD/src d412f42 — sys/conf files.amd64, sys/dev/asmc asmcvar.h asmc_debug.h

asmc: split the debug key access into asmc_debug.c

Move the ASMC_DEBUG code out of asmc.c into a file compiled only when the
option is set, gated in files.amd64 the way acpi_debug gates the ACPICA
debugger sources. The module Makefile writes the define into opt_asmc.h so
every translation unit sees it; the old CFLAGS.asmc.c form covered one.

No functional change.

MFC After: 1 Week
Approved-by: ngie (co-mentor)

Reviewed by:    ngie
Differential Revision:  https://reviews.freebsd.org/D61294
DeltaFile
+6-222sys/dev/asmc/asmc.c
+217-0sys/dev/asmc/asmc_debug.c
+31-0sys/dev/asmc/asmc_debug.h
+19-0sys/dev/asmc/asmcvar.h
+8-0sys/modules/asmc/Makefile
+1-0sys/conf/files.amd64
+282-2226 files

HardenedBSD/src f594944 — krb5/libexec/kprop Makefile, krb5/plugins/k5tls Makefile

krb5: Don't include libsys in LIBADD

This has the curious effect of placing libsys before libc in the link
order even though libc links against libsys.  While this happens to
work currently, it is fragile and fails to link properly in some edge
cases.

Sponsored by:   AFRL, DARPA
Differential Revision:  https://reviews.freebsd.org/D60724
DeltaFile
+1-1krb5/usr.bin/klist/Makefile
+1-1krb5/usr.bin/kdestroy/Makefile
+1-1krb5/usr.bin/gss-client/Makefile
+1-1krb5/plugins/preauth/spake/Makefile
+1-1krb5/plugins/k5tls/Makefile
+1-1krb5/libexec/kprop/Makefile
+6-610 files not shown
+16-1616 files

HardenedBSD/src 9e99355 — lib/libpam/modules/pam_krb5 Makefile

pam_krb5: Append to CFLAGS instead of replacing

Obtained from:  CheriBSD
Sponsored by:   AFRL, DARPA
Differential Revision:  https://reviews.freebsd.org/D60723
DeltaFile
+1-1lib/libpam/modules/pam_krb5/Makefile
+1-11 files