FreeBSD/src a3b3be5sys/compat/linuxkpi/common/src linux_firmware.c

linuxkpi: Avoid a potential null pointer dereference in an error path

Reported by:    Kevin Day <kevin at your.org>
Reviewed by:    bz, emaste
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D54672

(cherry picked from commit aa1eb623389008c95b897976f4d28a7fe0acd93c)
DeltaFile
+2-1sys/compat/linuxkpi/common/src/linux_firmware.c
+2-11 files

FreeBSD/src 72dc1a1sys/compat/linuxkpi/common/src linux_current.c

linuxkpi: Fix an error path in linux_alloc_current()

If the allocation fails we should free the task struct.

While here get rid of a couple of unnecessary assertions.

Reported by:    Kevin Day <kevin at your.org>
Reviewed by:    emaste
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D54671

(cherry picked from commit a4955b0143361900140df640d116891f047f5431)
DeltaFile
+2-8sys/compat/linuxkpi/common/src/linux_current.c
+2-81 files

FreeBSD/src 6cbd76esys/dev/jme if_jme.c

jme: Convert driver to CTLFLAG_MPSAFE

Replace CTLFLAG_NEEDGIANT with CTLFLAG_MPSAFE for all interrupt
coalescing sysctls. The driver uses jme_mtx mutex for proper
synchronization and does not require Giant lock.

Sysctls converted:
- dev.jme.X.tx_coal_to (TX coalescing timeout)
- dev.jme.X.tx_coal_pkt (TX coalescing packet count)
- dev.jme.X.rx_coal_to (RX coalescing timeout)
- dev.jme.X.rx_coal_pkt (RX coalescing packet count)
- dev.jme.X.process_limit (max RX events to process)

Reviewed by:    markj
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D54618

(cherry picked from commit c2a55efd74cccb3d4e7b9037b240ad062c203bb8)
DeltaFile
+5-5sys/dev/jme/if_jme.c
+5-51 files

FreeBSD/src 4d9eaa0sys/arm64/iommu smmu.c

arm64/iommu: Fix a resource leak in smmu_domain_alloc()

We should free the allocated ASID if smmu_init_cd() fails.

Move the allocation of "domain" to simplify the first error path.

Reported by:    Kevin Day <kevin at your.org>
Reviewed by:    br
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D54676

(cherry picked from commit 6740cccb1eff2a0e1e6d451fa9676a21736937d2)
DeltaFile
+2-3sys/arm64/iommu/smmu.c
+2-31 files

FreeBSD/src 714d5b3sys/dev/iicbus/adc ads111x.c

ads111x: Convert driver to CTLFLAG_MPSAFE

Replace CTLFLAG_NEEDGIANT with CTLFLAG_MPSAFE for all ADC sensor
sysctls.  All of the sysctl handlers are serialized by a driver mutex.

Sysctls converted:
- dev.ads111x.X.channelN.gain_index (PGA setting)
- dev.ads111x.X.channelN.rate_index (sample rate)
- dev.ads111x.X.channelN.voltage (sampled voltage)
- dev.ads111x.X.config (configuration register)
- dev.ads111x.X.lo_thresh (comparator low threshold)
- dev.ads111x.X.hi_thresh (comparator high threshold)

Reviewed by:    markj
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D54620

(cherry picked from commit 2c029cff5ba3716757646a2d2c89db49987c1e98)
DeltaFile
+6-6sys/dev/iicbus/adc/ads111x.c
+6-61 files

FreeBSD/src 0e2e588sys/arm64/vmm/io vgic_v3.c

arm64/vgic_v3: Fix an inverted test when reading GICD_I<C|S>ENABLER

On read, these registers' fields return 1 if forwarding of the
corresponding interrupt is enabled, and 0 otherwise.  The test in
read_enabler() was inverted.

Reported by:    Kevin Day <kevin at your.org>
Reviewed by:    andrew
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D54678

(cherry picked from commit 6fef0c9ee64cea1f22b6a33a0c4dd39f605b7465)
DeltaFile
+1-1sys/arm64/vmm/io/vgic_v3.c
+1-11 files

FreeBSD/src fd6bccclib/libc/gen exterr_cat_filenames.h

exterr: Regenerate exterr_cat_filenames.h
DeltaFile
+1-1lib/libc/gen/exterr_cat_filenames.h
+1-11 files

FreeBSD/src da714e3sys/dev/isl isl.c

isl: Convert driver to CTLFLAG_MPSAFE

Replace CTLFLAG_NEEDGIANT with CTLFLAG_MPSAFE for all light sensor
sysctls.  All of the sysctl handlers are serialized by a driver mutex.

Sysctls converted:
- dev.isl.X.als (ambient light sensor)
- dev.isl.X.ir (infrared sensor)
- dev.isl.X.prox (proximity sensor)
- dev.isl.X.resolution (sensor resolution)
- dev.isl.X.range (sensor range)

Reviewed by:    markj
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D54621

(cherry picked from commit 0672e0e38a08c580f723a02bb183344d8c7cee65)
DeltaFile
+5-5sys/dev/isl/isl.c
+5-51 files

FreeBSD/src 36daea2tools/build make_libc_exterr_cat_filenames.sh

exterr: Sort output from make_libc_exterr_cat_filenames.sh

Otherwise the script may permute the order of entries in the file since
find(1) output is not stable.

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

(cherry picked from commit bda6ed2ee4d8e836b1b2f8ca7a6ed72034e5f231)
DeltaFile
+1-1tools/build/make_libc_exterr_cat_filenames.sh
+1-11 files

FreeBSD/src f1e1bfesys/compat/linuxkpi/common/src linux_shmemfs.c

linuxkpi: Clean up linux_shmem_file_setup() a bit

- Free the pointer that was returned by the allocator, instead of the
  address of the first member.  These will be equal in practice, but
  it's sketchy and won't work on CHERI with subobject bounds checking.
- Use an anonymous struct, there's no need to name it.

Reviewed by:    bz, brooks, emaste
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D54673

(cherry picked from commit 251662e5abdd85f5a83766b400e23c2ac5597fb9)
DeltaFile
+3-4sys/compat/linuxkpi/common/src/linux_shmemfs.c
+3-41 files

FreeBSD/src a11b4f7sys/dev/asmc asmc.c

asmc: add per-fan manual mode control via sysctl

Add per-fan manual mode control via dev.asmc.0.fan.N.manual sysctl.

Apple SMCs support manual fan control via the FS! SMC key,
a 16-bit bitmask where each bit controls one fan (0=auto, 1=manual).

This change adds a new sysctl per fan:
    dev.asmc.0.fan.N.manual (0=auto, 1=manual)

When set to manual mode (1), the fan runs at the speed set via
dev.asmc.0.fan.N.targetspeed instead of automatic thermal control.  When
set to auto mode (0), the SMC controls fan speed automatically.

The FS! key was already defined in asmcvar.h but not accessible.
This exposes it for debugging, testing, and advanced fan control.

Implementation uses read-modify-write to allow independent control of
each fan without affecting others.

    [6 lines not shown]
DeltaFile
+55-0sys/dev/asmc/asmc.c
+55-01 files

FreeBSD/src 4efe75alib/libsys kqueue.2

kqueue.2: Fix reference to unexisting kevent1()

kqueue1() was meant.

While here, make the wording in the AUTHORS section more clear.

PR:             291908
Fixes:          9b1585384d53 ("kqueue.2: Editorial pass")
Reviewed by:    kib, dab
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D54858
DeltaFile
+4-4lib/libsys/kqueue.2
+4-41 files

FreeBSD/src d6bc31fusr.sbin/makefs/tests makefs_zfs_tests.sh

makefs/zfs/tests: Force-destroy md devices

Most of these tests create a md(4) device backed by a makefs-generated
image, then import the pool, using the md device as a pool vdev.  When
a test finishes, it destroys the pool, then destroys the md device.

Once in a while md device destruction fails with EBUSY.  This happens
when a GEOM consumer is holding the device open; kern_mddetach_locked()
simply fails if any consumers are present.  zpool destruction is
synchronous so ZFS is innocent, rather, the problem seems to be that
GEOM re-tastes the device after the zpool reference goes away.  This
operation creates a transient reference that causes the spurious
failure.

Use "mdconfig -o force" to work around this.

MFC after:      2 weeks
DeltaFile
+2-2usr.sbin/makefs/tests/makefs_zfs_tests.sh
+2-21 files

FreeBSD/src 711b0e1sys/netpfil/ipfw ip_fw_table_value.c

netpfil/ipfw: Fix a typo in a source code comment

- s/vaues/values/

(cherry picked from commit 9be9ab2a242080dea6254e187cf211604170de07)
DeltaFile
+1-1sys/netpfil/ipfw/ip_fw_table_value.c
+1-11 files

FreeBSD/src ed2b5f4sys/arm64/rockchip/clk rk_clk_fract.c

rockship: Fix a typo in a source code comment

- s/vaues/values/

(cherry picked from commit cabb5add07a60c146698d09759445276aa96757a)
DeltaFile
+1-1sys/arm64/rockchip/clk/rk_clk_fract.c
+1-11 files

FreeBSD/src 60e75e9sys/netpfil/ipfw ip_fw_table_value.c

netpfil/ipfw: Fix a typo in a source code comment

- s/vaues/values/

(cherry picked from commit 9be9ab2a242080dea6254e187cf211604170de07)
DeltaFile
+1-1sys/netpfil/ipfw/ip_fw_table_value.c
+1-11 files

FreeBSD/src ad9c5a6sys/dev/clk/rockchip rk_clk_fract.c

rockship: Fix a typo in a source code comment

- s/vaues/values/

(cherry picked from commit cabb5add07a60c146698d09759445276aa96757a)
DeltaFile
+1-1sys/dev/clk/rockchip/rk_clk_fract.c
+1-11 files

FreeBSD/src 58580dclib/libc/gen posix_spawnattr_getexecfd_np.3 Makefile.inc

libc: document posix_spawnattr_getexecfd_np(3)

Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D54862
DeltaFile
+86-0lib/libc/gen/posix_spawnattr_getexecfd_np.3
+2-0lib/libc/gen/Makefile.inc
+2-0lib/libc/gen/posix_spawn.3
+90-03 files

FreeBSD/src 3f0aea0include spawn.h, lib/libc/gen posix_spawn.c Symbol.map

libc: add posix_spawnattr_{get,set}execfd_np(3)

If execfd is set, the fexecve(2) is used by posix_spawn() instead of the
provided path.

Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D54862
DeltaFile
+21-1lib/libc/gen/posix_spawn.c
+7-0include/spawn.h
+5-0lib/libc/gen/Symbol.map
+33-13 files

FreeBSD/src d185e9fsys/sys param.h

Bump __FreeBSD_version to 1600011 after changes to eventfd

This covers the commits that updated the API and the commit that exposes
that API in linuxkpi for DRM drivers.

Sponsored by:   The FreeBSD Foundation
DeltaFile
+1-1sys/sys/param.h
+1-11 files

FreeBSD/src a200c8esys/compat/linuxkpi/common/include/linux eventfd.h, sys/compat/linuxkpi/common/src linux_eventfd.c

linuxkpi: Add eventfd_*()

Add <linux/eventfd.h> and expose the `eventfd_*()` API. This is used by
DRM drivers for some time, but the code was commented out so far.

Note that Linux uses `struct eventfd_ctx`, but FreeBSD defines `struct
eventfd`. We define `eventfd_ctx` as a synonym to `eventfd`.

Reviewed by:    christos, markj
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50853
DeltaFile
+63-0sys/compat/linuxkpi/common/src/linux_eventfd.c
+54-0sys/compat/linuxkpi/common/include/linux/eventfd.h
+2-0sys/conf/files
+1-0sys/modules/linuxkpi/Makefile
+0-0sys/compat/linuxkpi/dummy/include/linux/eventfd.h
+120-05 files

FreeBSD/src 28d6ffesys/kern sys_eventfd.c, sys/sys eventfd.h

eventfd: Add eventfd_signal()

The `eventfd_signal()` function is the equivalent to a write to an
eventfd file descriptor: it bumps the internal counter and wakes up
processes waiting for it.

`eventfd_signal()` is meant to be used by kernel drivers. DRM drivers
will call it through linuxkpi.

Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50850
DeltaFile
+22-3sys/kern/sys_eventfd.c
+1-0sys/sys/eventfd.h
+23-32 files

FreeBSD/src 5931649sys/kern sys_eventfd.c, sys/sys eventfd.h

eventfd: Add refcounting

An eventfd file descriptor can be used by drivers such as DRM drivers
through linuxkpi. A driver can hold a reference to such a file
regardless of the fact it is used by userland or not.

This patch introduces a refcount in `struct eventfd`, plus the
`eventfd_get()` and `eventfd_put()` functions to acquire and release
references. These functions will be used by DRM drivers for instance.

This structure is internal to `sys/kern/sys_eventfd.c` and not used
anywhere else. Thus it is safe to add a field without breaking anything.

Reviewed by:    markj
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50849
DeltaFile
+30-4sys/kern/sys_eventfd.c
+4-0sys/sys/eventfd.h
+34-42 files

FreeBSD/src e878df0lib/libsys _libsys.h, sys/compat/freebsd32 freebsd32_systrace_args.c freebsd32_proto.h

Regen syscall tables after pdfork(2) and pdwait(2) additions
DeltaFile
+68-0sys/compat/freebsd32/freebsd32_systrace_args.c
+68-0sys/kern/systrace_args.c
+16-0sys/sys/sysproto.h
+9-0sys/compat/freebsd32/freebsd32_proto.h
+3-1sys/compat/freebsd32/freebsd32_syscall.h
+4-0lib/libsys/_libsys.h
+168-17 files not shown
+186-313 files

FreeBSD/src 6c82bf1lib/libc/gen exterr_cat_filenames.h

Regen for the fork and exit/wait exterror category addition
DeltaFile
+2-0lib/libc/gen/exterr_cat_filenames.h
+2-01 files

FreeBSD/src ec8e8fashare/man/man4 rights.4

rights.4: document CAP_PDWAIT

Noted by:       markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D54592
DeltaFile
+3-0share/man/man4/rights.4
+3-01 files

FreeBSD/src f7b5688lib/libsys pdfork.2 Makefile.sys

Document pdrfork(2) and pdwait(2)

Reviewed by:    asomers, markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D54592
DeltaFile
+81-8lib/libsys/pdfork.2
+4-2lib/libsys/Makefile.sys
+1-0lib/libsys/rfork.2
+1-0lib/libsys/wait.2
+87-104 files

FreeBSD/src 2d555eclib/libc/sys pdwait.c Symbol.map, lib/libsys Makefile.sys interposing_table.c

lib/libsys, lib/libc: export pdwait

Make pdwait(2) cancellable, same as all other wait*(2) syscalls wrappers.

Reviewed by:    asomers, markj
Tested by:      pho
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D54592
DeltaFile
+20-0lib/libc/sys/pdwait.c
+15-0lib/libthr/thread/thr_syscalls.c
+4-0sys/sys/procdesc.h
+4-0lib/libc/sys/Symbol.map
+1-0lib/libsys/Makefile.sys
+1-0lib/libsys/interposing_table.c
+45-01 files not shown
+46-07 files

FreeBSD/src 4d70782sys/compat/freebsd32 freebsd32_misc.c, sys/kern kern_exit.c syscalls.master

Add pdwait(2)

Reviewed by:    asomers, markj
Tested by:      pho
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D54592
DeltaFile
+105-0sys/kern/kern_exit.c
+31-0sys/compat/freebsd32/freebsd32_misc.c
+10-0sys/kern/syscalls.master
+4-0sys/kern/sys_procdesc.c
+2-0sys/sys/syscallsubr.h
+152-05 files

FreeBSD/src 0998487sys/kern kern_exit.c sys_procdesc.c

procdesc: postpone freeing the zombie' pid until procdesc is freed

Requested by:   asomers
Reviewed by:    asomers, markj
Tested by:      pho
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D54592
DeltaFile
+2-2sys/kern/kern_exit.c
+4-0sys/kern/sys_procdesc.c
+6-22 files