From: Takashi Iwai <tiwai@suse.de>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: alsa-devel@alsa-project.org, Jie Yang <yang.jie@intel.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
LKML <linux-kernel@vger.kernel.org>,
Eric Dumazet <edumazet@google.com>,
Alexander Potapenko <glider@google.com>,
Kostya Serebryany <kcc@google.com>,
syzkaller <syzkaller@googlegroups.com>,
Sasha Levin <sasha.levin@oracle.com>
Subject: Re: sound: use-after-free in snd_timer_interrupt
Date: Wed, 13 Jan 2016 21:45:48 +0100 [thread overview]
Message-ID: <s5h8u3tmcn7.wl-tiwai@suse.de> (raw)
In-Reply-To: <CACT4Y+bqxg_C7JmnUSRm_9jiZ9R9XqbBV0igDdUW1ZhtqvktJw@mail.gmail.com>
On Wed, 13 Jan 2016 20:30:01 +0100,
Dmitry Vyukov wrote:
>
> On Wed, Jan 13, 2016 at 8:05 PM, Takashi Iwai <tiwai@suse.de> wrote:
> > On Wed, 13 Jan 2016 19:34:36 +0100,
> > Dmitry Vyukov wrote:
> >>
> >> On Wed, Jan 13, 2016 at 5:53 PM, Takashi Iwai <tiwai@suse.de> wrote:
> >> > This and your other relevant reports seem pointing the race of timer
> >> > ioctls. Although snd_timer_close() itself calls snd_timer_stop(),
> >> > there is no other protection against the concurrent execution.
> >> >
> >> > If my guess is correct, a simplistic fix like below should work. It
> >> > basically serializes the timer ioctl by using a new mutex (and
> >> > replacing the old tread_sem mutex). They are no longtime blocking
> >> > calls, so this shouldn't be a big problem. But certainly there can be
> >> > a less intrusive way to paper over this if this really matters.
> >> >
> >> > In this case for timer.c, I'd leave the final decision rather to
> >> > Jaroslav. Jaroslav, what do you think?
> >>
> >>
> >> After applying this patch I still see the following WARNINGS:
> >>
> >> ------------[ cut here ]------------
> >> WARNING: CPU: 2 PID: 30398 at lib/list_debug.c:53 __list_del_entry+0x10b/0x1e0()
> >> list_del corruption, ffff880032d933b0->next is LIST_POISON1 (dead000000000100)
> >> Modules linked in:
> >> CPU: 2 PID: 30398 Comm: syz-executor Not tainted 4.4.0+ #241
> >> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
> >> 00000000ffffffff ffff8800627778d8 ffffffff82926eed ffff880062777948
> >> ffff880061c2af80 ffffffff8660b640 ffff880062777918 ffffffff81350c89
> >> ffffffff8298e77b ffffed000c4eef25 ffffffff8660b640 0000000000000035
> >> Call Trace:
> >> [< inline >] __dump_stack lib/dump_stack.c:15
> >> [<ffffffff82926eed>] dump_stack+0x6f/0xa2 lib/dump_stack.c:50
> >> [<ffffffff81350c89>] warn_slowpath_common+0xd9/0x140 kernel/panic.c:483
> >> [<ffffffff81350d99>] warn_slowpath_fmt+0xa9/0xd0 kernel/panic.c:495
> >> [<ffffffff8298e77b>] __list_del_entry+0x10b/0x1e0 lib/list_debug.c:51
> >> [< inline >] list_del_init include/linux/list.h:145
> >> [<ffffffff84ebd199>] _snd_timer_stop+0x119/0x450 sound/core/timer.c:501
> >
> > This is
> >
> > list_del_init(&timeri->active_list);
> >
> > right? Possibly the following oneliner covers it?
>
> Yes, that is this line.
> Yes, these two patches fix use-after-frees and GPFs.
>
> Tested-by: Dmitry Vyukov <dvyukov@google.com>
OK, I'm going to queue the list fix now, at least. Below is the
patch with a proper description.
If there comes no objection, I'll queue the former ioctl mutex fix,
too.
> The only one that still happens is "sound: spinlock lockup in
> sound/core/timer.c".
Oh well, there is another :-<
thanks,
Takashi
-- 8< --
From: Takashi Iwai <tiwai@suse.de>
Subject: [PATCH] ALSA: timer: Fix double unlink of active_list
ALSA timer instance object has a couple of linked lists and they are
unlinked unconditionally at snd_timer_stop(). Meanwhile
snd_timer_interrupt() unlinks it, but it calls list_del() which leaves
the element list itself unchanged. This ends up with unlinking twice,
and it was caught by syzkaller fuzzer.
The fix is to use list_del_init() variant properly there, too.
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Tested-by: Dmitry Vyukov <dvyukov@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/core/timer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/core/timer.c b/sound/core/timer.c
index 31f40f03e5b7..9241784dfe7d 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -694,7 +694,7 @@ void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left)
} else {
ti->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
if (--timer->running)
- list_del(&ti->active_list);
+ list_del_init(&ti->active_list);
}
if ((timer->hw.flags & SNDRV_TIMER_HW_TASKLET) ||
(ti->flags & SNDRV_TIMER_IFLG_FAST))
--
2.7.0
next prev parent reply other threads:[~2016-01-13 20:45 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-13 15:00 Dmitry Vyukov
2016-01-13 16:53 ` Takashi Iwai
2016-01-13 18:34 ` Dmitry Vyukov
2016-01-13 19:05 ` Takashi Iwai
2016-01-13 19:30 ` Dmitry Vyukov
2016-01-13 19:41 ` Dmitry Vyukov
2016-01-13 20:30 ` Takashi Iwai
2016-01-13 20:48 ` Dmitry Vyukov
2016-01-13 20:54 ` Takashi Iwai
2016-01-14 16:09 ` Takashi Iwai
2016-01-15 8:06 ` Dmitry Vyukov
2016-01-15 11:00 ` Takashi Iwai
2016-01-15 11:03 ` Dmitry Vyukov
2016-01-15 13:51 ` Takashi Iwai
2016-01-15 14:38 ` Dmitry Vyukov
2016-01-15 15:21 ` Takashi Iwai
2016-01-15 15:28 ` Dmitry Vyukov
2016-01-15 15:39 ` Takashi Iwai
2016-01-15 19:13 ` Dmitry Vyukov
2016-01-15 19:18 ` Takashi Iwai
2016-01-15 19:47 ` Dmitry Vyukov
2016-01-15 21:22 ` Takashi Iwai
2016-01-15 21:44 ` Takashi Iwai
2016-01-18 10:53 ` Dmitry Vyukov
2016-01-18 13:06 ` Takashi Iwai
2016-01-18 13:30 ` Dmitry Vyukov
2016-01-18 13:36 ` Takashi Iwai
2016-01-13 20:45 ` Takashi Iwai [this message]
2016-04-02 9:08 Dmitry Vyukov
2016-04-02 16:30 ` Takashi Iwai
2016-04-03 6:06 ` Dmitry Vyukov
2016-04-03 6:33 ` Takashi Iwai
2016-04-20 7:56 ` Dmitry Vyukov
2016-04-20 8:08 ` Takashi Iwai
2016-04-20 10:31 ` Takashi Iwai
2016-04-21 8:14 ` Dmitry Vyukov
2016-04-21 8:31 ` 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=s5h8u3tmcn7.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=dvyukov@google.com \
--cc=edumazet@google.com \
--cc=glider@google.com \
--cc=kcc@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=sasha.levin@oracle.com \
--cc=syzkaller@googlegroups.com \
--cc=yang.jie@intel.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
all inboxes | Powered by JetHome®