From: Nick Desaulniers <ndesaulniers@google.com>
To: unlisted-recipients:; (no To-header on input)
Cc: keescook@chromium.org, Robb Glasser <rglasser@google.com>,
Nick Desaulniers <ndesaulniers@google.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Markus Elfring <elfring@users.sourceforge.net>,
Takashi Sakamoto <o-takashi@sakamocchi.jp>,
Arvind Yadav <arvind.yadav.cs@gmail.com>,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ALSA: pcm: prevent UAF in snd_pcm_info
Date: Tue, 5 Dec 2017 09:16:55 -0800 [thread overview]
Message-ID: <20171205171657.74392-1-ndesaulniers@google.com> (raw)
From: Robb Glasser <rglasser@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`.
Signed-off-by: Robb Glasser <rglasser@google.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
sound/core/pcm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index 9070f277f8db..09ee8c6b9f75 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -153,7 +153,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(®ister_mutex);
return err;
--
2.15.0.531.g2ccb3012c9-goog
next reply other threads:[~2017-12-05 17:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-05 17:16 Nick Desaulniers [this message]
2017-12-05 17:19 ` [PATCH] ALSA: pcm: prevent UAF in snd_pcm_info Nick Desaulniers
2017-12-05 17:26 ` Greg KH
2017-12-05 19:14 ` Takashi Iwai
2017-12-05 19:29 ` Kees Cook
2017-12-05 22:30 ` Takashi Iwai
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=20171205171657.74392-1-ndesaulniers@google.com \
--to=ndesaulniers@google.com \
--cc=alsa-devel@alsa-project.org \
--cc=arvind.yadav.cs@gmail.com \
--cc=elfring@users.sourceforge.net \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=o-takashi@sakamocchi.jp \
--cc=perex@perex.cz \
--cc=rglasser@google.com \
--cc=tiwai@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).