[SRU][Trusty][Artful][PATCH 1/1] ALSA: pcm: prevent UAF in snd_pcm_info

Kleber Sacilotto de Souza kleber.souza at canonical.com
Fri Jan 26 16:11:23 UTC 2018


From: Robb Glasser <rglasser at google.com>

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`.

Note: this fixes CVE-2017-0861

Signed-off-by: Robb Glasser <rglasser at google.com>
Signed-off-by: Nick Desaulniers <ndesaulniers at google.com>
Cc: <stable at vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai at suse.de>

CVE-2017-0861
(cherry picked from commit 362bca57f5d78220f8b5907b875961af9436e229)
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza at canonical.com>
---
 sound/core/pcm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index e1e9e0c999fe..5e95bc66f817 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;
-- 
2.14.1





More information about the kernel-team mailing list