aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobb Glasser <rglasser@google.com>2017-08-11 11:33:31 -0700
committerMoyster <oysterized@gmail.com>2017-11-09 13:15:11 +0100
commita7af0f1f7823ddabff5f92ad8526cbb3cbcc015e (patch)
tree8a89df699a20175c2e3a406ee3c5976d333802b8
parent5043daa42364c738092bfffe5c602540dfff8f0c (diff)
ALSA: pcm: prevent UAF in snd_pcm_info
When the device descriptor is closed, the `substream->runtime` pointer is freed. But another thread may be in the ioctl handler, case SNDRV_CTL_IOCTL_PCM_INFO. This case calls snd_pcm_info_user() which calls snd_pcm_info() which accesses the now freed `substream->runtime`. Bug: 36006981 Signed-off-by: Robb Glasser <rglasser@google.com> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> Change-Id: I445d24bc21dc0af6d9522a8daabe64969042236a
-rw-r--r--sound/core/pcm.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index e1e9e0c99..5e95bc66f 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -150,7 +150,9 @@ static int snd_pcm_control_ioctl(struct snd_card *card,
err = -ENXIO;
goto _error;
}
+ mutex_lock(&pcm->open_mutex);
err = snd_pcm_info_user(substream, info);
+ mutex_unlock(&pcm->open_mutex);
_error:
mutex_unlock(&register_mutex);
return err;