sound: Unlock the channel when chn_reset() fails in dsp_chn_alloc()
If chn_reset() fails, dsp_chn_alloc() returns with the channel lock
held, dsp_open() calls dsp_close() as part of its cdevpriv error path,
and this causes both a mutex recursion on the channel lock in
dsp_close(), as well a lock order reversal.
Fixes: 02d4eeabfd73 ("sound: Allocate vchans on-demand")
Reported by: llm-postcr
MFC after: Immediately
Sponsored by: The FreeBSD Foundation
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D61793
(cherry picked from commit 01a8cd5ebe9368fd115fb5060bcb1e60d1bbdf1f)
sound: Unlock the channel when chn_reset() fails in dsp_chn_alloc()
If chn_reset() fails, dsp_chn_alloc() returns with the channel lock
held, dsp_open() calls dsp_close() as part of its cdevpriv error path,
and this causes both a mutex recursion on the channel lock in
dsp_close(), as well a lock order reversal.
Fixes: 02d4eeabfd73 ("sound: Allocate vchans on-demand")
Reported by: llm-postcr
MFC after: Immediately
Sponsored by: The FreeBSD Foundation
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D61793
linux: Destroy the per-VNET unit allocator after the cloners
linux_ifnet_vnet_uninit() deletes the unit number allocator that
linux_ifnet_departure() frees into. It ran at SI_SUB_INIT_IF,
SI_ORDER_ANY, the same slot in which lagg, vlan, edsc and ng_eiface
destroy the interfaces left in a dying vnet. Destructors of equal order
run in the reverse of the order their modules were loaded, so with
linux_common loaded after if_lagg the allocator was gone by the time
vnet_lagg_uninit() detached its interfaces, and removing a vnet jail that
still held a lagg interface panicked in free_unr().
Commit a23901a37be9 moved the destructor from SI_SUB_PROTO_IF to
SI_SUB_INIT_IF for the cloners that tear down earlier, which left this
tie.
Run the destructor at SI_ORDER_FIRST, which is after every destructor of
a later order in the same subsystem, whatever the load order. Move the
constructor with it.
[6 lines not shown]
LinuxKPI: Include <linux/fs.h> from <linux/mm.h>
and <linux/kernel.h> from <linux/io.h>.
This reproduces the same namespace pollution as Linux and will help us
to fix historical bug when these files were included from <linux/fb.h>.
Fix conflicting Linux name leakage appeared in qat(4) as result.
Differential Revision: https://reviews.freebsd.org/D60798
LinuxKPI: Add mapping_gfp_mask() and four more folio/pagemap helpers
Adds mapping_gfp_mask(), mapping_gfp_constraint(), mapping_set_unevictable(),
folio_page() and folio_file_page(), which Linux's drm_gem_get_pages() uses.
drm-kmod carries them in an overlay for virtio-gpu (freebsd/drm-kmod#517) today.
The mask is GFP_KERNEL, as shmem page allocation may sleep and ignores
the other flags. folio_page() and folio_file_page() are exact copies
from D58763, to not clash with it.
Signed-off-by: Denis Borovikov <denis.borovikov at gmail.com>
Reviewed by: wulf
Differential Revision: https://reviews.freebsd.org/D61217
LinuxKPI: Add PCI method for transferring framebuffer parameters
from LKPI video driver to FreeBSD native framebuffer driver.
This makes possible to attach framebuffer driver in traditional way
using newbus interface rather than direct calls into vt internals.
It is required to make LKPI framebuffer driver compatible with
fbd/vt_fb. As a consequence that allows us to switch back to vt_fb on
radeon driver where vt_drmfb regressions have been reported [1].
The method expects fbd device ivars pointed to FreeBSD fb_info
structure embedded in to Linux fb_info structure. See linux/fb.h.
Note that some out-of-tree non-PCI drm drivers may require similar
changes in parent bus drivers.
[1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=285088
PR: 285088
Differential Revision: https://reviews.freebsd.org/D60038
kern: Have .m rules depend sys/tools/makeobjops.awk
Generated _if.[ch] files have to be rebuilt after commit bf362c1b41c8
("kobj: convert KOBJOPLOOKUP() to returning pointer to function"). Add
a dependency on the build tool, similar to kmod.mk.
Build rules using NORMAL_M (defined in kern.pre.mk) presumably need a
similar treatment, but this restores (most of) the incremental build
now.
Reviewed by: jrtc27
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61821
tests/sigtramp_test: re-enable test on aarch64
This now passes on both aarch64 (since 6a936d939b88)
and amd64. It still fails on other architectures, so
keep the xfail.
PR: 289096
Sponsored by: The FreeBSD Foundation
pwd_altroot(): avoid creating new pwd structure if altroot does not change
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D60035
vfs: guard against altroot pointing to not a directory
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D60035
namei: disallow altroot for beneath lookups
Once namei_setup() has determined that the lookup is strictly relative,
set ni_rootdir to pwd_rdir and mark the lookup as already restarted,
which effectively disables restart on ENOENT.
This is done in namei_setup() and not in NDINIT(), because RBENEATH
might be set after NDINIT() by vn_open_cred() or inherited from
the dirfd in fgetvp_lookup(), and ISRESTARTED is cleared by
NDREINIT()/NDRESET().
Noted by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D60035
exec_new_vmspace(): drop altroot for native processes if setuid
Noted and reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D60035
libsysdecode: Avoid non-portable \> word end boundary in mktables
Whilst we bootstrap our own sed when building on non-FreeBSD, it uses
the system regex(3) implementation, and so inherits its extensions, not
our own. Our implementation and glibc's both include this extension to
POSIX, but macOS's does not, and so even with our bootstrap sed we
cannot use the \> extension when built and run on macOS.
Unfortunately, there is no alternative form we can use; whilst macOS
implements [[:>:]] as an extension that provides this same feature, and
so do we, the regex(3) implementation in glibc does not, and the only
alternative glibc offers is \b, which neither us nor macOS implement.
We could make the form used conditional on the OS, but that starts to
get messy once other Linux libcs enter the picture, which in theory we
somewhat support.
Rewrite both uses to avoid the need for \>. For gen_table, use a pattern
to match the identifier that is precisely the (non-extended) C99
[23 lines not shown]
nuageinit: Fix typo, whitespace, and lua style in new test
Fixes: e82b8378de19 ("nuageinit: Also add -n to pw usermod and pw groupshow")
Sponsored by: The FreeBSD Foundation