From: Dmitriy Chumachenko <Dmitry.Chumachenko@cyberprotect.ru>
To: Jaroslav Kysela <perex@perex.cz>
Cc: 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>,
Dmitriy Chumachenko <Dmitry.Chumachenko@cyberprotect.ru>
Subject: [PATCH v2] ALSA: pcm_oss: reject buffer reconfiguration while the stream is mmapped
Date: Wed, 18 Nov 2026 16:19:45 +0300 [thread overview]
Message-ID: <20261118131945.27592-1-Dmitry.Chumachenko@cyberprotect.ru> (raw)
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>
---
v2: Fix the root cause in the OSS layer instead of silencing the core
warning. v1 dropped the WARN_ON_ONCE() in snd_pcm_mmap_data_fault();
v2 refuses to reconfigure (and free) the buffer while a data mapping
is active, which is what left dma_area NULL.
sound/core/oss/pcm_oss.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 2dbc27831eb3..4ce9ecaa6ab1 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -861,6 +861,8 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
if (!runtime->oss.params)
return 0;
+ if (atomic_read(&substream->mmap_count))
+ return -EBADFD;
sw_params = kzalloc_obj(*sw_params);
params = kmalloc_obj(*params);
sparams = kmalloc_obj(*sparams);
--
2.49.0
next reply other threads:[~2026-11-18 13:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 13:19 Dmitriy Chumachenko [this message]
2026-11-18 13:47 ` Takashi Iwai
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=20261118131945.27592-1-Dmitry.Chumachenko@cyberprotect.ru \
--to=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
all inboxes | Powered by JetHome®