Re: [PATCH 1/3] ALSA: pcm: Remove is_oss_stream() bypass of mmap_count check

From: Takashi Iwai

Date: Wed Dec 02 2026 - 09:20:45 EST


On Wed, 02 Dec 2026 15:01:15 +0100,
Ahmed Abdelmoemen wrote:
>
> hw_params_state_check() skips the mmap_count guard for OSS streams via
> the is_oss_stream() condition. This lets hw_params run while userspace
> holds a live VM_PFNMAP mapping obtained through /dev/dsp.
>
> remap_pfn_range() mappings (VM_PFNMAP) carry no page reference counts,
> so the kernel cannot revoke them when hw_params reconfigures or
> reallocates the DMA buffer. The buffer can be cleared or freed while
> userspace retains read/write access to it.
>
> Removing the bypass restores the intended safety invariant: an OSS
> caller holding a mapping gets -EBADFD on reconfiguration, the same as a
> native PCM stream. Reconfiguring the buffer under an active mapping is
> never safe regardless of stream type.
>
> Fixes: 92ee3c60ec9f ("ALSA: pcm: Fix races among concurrent hw_params and hw_free calls")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Ahmed Abdelmoemen <ahmedabdelmoumen05@xxxxxxxxx>

The same fix is already on sound.git tree for-next branch.


thanks,

Takashi