mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
sndbuf_resize() and sndbuf_remalloc() drop the channel lock in order to allocate the new buffer(s) with M_WAITOK. Before doing that they verify that the buffer is not mapped, but this could change while the lock is dropped, as there is no higher-level synchronization which prevents buffer resize (e.g., via the SNDCTL_DSP_SETBLKSIZE ioctl) from happening concurrently with mmap. Thus, these checks are insufficient. Modify sndbuf_resize() and sndbuf_remalloc() to revalidate after reacquiring the lock. Extend them to check for a couple of channel flags, mirroring the check in chn_resizebuf(). Modify chn_resizebuf() to revalidate state after reacquiring the channel lock. We could also allocate new buffers with M_NOWAIT and so avoid dropping the lock. Then, I think we could go even further and invoke CHANNEL_SETBLOCKSIZE and CHANNEL_SETFRAGMENTS with the channel lock held. But really it would be better to ensure that dsp operations are serialized; there is no reason for mmap and chn_resizebuf() to be able to run in parallel, we should not be relying on the channel lock for this. So, let's keep a more minimal approach here. Add a simple regression test. Approved by: so Security: FreeBSD-SA-26:71.sound Security: CVE-2026-101308 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D60554