[3.13.y-ckt stable] Patch "ALSA: timer: Fix race between stop and interrupt" has been added to the 3.13.y-ckt tree

Kamal Mostafa kamal at canonical.com
Wed Mar 9 23:10:40 UTC 2016


This is a note to let you know that I have just added a patch titled

    ALSA: timer: Fix race between stop and interrupt

to the linux-3.13.y-queue branch of the 3.13.y-ckt extended stable tree 
which can be found at:

    http://kernel.ubuntu.com/git/ubuntu/linux.git/log/?h=linux-3.13.y-queue

This patch is scheduled to be released in version 3.13.11-ckt36.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.13.y-ckt tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

---8<------------------------------------------------------------

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

commit ed8b1d6d2c741ab26d60d499d7fbb7ac801f0f51 upstream.

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
Signed-off-by: Takashi Iwai <tiwai at suse.de>
[ kamal: backport to 3.13-stable: context ]
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
---
 sound/core/timer.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/core/timer.c b/sound/core/timer.c
index 44cbdde..cbb127b 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -511,9 +511,13 @@ static int _snd_timer_stop(struct snd_timer_instance * timeri,
 				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;
--
2.7.0





More information about the kernel-team mailing list