* [PATCH 6.6.y] ALSA: mixer: oss: Add card disconnect checkpoints
@ 2026-10-14 19:24 Artem Dinaburg
2026-10-15 19:35 ` Sasha Levin
0 siblings, 1 reply; 2+ messages in thread
From: Artem Dinaburg @ 2026-10-14 19:24 UTC (permalink / raw)
To: stable; +Cc: linux-kernel, linux-sound, perex, tiwai, tiwai
From: Takashi Iwai <tiwai@suse.de>
[ Upstream commit 084d5d44418148662365eced3e126ad1a81ee3e2 ]
ALSA OSS mixer layer calls the kcontrol ops rather individually, and
pending calls might be not always caught at disconnecting the device.
For avoiding the potential UAF scenarios, add sanity checks of the
card disconnection at each entry point of OSS mixer accesses. The
rwsem is taken just before that check, hence the rest context should
be covered by that properly.
Link: https://patch.msgid.link/20260209121212.171430-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Assisted-by: LLM
[ Backport to 6.6.y: Replace upstream scoped controls_rwsem release with
explicit unlocks or existing unlock labels on the added shutdown exits.
]
Signed-off-by: Artem Dinaburg <artem@trailofbits.com>
---
Hi,
Please consider this backport of the fix for CVE-2026-43126 to 6.6.y.
The code changes are identical to upstream, except explicit controls_rwsem
unlocks replace upstream scoped cleanup; see the bracketed backport note
above.
The complete fix is already present in 6.12.y, 6.18.y and 7.2.y.
Build-tested only as part of a cumulative 6.6.y series: x86_64 objects
(allmodconfig, CONFIG_WERROR=y); no runtime testing.
Thanks,
Artem Dinaburg
sound/core/oss/mixer_oss.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index abc99ae3332824183298ce329916b1787841dd35..ecb4af6709598c92dde791570a9b9703c8b81d48 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -540,6 +540,10 @@ static void snd_mixer_oss_get_volume1_vol(struct snd_mixer_oss_file *fmixer,
if (numid == ID_UNKNOWN)
return;
down_read(&card->controls_rwsem);
+ if (card->shutdown) {
+ up_read(&card->controls_rwsem);
+ return;
+ }
kctl = snd_ctl_find_numid_locked(card, numid);
if (!kctl) {
up_read(&card->controls_rwsem);
@@ -579,6 +583,10 @@ static void snd_mixer_oss_get_volume1_sw(struct snd_mixer_oss_file *fmixer,
if (numid == ID_UNKNOWN)
return;
down_read(&card->controls_rwsem);
+ if (card->shutdown) {
+ up_read(&card->controls_rwsem);
+ return;
+ }
kctl = snd_ctl_find_numid_locked(card, numid);
if (!kctl) {
up_read(&card->controls_rwsem);
@@ -645,6 +653,10 @@ static void snd_mixer_oss_put_volume1_vol(struct snd_mixer_oss_file *fmixer,
if (numid == ID_UNKNOWN)
return;
down_read(&card->controls_rwsem);
+ if (card->shutdown) {
+ up_read(&card->controls_rwsem);
+ return;
+ }
kctl = snd_ctl_find_numid_locked(card, numid);
if (!kctl) {
up_read(&card->controls_rwsem);
@@ -688,6 +700,10 @@ static void snd_mixer_oss_put_volume1_sw(struct snd_mixer_oss_file *fmixer,
if (numid == ID_UNKNOWN)
return;
down_read(&card->controls_rwsem);
+ if (card->shutdown) {
+ up_read(&card->controls_rwsem);
+ return;
+ }
kctl = snd_ctl_find_numid_locked(card, numid);
if (!kctl) {
up_read(&card->controls_rwsem);
@@ -833,6 +849,10 @@ static int snd_mixer_oss_get_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned
goto __free_only;
}
down_read(&card->controls_rwsem);
+ if (card->shutdown) {
+ err = -ENODEV;
+ goto __unlock;
+ }
kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0);
if (! kctl) {
err = -ENOENT;
@@ -886,6 +906,10 @@ static int snd_mixer_oss_put_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned
goto __free_only;
}
down_read(&card->controls_rwsem);
+ if (card->shutdown) {
+ err = -ENODEV;
+ goto __unlock;
+ }
kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0);
if (! kctl) {
err = -ENOENT;
@@ -937,6 +961,10 @@ static int snd_mixer_oss_build_test(struct snd_mixer_oss *mixer, struct slot *sl
int err;
down_read(&card->controls_rwsem);
+ if (card->shutdown) {
+ up_read(&card->controls_rwsem);
+ return -ENODEV;
+ }
kcontrol = snd_mixer_oss_test_id(mixer, name, index);
if (kcontrol == NULL) {
up_read(&card->controls_rwsem);
@@ -1069,6 +1097,10 @@ static int snd_mixer_oss_build_input(struct snd_mixer_oss *mixer,
if (snd_mixer_oss_build_test_all(mixer, ptr, &slot))
return 0;
down_read(&mixer->card->controls_rwsem);
+ if (mixer->card->shutdown) {
+ up_read(&mixer->card->controls_rwsem);
+ return -ENODEV;
+ }
kctl = NULL;
if (!ptr->index)
kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0);
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH 6.6.y] ALSA: mixer: oss: Add card disconnect checkpoints
2026-10-14 19:24 [PATCH 6.6.y] ALSA: mixer: oss: Add card disconnect checkpoints Artem Dinaburg
@ 2026-10-15 19:35 ` Sasha Levin
0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2026-10-15 19:35 UTC (permalink / raw)
To: stable
Cc: Sasha Levin, linux-kernel, linux-sound, perex, tiwai, tiwai,
Artem Dinaburg
> ALSA OSS mixer layer calls the kcontrol ops rather individually, and
> pending calls might be not always caught at disconnecting the device.
>
Queued for 6.6, thanks.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-15 19:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-14 19:24 [PATCH 6.6.y] ALSA: mixer: oss: Add card disconnect checkpoints Artem Dinaburg
2026-10-15 19:35 ` Sasha Levin
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®