HardenedBSD/src ff2744asys/netpfil/ipfilter/netinet fil.c ip_fil.h

Merge branch 'freebsd/current/main' into hardened/current/master
DeltaFile
+2-2sys/netpfil/ipfilter/netinet/fil.c
+1-1sys/netpfil/ipfilter/netinet/ip_fil.h
+1-1sys/netpfil/ipfilter/netinet/ip_state.c
+4-43 files

HardenedBSD/src 3fdbd8asys/netpfil/ipfilter/netinet fil.c ip_fil.h

ipfilter: Avoid negative array indicies

Array indices must always be posive. We avoid this by making each index
unsigned. This mitigates out-of-bounds reads and writes.

Reported by:            Ilja Van Sprundel <ivansprundel at ioactive.com>
Reviewed by:            glebius
MFC after:              3 days
Differential revision:  https://reviews.freebsd.org/D55260
DeltaFile
+2-2sys/netpfil/ipfilter/netinet/fil.c
+1-1sys/netpfil/ipfilter/netinet/ip_fil.h
+1-1sys/netpfil/ipfilter/netinet/ip_state.c
+4-43 files

HardenedBSD/src eb1c78esys/sys priv.h

HBSD: Resolve merge conflict

Signed-off-by:  Shawn Webb <shawn.webb at hardenedbsd.org>
DeltaFile
+2-7sys/sys/priv.h
+2-71 files

HardenedBSD/src fdac606tests/sys/capsicum capsicum.h syscalls.h, tests/sys/kern pdrfork.c

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

Conflicts:
        sys/sys/priv.h (unresolved)
DeltaFile
+4-144tests/sys/capsicum/capsicum.h
+0-144tests/sys/capsicum/syscalls.h
+0-140tests/sys/capsicum/capability-fd-pair.cc
+62-66tests/sys/kern/pdrfork.c
+0-103tests/sys/capsicum/capsicum-rights.h
+76-25usr.sbin/bhyve/rfb.c
+142-62235 files not shown
+350-1,07141 files

HardenedBSD/src fba81b3tests/sys/capsicum capsicum.h syscalls.h

capsicum-tests: remove Linux support

Now that this project is part of freebsd-src, it no longer needs to be
portable.  Remove Linux-only tests, cross-os compatibility code, and
compatibility with older FreeBSD versions.  Leave in place some
originally Linux-only tests that could now be ported to FreeBSD, like the
pipe2 tests.

Sponsored by:   ConnectWise
Reviewed by:    oshogbo
Differential Revision: https://reviews.freebsd.org/D54985
DeltaFile
+4-144tests/sys/capsicum/capsicum.h
+0-144tests/sys/capsicum/syscalls.h
+0-140tests/sys/capsicum/capability-fd-pair.cc
+0-103tests/sys/capsicum/capsicum-rights.h
+5-65tests/sys/capsicum/capability-fd.cc
+15-51tests/sys/capsicum/procdesc.cc
+24-64716 files not shown
+55-93722 files

HardenedBSD/src dc9a8d3tests/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.

MFC after:      1 week
DeltaFile
+6-1tests/sys/aio/aio_test.c
+6-11 files

HardenedBSD/src 05492fftests/sys/kern pdwait.c

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

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

MFC after:      1 week
DeltaFile
+17-3tests/sys/kern/pdwait.c
+17-31 files

HardenedBSD/src 11c1b69sys/netlink netlink_io.c

netlink: force uninline of nl_receive_message()

The entire netlink(4) message processing thread is all inlined into
nl_taskqueue_handler() making it difficult to dtrace(1) on a message
level.
DeltaFile
+1-1sys/netlink/netlink_io.c
+1-11 files

HardenedBSD/src 757b0bfusr.sbin/bhyve rfb.c

bhyve: Propagate errors from rfb_recv_* functions

Update rfb_recv_* functions to return -1 on failure and 0 on success.
Update rfb_handle to check these return values and drop the connection
if an error occurs.

Signed-off-by: Hayzam Sherif <hayzam at gmail.com>

Reviewed by:    markj
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
DeltaFile
+76-25usr.sbin/bhyve/rfb.c
+76-251 files

HardenedBSD/src 29ec390usr.sbin/syslogd syslogd.c

syslogd: Improve handling of configuration errors

Make parse_selector() print a warning to stderr and continue parsing the
config if it encounters an invalid facility or priority.  Note that
because the parsing is done from a casper service, there isn't a good
mechanism to log errors; the warnings are visible only when syslogd is
started in debug mode.

Reported by:    Doug Hardie <bc979 at lafn.org>
MFC after:      1 week
Fixes:          f4b4a10abb26 ("syslogd: Move selector parsing into its own function")
Reviewed by:    jfree, jlduran, eugen, delphij
Differential Revision:  https://reviews.freebsd.org/D55033
DeltaFile
+8-6usr.sbin/syslogd/syslogd.c
+8-61 files

HardenedBSD/src 793e891tests/sys/kern pdrfork.c

pdrfork(2) tests: enable on x86

Use pfrfork_thread(3) instead of pdrfork(RFSPAWN) to make tests working
on x86.

Tested by:      pho
Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D55306
DeltaFile
+20-9tests/sys/kern/pdrfork.c
+20-91 files

HardenedBSD/src f90ee66tests/sys/kern pdrfork.c

pdrfork(2) tests: should wait for the child to exit

Tested by:      pho
Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D55306
DeltaFile
+3-2tests/sys/kern/pdrfork.c
+3-21 files

HardenedBSD/src 94e4de7tests/sys/kern pdrfork.c

pdrfork(2) tests: split basic_usage

into pdrfork(2) call itself, and basic_usage_tail() that checks the
pdrfork(2) results.

Tested by:      pho
Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D55306
DeltaFile
+19-9tests/sys/kern/pdrfork.c
+19-91 files

HardenedBSD/src 68ba270tests/sys/kern pdrfork.c

pdrfork(2) tests: RFPROCDESC|RFPROC are required

Tested by:      pho
Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D55306
DeltaFile
+2-44tests/sys/kern/pdrfork.c
+2-441 files

HardenedBSD/src b05be03lib/libsys pdfork.2, sys/kern kern_fork.c

pdrfork(2): do require RFPROCDESC | RFPROC

when RFSPAWN is not specified, as stated in the man page.
rfork(2) cannot modify non-curproc, which is why RFPROC is required,
the syscall cannot act on arbitrary process descriptor.
If RFPROCDESC is not specified, the syscall does not make sense,
use rfork(2).

Reported and tested by: pho
Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D55306
DeltaFile
+5-3lib/libsys/pdfork.2
+5-0sys/kern/kern_fork.c
+10-32 files

HardenedBSD/src 4484369tests/sys/kern pdrfork.c

pdrfork(2) tests: catch runaway child for EFAULT test

Reported and tested by: pho
Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D55306
DeltaFile
+10-0tests/sys/kern/pdrfork.c
+10-01 files

HardenedBSD/src db80ea9lib/libsys pdfork.2

pdfork.2: add EFAULT as possible error, explain some consequences of it

Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D55306
DeltaFile
+18-0lib/libsys/pdfork.2
+18-01 files

HardenedBSD/src d6bf2d1tests/sys/kern pdrfork.c

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

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

Tested by:      pho
Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D55306
DeltaFile
+8-2tests/sys/kern/pdrfork.c
+8-21 files

HardenedBSD/src 9950902sys/powerpc/aim moea64_native.c

powerpc: document the magic constants for 16MB page size

After discussion with jhibbits@, we pulled out what is supported here
and how it's supported.

Reviewed by:    imp
Differential Revision:  https://reviews.freebsd.org/D55093
DeltaFile
+13-0sys/powerpc/aim/moea64_native.c
+13-01 files

HardenedBSD/src f412a5csys/powerpc/aim mmu_oea64.c

powerpc: enable HPT superpages by default

It's time to flip these on and see if anything happens in -HEAD.
It can be turned back off before 16.0-RELEASE if there are problems.

Reviewed by:    jhibbits
Differential Revision:  https://reviews.freebsd.org/D55071
DeltaFile
+2-7sys/powerpc/aim/mmu_oea64.c
+2-71 files

HardenedBSD/src c20f5fdsbin/ifconfig ifconfig.8

ifconfig.8: Start new sentence on new line

This change was forgotten by me in the previous commit to this file.

Reported by:    kib
Approved by:    implicit (change omitted from previous commit)
Fixes:          31ec8b6407fdd5a87d70265762457c67ce618283

(cherry picked from commit e912723afb4e6bcfa828fcb73f35cd82fc6bca68)

Reviewed by:            glebius, kp, pouria, zlei
Approved by:            glebius, pouria
Relnotes:               yes
Differential Revision:  https://reviews.freebsd.org/D54382
DeltaFile
+2-1sbin/ifconfig/ifconfig.8
+2-11 files

HardenedBSD/src 20294a7sbin/ifconfig ifconfig.8, sys/netinet6 in6_ifattach.c

netinet6: Fix my style issues

Reported by:            pouria
Reviewed by:            pouria, ziaee, glebius
Approved by:            glebius
Fixes:                  31ec8b6407fdd5a87d70265762457c67ce618283
Differential Revision:  https://reviews.freebsd.org/D55136

(cherry picked from commit 4548149a81026ad9b1706b2b7e7ad47a4c1358b6)

Reviewed by:            glebius, kp, pouria, zlei
Approved by:            glebius, pouria
Relnotes:               yes
Differential Revision:  https://reviews.freebsd.org/D54382
DeltaFile
+9-13sys/netinet6/in6_ifattach.c
+11-8sbin/ifconfig/ifconfig.8
+20-212 files

HardenedBSD/src 4c7357asys/netinet6 nd6_nbr.c in6_ifattach.c

sys/netinet6: Use atomic(9) for dad_failures counter

Replace counter(9) usage with more lightweight atomic(9) in the
code handling RFC 7217 SLAAC address generation.

Also, use `u_int` types with this. Leaving `dad_failures` local to
`in6_get_stableifid()` as a `uint64_t` to avoid changing the generated
addresses from previous code; this also gives some headroom for
future changes.

While here, moved some `#include` lines to adhere to style(9).

Reviewed by:            glebius, jhibbits, jtl, zlei
Approved by:            glebius, jtl, zlei
Differential Revision:  https://reviews.freebsd.org/D52731

(cherry picked from commit 0c94dc9da7c238603e43c55ca6da64c417fc2204)

Reviewed by:            glebius, kp, pouria, zlei

    [3 lines not shown]
DeltaFile
+5-3sys/netinet6/nd6_nbr.c
+4-2sys/netinet6/in6_ifattach.c
+3-1sys/netinet6/nd6_rtr.c
+2-2sys/netinet6/in6_proto.c
+0-3sys/netinet6/in6.c
+1-1sys/netinet6/ip6_var.h
+15-121 files not shown
+16-137 files

HardenedBSD/src 76cd280sys/netinet6 nd6_nbr.c nd6.c

sys/netinet6: Fix ABI breakage introduced with RFC 7217 support

commit 31ec8b6407fdd5a87d70265762457c67ce618283 added a `dad_failures`
variable to `struct nd_ifinfo`, which broke the netowrking ABI.

This commit fixes it by moving such variable to `struct in6_ifextra`
which is not a public interface, while `struct nd_ifinfo` is back
in its original state.

Thanks to kib, markj and glebious for their help and suggestions
in solving this problem.

Reported by:    "Herbert J. Skuhra" <herbert at gojira.at>
Tested by:      "Herbert J. Skuhra" <herbert at gojira.at>
Approved by:    glebius
Fixes:          31ec8b6407fdd5a87d70265762457c67ce618283

(cherry picked from commit 0ec13430c583830cc4d29640787e2d154b140e31)


    [4 lines not shown]
DeltaFile
+3-3sys/netinet6/nd6_nbr.c
+0-4sys/netinet6/nd6.c
+3-0sys/netinet6/in6.c
+1-1sys/netinet6/nd6_rtr.c
+1-1sys/netinet6/in6_ifattach.c
+2-0sys/netinet6/in6_var.h
+10-91 files not shown
+10-107 files

HardenedBSD/src 865e0b2sbin/ifconfig ifconfig.8, sys/netinet6 in6_ifattach.c nd6_rtr.c

sys/netinet6: Implement RFC 7217

Implement RFC 7217 (A Method for Generating Semantically Opaque
Interface Identifiers with IPv6 Stateless Address Autoconfiguration
(SLAAC)) in our IPv6 stack.

A new ifconfig `stableaddr` flag is added to enable the feature on
interfaces, which defaults to on or off for new interfaces based
on the sysctl `net.inet6.ip6.use_stableaddr` (off by default, so
this commit causes no change in behavior with default settings).

The algorithm follows the RFC in its logic, using SHA256-HMAC as
the algorithm to derive addresses so as to provide code that can
be leveraged by future implentations of RFC 8981, leveraging the
`hostuuid` as the secret.

The source of the hostidentifier can be configured using the sysctl
`net.inet6.ip6.stableaddr_netifsource`, while the number of retries
generating a new address in case of collision can be configured

    [17 lines not shown]
DeltaFile
+231-42sys/netinet6/in6_ifattach.c
+65-29sys/netinet6/nd6_rtr.c
+30-5sys/netinet6/nd6_nbr.c
+30-0sbin/ifconfig/ifconfig.8
+12-0sys/netinet6/ip6_var.h
+10-0sys/netinet6/in6_proto.c
+378-768 files not shown
+405-7614 files

HardenedBSD/src e5213cabin/sh sh.1

sh.1: Fix ordering of Cm and Aq macros

MFC after:      3 days
Reviewed by:    ziaee
Fixes:  2711852bd9ac (sh.1: Provide detailed job control documentation)
Differential Revision:  https://reviews.freebsd.org/D55194
DeltaFile
+1-1bin/sh/sh.1
+1-11 files

HardenedBSD/src 931d4f0bin/sh sh.1

sh.1: Document the exit status of return

It's not obvious that if `exitstatus` is omitted,
the exit status of the function is taken from the last executed command.

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

HardenedBSD/src f1f142clib/libsys open.2

open.2: grammar improvements

Submitted by:   matteo
Fixes:  5bcccc702b29a0e173a5916b001771dd7b280c7c
MFC after:      3 days
DeltaFile
+2-2lib/libsys/open.2
+2-21 files

HardenedBSD/src c713540sys/amd64/vmm vmm_dev_machdep.c, sys/dev/vmm vmm_dev.c vmm_dev.h

vmm: Allow the use of PCI passthrough in a jail

After commit e11768e94787 ("vmm: Add PRIV_DRIVER checks for passthru
ioctls"), it is not possible to use PCI passthru from jails, as
PRIV_DRIVER is not granted to jails.  Apparently some users expect this
to work, understanding that jailing bhyve provides little security
benefit in this configuration.

I believe we should disable ppt access in jails even when allow.vmm is
configured.  To provide an escape hatch for users, add a new
allow.vmm_ppt jail configuration knob, and check it when handling ppt
ioctls in jails.  Also add a new PRIV_VMM_PPTDEV to replace the use of
PRIV_DRIVER.

PR:             292750
Reviewed by:    corvink
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Sponsored by:   Klara, Inc.
Differential Revision:  https://reviews.freebsd.org/D55066
DeltaFile
+13-7sys/dev/vmm/vmm_dev.c
+7-7sys/amd64/vmm/vmm_dev_machdep.c
+11-0usr.sbin/jail/jail.8
+7-0sys/kern/kern_jail.c
+6-1sys/sys/priv.h
+1-1sys/dev/vmm/vmm_dev.h
+45-166 files

HardenedBSD/src 7ab5e3fusr.sbin/bhyve pci_passthru.c

bhyve: Fix a misleading error message

The ioctl might fail because it's run in a jail which doesn't have
permission to invoke ppt ioctls.

Reviewed by:    jhb
MFC after:      2 weeks
Sponsored by:   The FreeBSD Foundation
Sponsored by:   Klara, Inc.
Differential Revision:  https://reviews.freebsd.org/D55070
DeltaFile
+7-2usr.sbin/bhyve/pci_passthru.c
+7-21 files