ALSA: mixer: oss: Add card disconnect checkpoints
Subsystems (2)
PATCH 1/1 ALSA: mixer: oss: Add card disconnect checkpoints
From: Takashi Iwai <[email protected]>
[ 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.
[ Backport to 6.6.y: Replace upstream scoped controls_rwsem release with
explicit unlocks or existing unlock labels on the added shutdown exits. ]
---
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(+)
sound/core/oss/mixer_oss.c +32 -0
@@ -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 *slint 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 );
Quoted 3 lines
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.
Signature · 2 lines
Thanks, Sasha