diff mbox series

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

Message ID 20180126161123.1853-2-kleber.souza@canonical.com
State New
Headers show
Series Fix for CVE-2017-0861 | expand

Commit Message

Kleber Sacilotto de Souza Jan. 26, 2018, 4:11 p.m. UTC
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`.

Note: this fixes CVE-2017-0861

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

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

Comments

Colin Ian King Jan. 26, 2018, 4:18 p.m. UTC | #1
On 26/01/18 16:11, Kleber Sacilotto de Souza wrote:
> 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`.
> 
> Note: this fixes CVE-2017-0861
> 
> Signed-off-by: Robb Glasser <rglasser@google.com>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> 
> CVE-2017-0861
> (cherry picked from commit 362bca57f5d78220f8b5907b875961af9436e229)
> Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@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;
> 

Clean cherry pick. Looks sane to me.

Acked-by: Colin Ian King <colin.king@canonical.com>
Khalid Elmously Jan. 26, 2018, 4:28 p.m. UTC | #2
On 2018-01-26 17:11:23 , Kleber Sacilotto de Souza wrote:
> 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`.
> 
> Note: this fixes CVE-2017-0861
> 
> Signed-off-by: Robb Glasser <rglasser@google.com>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> 
> CVE-2017-0861
> (cherry picked from commit 362bca57f5d78220f8b5907b875961af9436e229)
> Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@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;

Acked-by: Khalid Elmously <khalid.elmously@canonical.com>
Khalid Elmously Jan. 26, 2018, 4:32 p.m. UTC | #3
On 2018-01-26 17:11:23 , Kleber Sacilotto de Souza wrote:
> 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`.
> 
> Note: this fixes CVE-2017-0861
> 
> Signed-off-by: Robb Glasser <rglasser@google.com>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> 
> CVE-2017-0861
> (cherry picked from commit 362bca57f5d78220f8b5907b875961af9436e229)
> Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@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;

Added 'ACK' to the subject line.

Acked-by: Khalid Elmously <khalid.elmously@canonical.com>
Stefan Bader Feb. 2, 2018, 9:33 a.m. UTC | #4
On 26.01.2018 17:11, Kleber Sacilotto de Souza wrote:
> 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`.
> 
> Note: this fixes CVE-2017-0861
> 
> Signed-off-by: Robb Glasser <rglasser@google.com>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> 
> CVE-2017-0861
> (cherry picked from commit 362bca57f5d78220f8b5907b875961af9436e229)
> Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@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;
>
diff mbox series

Patch

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;