From: Takashi Iwai <tiwai@suse.de>
To: Dmitriy Chumachenko <Dmitry.Chumachenko@cyberprotect.ru>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sasha Levin <sashal@kernel.org>,
Oswald Buddenhagen <oswald.buddenhagen@gmx.de>,
Mehul Rao <mehulrao@gmail.com>,
Ji'an Zhou <eilaimemedsnaimel@gmail.com>,
Norbert Szetei <norbert@doyensec.com>,
<alsa-devel@alsa-project.org>, <linux-kernel@vger.kernel.org>,
<lvc-project@linuxtesting.org>
Subject: Re: [PATCH v2] ALSA: pcm_oss: reject buffer reconfiguration while the stream is mmapped
Date: Wed, 18 Nov 2026 14:47:09 +0100 [thread overview]
Message-ID: <87h5hew8te.wl-tiwai@suse.de> (raw)
In-Reply-To: <20261118131945.27592-1-Dmitry.Chumachenko@cyberprotect.ru>
On Wed, 18 Nov 2026 14:19:45 +0100,
Dmitriy Chumachenko wrote:
>
> During fuzz testing, the following issue was discovered.
>
> WARNING: CPU: 2 PID: 1734 at sound/core/pcm_native.c:3835
> snd_pcm_mmap_data_fault+0x47f/0x530 sound/core/pcm_native.c:3835
>
> Modules linked in:
> CPU: 2 PID: 1734 Comm: syz.1.352 Not tainted 6.1.187-syzkaller-00593-g063a81552262 #0
> RIP: 0010:snd_pcm_mmap_data_fault+0x47f/0x530 sound/core/pcm_native.c:3835
>
> Call Trace:
> <TASK>
> __do_fault+0x10d/0x480 mm/memory.c:4280
> do_cow_fault mm/memory.c:4661 [inline]
> do_fault+0xa7a/0x1100 mm/memory.c:4762
> handle_pte_fault mm/memory.c:5031 [inline]
> __handle_mm_fault+0xdf3/0x2e40 mm/memory.c:5173
> handle_mm_fault+0x2da/0xa60 mm/memory.c:5294
> do_user_addr_fault+0x4aa/0x1050 arch/x86/mm/fault.c:1338
> handle_page_fault arch/x86/mm/fault.c:1429 [inline]
> exc_page_fault+0x98/0x1b0 arch/x86/mm/fault.c:1482
> asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:608
>
> snd_pcm_oss_change_params() frees and reallocates the substream buffer,
> and several OSS entry points reach it while the data area may already be
> mmapped: snd_pcm_oss_mmap() and the SNDCTL_DSP_GETOSPACE/GETISPACE ioctls
> (snd_pcm_oss_get_space()).
>
> For OSS streams snd_pcm_hw_params() skips the mmap_count guard
> (!is_oss_stream), so the buffer is torn down under a live mapping. If the
> reallocation then fails, the substream is left with runtime->dma_area ==
> NULL, and the next page fault on the stale mapping reaches
> snd_pcm_mmap_data_fault() with no buffer, hitting the WARN_ON_ONCE().
>
> Reject the reconfiguration in snd_pcm_oss_change_params_locked() when the
> stream is already mmapped; this covers all callers (read/write already
> bail out earlier on a non-zero mmap_count). The core WARN_ON_ONCE() is
> left in place.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Dmitriy Chumachenko <Dmitry.Chumachenko@cyberprotect.ru>
Well, if we want to restrict the hw_params with mmap completely, it's
easier just drop the exception for OSS in the PCM core, instead:
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -778,7 +778,7 @@ static int hw_params_state_check(struct snd_pcm_substream *substream,
case SNDRV_PCM_STATE_OPEN:
case SNDRV_PCM_STATE_SETUP:
case SNDRV_PCM_STATE_PREPARED:
- if (check_mmap && !is_oss_stream(substream) &&
+ if (check_mmap &&
atomic_read(&substream->mmap_count))
return -EBADFD;
return 0;
But, there must be some reason for this explicitly allowance for OSS
(maybe some apps like the old game need it), and the above (and your)
change would break it.
So, if we really want to guarantee the compatibility for old existing
applications, we need some other ways to check the buffer reallocation
instead (e.g. disallow the buffer byte size change). Though, I'm not
sure whether it's worth...
thanks,
Takashi
prev parent reply other threads:[~2026-11-18 13:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 13:19 [PATCH v2] ALSA: pcm_oss: reject buffer reconfiguration while the stream is mmapped Dmitriy Chumachenko
2026-11-18 13:47 ` Takashi Iwai [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h5hew8te.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=Dmitry.Chumachenko@cyberprotect.ru \
--cc=alsa-devel@alsa-project.org \
--cc=eilaimemedsnaimel@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=mehulrao@gmail.com \
--cc=norbert@doyensec.com \
--cc=oswald.buddenhagen@gmx.de \
--cc=perex@perex.cz \
--cc=sashal@kernel.org \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox