FreeBSD/src 488bf44 — sys/netipsec key.c

netipsec: Do not leak the SAH when an SA is cloned

key_updateaddresses() gives the clone of an SA a new SAH reference when
the SA index comes from key_newsah() or key_getsah(), but nothing
releases the reference of the old SA: key_delsav() leaves the SAH alone,
because key_unlinksav() normally releases it, and an SA that is replaced
never goes through that.  The SAH then stays allocated for good, after
its SAs are flushed and after the vnet is destroyed, as an SADB_UPDATE
with a new address does each time an IKE daemon moves an SA.

The old SA cannot release the reference when it is replaced, since a
sender that still holds it reads its SAH.  Release it in key_delsav()
instead.  When only the NAT-T config changes, the clone used to take over
the reference of the old SA; take a new one in that case as well, so that
every SA holds its own.

Reviewed by:            kib, markj
MFC after:              1 week
Sponsored by:           Rubicon Communications, LLC ("Netgate")
Differential Revision:  https://reviews.freebsd.org/D61101
DeltaFile
+7-3sys/netipsec/key.c
+7-31 files

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

OpenSSH: Update to 10.5p1

This release contains security fixes and small bugfixes.

Full release notes are available at
https://www.openssh.com/txt/release-10.5.

Selected items from the release notes:

Security
========

 * ssh-agent(1): fix an interaction between agent locking and the
   session-bind at openssh.com extension that is used to identify
   forwarded agents. These binding requests were refused when the
   agent was locked, with the result that operations that were
   intended to be limited to local use only could be performed
   remotely, including the ability to add PKCS#11 tokens and make
   use of keys that had destination restrictions applied.

    [33 lines not shown]
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-40591 files not shown
+2,174-1,18197 files

FreeBSD/src dbeadd4 — sys/i386/linux linux_sysvec.c, sys/netinet in_pcb.c

linux: Allow connect() with destination port 0

Linux allows connect() with destination port 0, but FreeBSD returns
EADDRNOTAVAIL in in_pcbconnect() and in6_pcbladdr(). Some Linux programs
(e.g. the new Android CLI tool) rely on this for routability checks,
however.

Add an SV_CONN_PORT0 flag to sv_flags which is set in the Linux sysvecs,
allowing the port 0 guard in the connect paths to be bypassed.

Reviewed by:    glebius, kib
Differential Revision:  https://reviews.freebsd.org/D60659
DeltaFile
+3-2sys/sys/sysent.h
+2-2sys/i386/linux/linux_sysvec.c
+3-1sys/netinet6/in6_pcb.c
+2-1sys/netinet/in_pcb.c
+10-64 files

FreeBSD/src 1333444 — sys/kern kern_loginclass.c, sys/sys syscallsubr.h

kern_loginclass.c: add kern_ implementations

Effort:         CHERI upstreaming
Sponsored by:   DARPA, AFRL, Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+16-3sys/kern/kern_loginclass.c
+2-0sys/sys/syscallsubr.h
+18-32 files

FreeBSD/src 58a758c — sys/kern kern_linker.c, sys/sys syscallsubr.h

kern_linker.c: add kern_ implementations

kldsym(2) is more complex than typical because it requires translation
of struct kld_sym_lookup which is a weird in/out structure.  Out of
paranoia we avoid copying out the symname pointer in the capability
version to eliminate the possiblity of leaking a capability (but not
invalidating a pointer userspace might be using via copyout()).

Effort:         CHERI upstreaming
Sponsored by:   DARPA, AFRL, Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+50-23sys/kern/kern_linker.c
+4-0sys/sys/syscallsubr.h
+54-232 files

FreeBSD/src 6189085 — sys/kern kern_ktrace.c, sys/sys syscallsubr.h

[ku]trace(2): add kern_[ku]trace

Effort:         CHERI upstreaming
Sponsored by:   Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+23-11sys/kern/kern_ktrace.c
+3-0sys/sys/syscallsubr.h
+26-112 files

FreeBSD/src 7c9060c — sys/kern kern_fork.c, sys/sys syscallsubr.h

pdfork(2): add kern_pdfork

Effort:         CHERI upstreaming
Sponsored by:   Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+11-5sys/kern/kern_fork.c
+1-0sys/sys/syscallsubr.h
+12-52 files

FreeBSD/src d477542 — sys/kern kern_ffclock.c, sys/sys syscallsubr.h

ffclock: add kern_ interfaces

Effort:         CHERI upstreaming
Sponsored by:   Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+24-4sys/kern/kern_ffclock.c
+7-0sys/sys/syscallsubr.h
+31-42 files

FreeBSD/src 52bd0d1 — sys/kern kern_exit.c, sys/sys syscallsubr.h

wait6(2): add user_wait6

sys_wait6 is a little more complicated than typical as compat layers
need to translate siginfo_t.

Effort:         CHERI upstreaming
Sponsored by:   Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+24-19sys/kern/kern_exit.c
+3-0sys/sys/syscallsubr.h
+27-192 files

FreeBSD/src 2e3ba76 — sys/kern kern_exit.c, sys/sys syscallsubr.h

wait4(2): add kern_wait4

Effort:         CHERI upstreaming
Sponsored by:   Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+14-6sys/kern/kern_exit.c
+2-0sys/sys/syscallsubr.h
+16-62 files

FreeBSD/src 0a42a5c — sys/kern kern_event.c, sys/sys syscallsubr.h

kevent(2): add kern_kevent_generic

Effort:         CHERI upstreaming
Sponsored by:   Innovate UK
Pull Request:   https://github.com/freebsd/freebsd-src/pull/2284
DeltaFile
+1-14sys/kern/kern_event.c
+11-0sys/sys/syscallsubr.h
+12-142 files

FreeBSD/src 4cb5268 — usr.sbin/flowctl flowctl.8

flowctl.8: Describe better

Align description with EuroBSD netgraph document descriptions rewrite.

MFC after:      3 days
DeltaFile
+2-4usr.sbin/flowctl/flowctl.8
+2-41 files

FreeBSD/src 4cbfaea — usr.sbin/adduser adduser.conf.5

adduser.conf.5: No crossreferences in titles

Crossreferences in titles are strongly discouraged and incompatible
with our own tooling. This is a wontfix by most of manpages ecosystem
because it is bad editorial style in the first place.

MFC after:      3 days
DeltaFile
+1-3usr.sbin/adduser/adduser.conf.5
+1-31 files

FreeBSD/src 1794dd6 — lib/libc/locale freelocale.3

freelocale.3: No crossreferences in titles

Crossreferences in titles are strongly discouraged and incompatible
with our own tooling. This is a wontfix by most of manpages ecosystem
because it is bad editorial style in the first place.

MFC after:      3 days
DeltaFile
+1-4lib/libc/locale/freelocale.3
+1-41 files

FreeBSD/src 115f0a2 — lib/libc/gen fmtcheck.3

fmtcheck.3: No crossreferences in titles

Crossreferences in titles are strongly discouraged and incompatible
with our own tooling. This is a wontfix by most of manpages ecosystem
because it is bad editorial style in the first place.

MFC after:      3 days
DeltaFile
+1-3lib/libc/gen/fmtcheck.3
+1-31 files

FreeBSD/src 5e91181 — share/man/man7 arch.7

arch.7: Mechanical fixes

+ Increase portability by never starting content lines with symbols
+ Improve search results by adding tunables to the variable database
+ Improve search result consistency by correcting description style

MFC after:      3 days
DeltaFile
+9-7share/man/man7/arch.7
+9-71 files

FreeBSD/src 769c49d — secure/lib/libcrypto/engines Makefile.inc Version.map

openssl: export only the engine entry points

Upstream links every dynamic engine with a version script,
engines/<name>.ld, that exports bind_engine and v_check and makes
everything else local.  FreeBSD's engines had no version script, so
they exported every global symbol, including _init and _fini.
loader_attic.so compiles its own copy of crypto/pem/pvkfmt.c and so
also exported 21 of its functions; 14 of them (b2i_*, i2b_*) have the
same names as public libcrypto functions.

Add one Version.map for all engines, the same as upstream's, and use it
from engines/Makefile.inc.

The engines are loaded only with dlopen(), and libcrypto looks up only
bind_engine and v_check, so hiding the other symbols does not affect
any consumer.

Tested via tinderbox: capi.so, devcrypto.so and loader_attic.so link
with --no-undefined-version and export only bind_engine and v_check.

    [8 lines not shown]
DeltaFile
+6-0secure/lib/libcrypto/engines/Version.map
+3-0secure/lib/libcrypto/engines/Makefile.inc
+9-02 files

FreeBSD/src 56741ec — secure/lib/libcrypto/engines/loader_attic Makefile, secure/lib/libcrypto/engines/padlock Makefile

openssl: fix engine defines to match upstream

Two engine Makefiles define different macros from upstream's
engines/build.info:

- padlock: engines/e_padlock.c builds the engine only when PADLOCK_ASM
  is defined.  Upstream defines it on x86 and x86_64, but our Makefile
  never did, so padlock.so has been a stub whose bind_engine() returns
  0 and the e_padlock-x86*.S code it links was never called.  Define
  PADLOCK_ASM on amd64 and i386, where that asm is built.

- loader_attic: upstream defines OPENSSL_NO_PROVIDER_CODE; the Makefile
  had OPENSSL_NO_PROVIDER_CORE.  No source tests either name, so the
  build does not change; this only follows upstream.

Found by comparing per-file compile flags against an upstream 3.5.9
build.  Checked by preprocessing e_padlock.c for amd64 and i386:
COMPILE_PADLOCKENG is now defined.


    [5 lines not shown]
DeltaFile
+1-1secure/lib/libcrypto/engines/loader_attic/Makefile
+2-0secure/lib/libcrypto/engines/padlock/Makefile
+3-12 files

FreeBSD/src 89d6dde — lib/libsys poll.2

libsys/poll.2: bump .Dd for the prior change

MFC after:      1 week
MFC with:       72a80a4733b2
DeltaFile
+1-1lib/libsys/poll.2
+1-11 files

FreeBSD/src 72a80a4 — lib/libsys poll.2

poll.2: document that poll is not restarted after signals

Signed-off-by: _ov4 <ov4 at ov4.org>
Reviewed-by: ngie
Pull-Request: https://github.com/freebsd/freebsd-src/pull/2526
DeltaFile
+12-0lib/libsys/poll.2
+12-01 files

FreeBSD/src 3c6c65b — tests/sys/file Makefile fork_lowfd_test.c

tests/sys/file: add tests for the lowest fd after fork

fdcopy() skips plain kqueues and close-on-fork descriptors when it
copies the table into the child.  Check that dup(2) in the child still
returns the lowest unused descriptor, both when the skipped descriptor
is the lowest free slot and when it sits above an existing hole.

Test cases:

  kqueue_no_hole      a plain kqueue is the lowest descriptor; the
                      child's dup() reuses its slot
  kqueue_two          two adjacent plain kqueues; the child's dup()
                      returns the lower one
  kqueue_above_hole   a plain kqueue sits above a closed descriptor;
                      the child's dup() returns the hole
  kqueue_cponfork     a KQUEUE_CPONFORK kqueue is copied; the child's
                      dup() returns the next slot
  clofork_no_hole     an O_CLOFORK descriptor is the lowest one; the
                      child's dup() reuses its slot

    [14 lines not shown]
DeltaFile
+141-0tests/sys/file/fork_lowfd_test.c
+1-0tests/sys/file/Makefile
+142-02 files

FreeBSD/src b3563d1 — sys/dev/virtio/random virtio_random.c

virtio_random: defer first enqueue until after DRIVER_OK

According to the virtio spec:

> The driver MUST NOT send any buffer available notifications to the
> device before setting DRIVER_OK.

DRIVER_OK isn't set until after attach completes, so defer the first
enqueue.  We haven't found any problems as a result of this to the best
of my knowledge: q35 and other devices that we *have* been used with
will apparently check when we go DRIVER_OK.

Tested with q35 virtio-random, which still works.

Reported by:    llm-postcr
Reviewed by:    kfv, markj
Fixes:  f1c5a2e3a62505 ("virtio_random: Pipeline fetching the data")
Sponsored by:   Stormshield
Sponsored by:   Klara, Inc.

    [2 lines not shown]
DeltaFile
+16-2sys/dev/virtio/random/virtio_random.c
+16-21 files

FreeBSD/src 601d2a9 — sys/dev/virtio/random virtio_random.c

virtio_random: stop on detach, don't poll

If the device is hung, then polling will block the detach and hang us.
Stop it and drain the queue instead.  This fixes a hang on detach in
some circumstances without the upcoming virtio_pci_modern fix.

Reviewed by:    bnovkov, kfv
Sponsored by:   Stormshield
Sponsored by:   Klara, Inc.

(cherry picked from commit cce522853aae3da45b131c2522dd2510edf083e7)
DeltaFile
+9-3sys/dev/virtio/random/virtio_random.c
+9-31 files

FreeBSD/src fcfae0a — sys/dev/virtio/pci virtio_pci_modern.c

virtio_pci_modern: enable virtqueues before completing attach

Most of our drivers setup interrupt(s) and virtqueues are enabled at
that time, but nothing will currently enable them for devices that we're
only going to poll.  This most notably affects virtio-random, and the
problem can be observed with qemu's q35 emulation and a random device
attached.  The q35 implementation ignores the ring unless it's enabled,
so vtrnd_harvest() will consistently EAGAIN rather than contribute
anything of value, but with this patch it becomes functional.

This can be reproduced with a qemu invocation like so:

qemu-system-x86_64 -machine q35,accel=tcg -cpu max -smp 2 -m 2G \
  -drive file=FreeBSD-16.0-CURRENT-amd64-ufs.qcow2,if=virtio \
  -device pcie-root-port,id=rp1,bus=pcie.0,chassis=1 \
  -object rng-random,id=rng0,filename=/dev/urandom \
  -device virtio-rng-pci,rng=rng0,bus=rp1 \
  -display curses


    [5 lines not shown]
DeltaFile
+10-0sys/dev/virtio/pci/virtio_pci_modern.c
+10-01 files

FreeBSD/src 41aa43f — sys/dev/virtio/random virtio_random.c

virtio_random: avoid using vtrnd_detach in the failure path

On the off chance that we discover more than one virtio-random device,
the second one will deregister the global instance or trip an invariant
when it fails to attach and calls vtrnd_detach().

We don't have that many resources to free, so just inline those.  This
is purely a hygiene thing, we haven't seen an instance of this in the
wild (to my knowledge).

Reviewed by:    bnovkov, kfv
Sponsored by:   Stormshield
Sponsored by:   Klara, Inc.

(cherry picked from commit 26ba71f73e8914ecd9e5b1e7bb864fee41158d04)
DeltaFile
+9-2sys/dev/virtio/random/virtio_random.c
+9-21 files

FreeBSD/src 1a10bff — sys/dev/virtio/random virtio_random.c

virtio_random: defer first enqueue until after DRIVER_OK

According to the virtio spec:

> The driver MUST NOT send any buffer available notifications to the
> device before setting DRIVER_OK.

DRIVER_OK isn't set until after attach completes, so defer the first
enqueue.  We haven't found any problems as a result of this to the best
of my knowledge: q35 and other devices that we *have* been used with
will apparently check when we go DRIVER_OK.

Tested with q35 virtio-random, which still works.

Reported by:    llm-postcr
Reviewed by:    kfv, markj
Fixes:  f1c5a2e3a62505 ("virtio_random: Pipeline fetching the data")
Sponsored by:   Stormshield
Sponsored by:   Klara, Inc.

    [2 lines not shown]
DeltaFile
+16-2sys/dev/virtio/random/virtio_random.c
+16-21 files

FreeBSD/src ffa1d4d — sys/dev/virtio/pci virtio_pci_modern.c

virtio_pci_modern: enable virtqueues before completing attach

Most of our drivers setup interrupt(s) and virtqueues are enabled at
that time, but nothing will currently enable them for devices that we're
only going to poll.  This most notably affects virtio-random, and the
problem can be observed with qemu's q35 emulation and a random device
attached.  The q35 implementation ignores the ring unless it's enabled,
so vtrnd_harvest() will consistently EAGAIN rather than contribute
anything of value, but with this patch it becomes functional.

This can be reproduced with a qemu invocation like so:

qemu-system-x86_64 -machine q35,accel=tcg -cpu max -smp 2 -m 2G \
  -drive file=FreeBSD-16.0-CURRENT-amd64-ufs.qcow2,if=virtio \
  -device pcie-root-port,id=rp1,bus=pcie.0,chassis=1 \
  -object rng-random,id=rng0,filename=/dev/urandom \
  -device virtio-rng-pci,rng=rng0,bus=rp1 \
  -display curses


    [5 lines not shown]
DeltaFile
+10-0sys/dev/virtio/pci/virtio_pci_modern.c
+10-01 files

FreeBSD/src ddfd685 — sys/dev/virtio/random virtio_random.c

virtio_random: stop on detach, don't poll

If the device is hung, then polling will block the detach and hang us.
Stop it and drain the queue instead.  This fixes a hang on detach in
some circumstances without the upcoming virtio_pci_modern fix.

Reviewed by:    bnovkov, kfv
Sponsored by:   Stormshield
Sponsored by:   Klara, Inc.

(cherry picked from commit cce522853aae3da45b131c2522dd2510edf083e7)
DeltaFile
+9-3sys/dev/virtio/random/virtio_random.c
+9-31 files

FreeBSD/src 45819a7 — sys/dev/virtio/random virtio_random.c

virtio_random: avoid using vtrnd_detach in the failure path

On the off chance that we discover more than one virtio-random device,
the second one will deregister the global instance or trip an invariant
when it fails to attach and calls vtrnd_detach().

We don't have that many resources to free, so just inline those.  This
is purely a hygiene thing, we haven't seen an instance of this in the
wild (to my knowledge).

Reviewed by:    bnovkov, kfv
Sponsored by:   Stormshield
Sponsored by:   Klara, Inc.

(cherry picked from commit 26ba71f73e8914ecd9e5b1e7bb864fee41158d04)
DeltaFile
+9-2sys/dev/virtio/random/virtio_random.c
+9-21 files

FreeBSD/src ec66296 — sys/compat/linux linux_file.c

linux: Bound native getdents and getdents64 batches

linux_getdents() and linux_getdents64() round their native read size up
to DEV_BSIZE before converting entries. For an unaligned caller buffer,
the native batch can contain more entries than fit in the Linux buffer.
Conversion then returns EINVAL even after copying complete entries,
and the native read has already advanced the directory position.

For counts of at least DEV_BSIZE, use min(args->count, MAXBSIZE) instead.
A 768-byte request, such as rustix's initial directory read, now uses a
768-byte native buffer rather than 1024. The converted Linux dirent and
dirent64 records are no larger than their native counterparts, so the
whole translated batch fits. Returning a short batch is allowed, and
consuming the whole native batch avoids needing to rewind the directory
position.

Keep the existing sizing for counts below DEV_BSIZE. This fixes the
oversized-batch case in both getdents interfaces, including legacy
getdents for 32-bit and 64-bit callers. The remaining small-buffer,

    [8 lines not shown]
DeltaFile
+18-2sys/compat/linux/linux_file.c
+18-21 files