From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754799AbcBPKAm (ORCPT ); Tue, 16 Feb 2016 05:00:42 -0500 Received: from mx2.suse.de ([195.135.220.15]:54923 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754745AbcBPKAg (ORCPT ); Tue, 16 Feb 2016 05:00:36 -0500 Date: Tue, 16 Feb 2016 11:00:35 +0100 Message-ID: From: Takashi Iwai To: "Dmitry Vyukov" Cc: , "Jaroslav Kysela" , "LKML" , "Alexander Potapenko" , "Kostya Serebryany" , "syzkaller" , "Sasha Levin" Subject: Re: sound: list corruption in delete_and_unsubscribe_port In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/24.5 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 16 Feb 2016 10:41:54 +0100, Dmitry Vyukov wrote: > > Hello, > > Here is a new one on 18558cae0272f8fd9647e69d3fec1565a7949865 > (4.5-rc4). But need to note that sound become much more stable, I've > seen only 2 of these over night. > > The following program causes list corruption: > > ------------[ cut here ]------------ > WARNING: CPU: 2 PID: 12546 at lib/list_debug.c:62 __list_del_entry+0x10b/0x1e0() > list_del corruption, ffff880063512388->next is LIST_POISON1 (dead000000000100) > Modules linked in: > CPU: 2 PID: 12546 Comm: a.out Not tainted 4.5.0-rc4+ #328 > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 > ffffffff87b05080 ffff8800608b7a48 ffffffff82be46cf ffffffff81477fb8 > fffffbfff0f60a10 ffff8800608b7ab8 ffff8800637d97c0 ffffffff86ad3780 > 0000000000000009 000000000000003e ffff8800608b7a88 ffffffff81355139 > Call Trace: > [] warn_slowpath_fmt+0xa9/0xd0 kernel/panic.c:494 > [] __list_del_entry+0x10b/0x1e0 lib/list_debug.c:60 > [] list_del+0xd/0x70 lib/list_debug.c:86 > [] delete_and_unsubscribe_port+0x1e3/0x2f0 > sound/core/seq/seq_ports.c:545 > [] clear_subscriber_list+0x15a/0x260 > sound/core/seq/seq_ports.c:250 > [] port_delete+0x6a/0x1c0 sound/core/seq/seq_ports.c:266 > [] snd_seq_delete_all_ports+0x242/0x350 > sound/core/seq/seq_ports.c:330 > [] seq_free_client1+0x2f/0x290 > sound/core/seq/seq_clientmgr.c:272 > [] seq_free_client+0x65/0x160 > sound/core/seq/seq_clientmgr.c:299 > [] snd_seq_release+0x4d/0xb0 > sound/core/seq/seq_clientmgr.c:380 > [] __fput+0x236/0x780 fs/file_table.c:208 > [] ____fput+0x15/0x20 fs/file_table.c:244 > [] task_work_run+0x170/0x210 kernel/task_work.c:115 > [< inline >] tracehook_notify_resume include/linux/tracehook.h:191 > [] exit_to_usermode_loop+0x1d1/0x210 > arch/x86/entry/common.c:251 > [< inline >] prepare_exit_to_usermode arch/x86/entry/common.c:282 > [] syscall_return_slowpath+0x2ba/0x340 > arch/x86/entry/common.c:344 > [] int_ret_from_sys_call+0x25/0x9f > arch/x86/entry/entry_64.S:281 > ---[ end trace 4cad985f706f8ace ]--- Hm, this might be the remaining open race at deleting ports. Please try the patch below. thanks, Takashi --- diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c index 921fb2bd8fad..fe686ee41c6d 100644 --- a/sound/core/seq/seq_ports.c +++ b/sound/core/seq/seq_ports.c @@ -535,19 +535,22 @@ static void delete_and_unsubscribe_port(struct snd_seq_client *client, bool is_src, bool ack) { struct snd_seq_port_subs_info *grp; + struct list_head *list; + bool empty; grp = is_src ? &port->c_src : &port->c_dest; + list = is_src ? &subs->src_list : &subs->dest_list; down_write(&grp->list_mutex); write_lock_irq(&grp->list_lock); - if (is_src) - list_del(&subs->src_list); - else - list_del(&subs->dest_list); + empty = list_empty(list); + if (!empty) + list_del_init(list); grp->exclusive = 0; write_unlock_irq(&grp->list_lock); up_write(&grp->list_mutex); - unsubscribe_port(client, port, grp, &subs->info, ack); + if (!empty) + unsubscribe_port(client, port, grp, &subs->info, ack); } /* connect two ports */