Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1521856

Re: BUG: KASAN: use-after-free in snd_usb_audio_free

From Shuah Khan <shuahkh@osg.samsung.com>
Newsgroups linux.kernel
Subject Re: BUG: KASAN: use-after-free in snd_usb_audio_free
Date 2016-11-14 18:00 +0100
Message-ID <sDsLU-16h-11@gated-at.bofh.it> (permalink)
References <sCtAl-2zT-7@gated-at.bofh.it> <sDmGu-5IO-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 11/14/2016 03:25 AM, Takashi Iwai wrote:
> On Sat, 12 Nov 2016 00:34:38 +0100,
> Shuah Khan wrote:
>>
>> Hi Takashi,
>>
>> I am seeing the following use-after-free error when I disconnect an
>> USB speaker. I saw this on 4.9-rc4 and 4.8.7. There might be race
>> condition between the disconnect and pcm close perhaps.
> 
> Thanks, this looks like a new discovery.
> Could you check whether the patch below works?
> 
> 
> Takashi
> 
> ---
> diff --git a/sound/usb/card.c b/sound/usb/card.c
> index 9e5276d6dda0..2ddc034673a8 100644
> --- a/sound/usb/card.c
> +++ b/sound/usb/card.c
> @@ -315,7 +315,8 @@ static int snd_usb_audio_free(struct snd_usb_audio *chip)
>  		snd_usb_endpoint_free(ep);
>  
>  	mutex_destroy(&chip->mutex);
> -	dev_set_drvdata(&chip->dev->dev, NULL);
> +	if (!atomic_read(&chip->shutdown))
> +		dev_set_drvdata(&chip->dev->dev, NULL);
>  	kfree(chip);
>  	return 0;
>  }
> 

Hi Takashi,

The patch fixed the problem on 4.9-rc4. Didn't get a chance
to test it on 4.8.7.

thanks,
-- Shuah

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

BUG: KASAN: use-after-free in snd_usb_audio_free Shuah Khan <shuahkhan@gmail.com> - 2016-11-12 00:40 +0100
  Re: BUG: KASAN: use-after-free in snd_usb_audio_free Takashi Iwai <tiwai@suse.de> - 2016-11-14 11:30 +0100
    Re: BUG: KASAN: use-after-free in snd_usb_audio_free Shuah Khan <shuahkh@osg.samsung.com> - 2016-11-14 18:00 +0100
      Re: BUG: KASAN: use-after-free in snd_usb_audio_free Takashi Iwai <tiwai@suse.de> - 2016-11-14 22:10 +0100

csiph-web