Linux kernel -stable discussions
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] ALSA: timer: Fix race between stop and interrupt" failed to apply to 4.4-stable tree
@ 2016-02-14 19:25 gregkh
  2016-02-14 20:14 ` Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2016-02-14 19:25 UTC (permalink / raw)
  To: tiwai, stable; +Cc: stable


The patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

>From ed8b1d6d2c741ab26d60d499d7fbb7ac801f0f51 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Tue, 9 Feb 2016 12:02:32 +0100
Subject: [PATCH] ALSA: timer: Fix race between stop and interrupt

A slave timer element also unlinks at snd_timer_stop() but it takes
only slave_active_lock.  When a slave is assigned to a master,
however, this may become a race against the master's interrupt
handling, eventually resulting in a list corruption.  The actual bug
could be seen with a syzkaller fuzzer test case in BugLink below.

As a fix, we need to take timeri->timer->lock when timer isn't NULL,
i.e. assigned to a master, while the assignment to a master itself is
protected by slave_active_lock.

BugLink: http://lkml.kernel.org/r/CACT4Y+Y_Bm+7epAb=8Wi=AaWd+DYS7qawX52qxdCfOfY49vozQ@mail.gmail.com
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

diff --git a/sound/core/timer.c b/sound/core/timer.c
index dea932ac6165..a0405b0078c6 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -518,9 +518,13 @@ static int _snd_timer_stop(struct snd_timer_instance *timeri, int event)
 			spin_unlock_irqrestore(&slave_active_lock, flags);
 			return -EBUSY;
 		}
+		if (timeri->timer)
+			spin_lock(&timeri->timer->lock);
 		timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
 		list_del_init(&timeri->ack_list);
 		list_del_init(&timeri->active_list);
+		if (timeri->timer)
+			spin_unlock(&timeri->timer->lock);
 		spin_unlock_irqrestore(&slave_active_lock, flags);
 		goto __end;
 	}


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: FAILED: patch "[PATCH] ALSA: timer: Fix race between stop and interrupt" failed to apply to 4.4-stable tree
  2016-02-14 19:25 FAILED: patch "[PATCH] ALSA: timer: Fix race between stop and interrupt" failed to apply to 4.4-stable tree gregkh
@ 2016-02-14 20:14 ` Takashi Iwai
  2016-02-14 20:37   ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2016-02-14 20:14 UTC (permalink / raw)
  To: gregkh; +Cc: stable

On Sun, 14 Feb 2016 20:25:55 +0100,
<gregkh@linuxfoundation.org> wrote:
> 
> 
> The patch below does not apply to the 4.4-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.

There is a prerequisite change by the commit
c3b1681375dc6e71d89a3ae00cc3ce9e775a8917
    ALSA: timer: Code cleanup

Could you cherry-pick it beforehand?


thanks,

Takashi

> 
> thanks,
> 
> greg k-h
> 
> ------------------ original commit in Linus's tree ------------------
> 
> >From ed8b1d6d2c741ab26d60d499d7fbb7ac801f0f51 Mon Sep 17 00:00:00 2001
> From: Takashi Iwai <tiwai@suse.de>
> Date: Tue, 9 Feb 2016 12:02:32 +0100
> Subject: [PATCH] ALSA: timer: Fix race between stop and interrupt
> 
> A slave timer element also unlinks at snd_timer_stop() but it takes
> only slave_active_lock.  When a slave is assigned to a master,
> however, this may become a race against the master's interrupt
> handling, eventually resulting in a list corruption.  The actual bug
> could be seen with a syzkaller fuzzer test case in BugLink below.
> 
> As a fix, we need to take timeri->timer->lock when timer isn't NULL,
> i.e. assigned to a master, while the assignment to a master itself is
> protected by slave_active_lock.
> 
> BugLink: http://lkml.kernel.org/r/CACT4Y+Y_Bm+7epAb=8Wi=AaWd+DYS7qawX52qxdCfOfY49vozQ@mail.gmail.com
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> 
> diff --git a/sound/core/timer.c b/sound/core/timer.c
> index dea932ac6165..a0405b0078c6 100644
> --- a/sound/core/timer.c
> +++ b/sound/core/timer.c
> @@ -518,9 +518,13 @@ static int _snd_timer_stop(struct snd_timer_instance *timeri, int event)
>  			spin_unlock_irqrestore(&slave_active_lock, flags);
>  			return -EBUSY;
>  		}
> +		if (timeri->timer)
> +			spin_lock(&timeri->timer->lock);
>  		timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
>  		list_del_init(&timeri->ack_list);
>  		list_del_init(&timeri->active_list);
> +		if (timeri->timer)
> +			spin_unlock(&timeri->timer->lock);
>  		spin_unlock_irqrestore(&slave_active_lock, flags);
>  		goto __end;
>  	}
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: FAILED: patch "[PATCH] ALSA: timer: Fix race between stop and interrupt" failed to apply to 4.4-stable tree
  2016-02-14 20:14 ` Takashi Iwai
@ 2016-02-14 20:37   ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2016-02-14 20:37 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: stable

On Sun, Feb 14, 2016 at 09:14:24PM +0100, Takashi Iwai wrote:
> On Sun, 14 Feb 2016 20:25:55 +0100,
> <gregkh@linuxfoundation.org> wrote:
> > 
> > 
> > The patch below does not apply to the 4.4-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
> 
> There is a prerequisite change by the commit
> c3b1681375dc6e71d89a3ae00cc3ce9e775a8917
>     ALSA: timer: Code cleanup
> 
> Could you cherry-pick it beforehand?

Ah, that makes sense, I had to hand-fix-up some other patches in this
series because I missed that one.  I'll add this, and then fix those
others as well, and add this one, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-14 20:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-14 19:25 FAILED: patch "[PATCH] ALSA: timer: Fix race between stop and interrupt" failed to apply to 4.4-stable tree gregkh
2016-02-14 20:14 ` Takashi Iwai
2016-02-14 20:37   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox