From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Takashi Iwai <tiwai@suse.de>, Bo Cao <treebacker@foxmail.com>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.10.y] ALSA: pcm: Prevent O_APPEND open on OSS streams
Date: Thu, 12 Nov 2026 22:24:06 -0500 [thread overview]
Message-ID: <20261113032342.850566-1-sashal@kernel.org> (raw)
In-Reply-To: <20261109202903-failed-5.10-9017bc3d13da@kernel.org>
From: Takashi Iwai <tiwai@suse.de>
[ Upstream commit 9017bc3d13da0ea4e63be618c87143a7b69185e6 ]
ALSA PCM core accepts to re-use the existing stream when O_APPEND is
passed, and it's been used for dmix, etc. However, this mode isn't
supposed to be used for OSS: the OSS stream allows re-configuration
via its hw_params/hw_refine procedure even while it's being mmapped,
so it implies the usage of only a single stream. Because of this
assumption, the sanity check is skipped for OSS streams, and if user
may attach to an existing OSS stream with O_APPEND, it may result in a
UAF of the mapped pages which could be used as a privilege escalation
exploit.
For addressing it, this patch simply prohibits the O_APPEND behavior
on the OSS stream. O_APPEND is never used for OSS layer itself, so
this can't break for the right applications.
Fixes: 0df63e44c3e3 ("[ALSA] Add O_APPEND flag support to PCM")
Cc: stable@vger.kernel.org
Reported-by: Bo Cao <treebacker@foxmail.com>
Link: https://lore.kernel.org/tencent_E90BB4F086165FAA3313723567A5C675EA06@qq.com
Link: https://patch.msgid.link/20261103155844.120838-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
[ sashal: Adjusted context for relocating the is_oss_stream macro because surrounding helpers are absent. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/core/pcm.c | 2 ++
sound/core/pcm_local.h | 6 ++++++
sound/core/pcm_native.c | 6 ------
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index bec81f6ba6ba5..d4eb842784143 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -930,6 +930,8 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
return -ENODEV;
if (! SUBSTREAM_BUSY(substream))
return -EBADFD;
+ if (is_oss_stream(substream))
+ return -EINVAL;
substream->ref_count++;
*rsubstream = substream;
return 0;
diff --git a/sound/core/pcm_local.h b/sound/core/pcm_local.h
index b3e8be5aeafb3..353f675724337 100644
--- a/sound/core/pcm_local.h
+++ b/sound/core/pcm_local.h
@@ -72,4 +72,10 @@ struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream,
#define PCM_RUNTIME_CHECK(sub) snd_BUG_ON(!(sub) || !(sub)->runtime)
+#if IS_ENABLED(CONFIG_SND_PCM_OSS)
+#define is_oss_stream(substream) ((substream)->oss.oss)
+#else
+#define is_oss_stream(substream) false
+#endif
+
#endif /* __SOUND_CORE_PCM_LOCAL_H */
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 40020c5dceda0..7b6902bf0fd12 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -702,12 +702,6 @@ int snd_pcm_runtime_buffer_set_silence(struct snd_pcm_runtime *runtime)
}
EXPORT_SYMBOL_GPL(snd_pcm_runtime_buffer_set_silence);
-#if IS_ENABLED(CONFIG_SND_PCM_OSS)
-#define is_oss_stream(substream) ((substream)->oss.oss)
-#else
-#define is_oss_stream(substream) false
-#endif
-
static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
--
2.53.0
prev parent reply other threads:[~2026-11-13 3:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 1:29 FAILED: patch "[PATCH] ALSA: pcm: Prevent O_APPEND open on OSS streams" failed to apply to 5.10-stable tree Sasha Levin
2026-11-13 3:24 ` Sasha Levin [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=20261113032342.850566-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.de \
--cc=treebacker@foxmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.