Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp562804ybt; Fri, 10 Jul 2020 07:00:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwigg2x58h5AmOtWwkSCFc/yVTxdbVK7b+tad28jvEWwjJV2ywK2TfGgqgYuE4wvzXAVEQQ X-Received: by 2002:a17:906:66d0:: with SMTP id k16mr63014349ejp.293.1594389635902; Fri, 10 Jul 2020 07:00:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594389635; cv=none; d=google.com; s=arc-20160816; b=P24riBDGK1fhFy66gpW2fQaXsr9WSOfTEAW/JbqYTukKo4kpXBsV0eY7uNn+gKs/8A rMgLZgxURvYpV5Dp45QQvLx9+8yiPAuyk1tOawwhMxB1WXNm208t/0qEAJni2EQqiZLH M0gbHRgJfET1pdLd2r51h2RmLYiFRgFdNIoJgnG77jUACytsPd+iBNEx0fpNSV97tMkE +vJWUsKo/yfd3XayZheFfC3SV34BcJ4FWIzFAcSAoefJHv1KT+Kd8Y+adTvUcOyWHns2 9pqdCa09Zuq12jk+9JLrfISqRuurD7bR3xEbwLSfyG6vbE7uA+Tfmrg+k+St6F819y+k Y8+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:subject:cc:to:from:message-id:date; bh=idC9KGfhpx+xPsWtMCdO8D3vGyMQqF3b+btYAPDR54M=; b=YBqDBujSLx7TwJJdjyD79RURiEc7kgFR/2c8b8Mysj+flBHNItt2lGpncrWfjlk7x3 i7Lzx76gzdNWMwj6DhjEuY4yJjec8bL5x3muZ631r7QoY71jhnLtRydUVokCRqRnDfAO A9tXbZxundijD8sbGsRhQk0C3q0SE0wKeZVoiDV1Vzi7b8Kboc6F3C9POEXR+a6lfPjc RhGYLpTiWRSLYw3sQ6t0GaqDAHAkoL5QtCeZGDxC7oSe+pIYJSHx/+/ANLHK8HDJqRYk dzF82oWeuoDYW9mgzdF8+4PWZEvhJtNVHBWIRCqZFyPGfXdWeav8liu8+4I/fq9uWAN5 zQhQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f3si4133083edy.2.2020.07.10.07.00.09; Fri, 10 Jul 2020 07:00:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727963AbgGJOAC (ORCPT + 99 others); Fri, 10 Jul 2020 10:00:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:42298 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726820AbgGJOAC (ORCPT ); Fri, 10 Jul 2020 10:00:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 03D7DAC9F; Fri, 10 Jul 2020 14:00:00 +0000 (UTC) Date: Fri, 10 Jul 2020 15:59:59 +0200 Message-ID: From: Takashi Iwai To: Alan Stern Cc: syzbot , alsa-devel@alsa-project.org, andreyknvl@google.com, linux-usb@vger.kernel.org, syzkaller-bugs@googlegroups.com, linux-kernel@vger.kernel.org, tiwai@suse.com Subject: Re: KASAN: use-after-free Read in line6_submit_audio_in_all_urbs In-Reply-To: <20200626182605.GA305214@rowland.harvard.edu> References: <000000000000d44c6d05a8ffe488@google.com> <20200626182605.GA305214@rowland.harvard.edu> 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/25.3 (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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 26 Jun 2020 20:26:05 +0200, Alan Stern wrote: > > On Fri, Jun 26, 2020 at 10:18:12AM -0700, syzbot wrote: > > Hello, > > > > syzbot found the following crash on: > > > > HEAD commit: fb574682 usbip: tools: fix module name in man page > > git tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing > > console output: https://syzkaller.appspot.com/x/log.txt?x=156560b1100000 > > kernel config: https://syzkaller.appspot.com/x/.config?x=63b40b2ae167bad6 > > dashboard link: https://syzkaller.appspot.com/bug?extid=145012a46658ac00fc9e > > compiler: gcc (GCC) 10.1.0-syz 20200507 > > > > Unfortunately, I don't have any reproducer for this crash yet. > > > > IMPORTANT: if you fix the bug, please add the following tag to the commit: > > Reported-by: syzbot+145012a46658ac00fc9e@syzkaller.appspotmail.com > > > > snd_usb_toneport 5-1:0.0: URB in #0 submission failed (-19) > > snd_usb_toneport 5-1:0.0: URB in #0 submission failed (-19) > > snd_usb_toneport 5-1:0.0: URB in #0 submission failed (-19) > > snd_usb_toneport 5-1:0.0: URB in #0 submission failed (-19) > > ================================================================== > > BUG: KASAN: use-after-free in line6_submit_audio_in_all_urbs+0x10b/0x120 sound/usb/line6/capture.c:72 > > Read of size 8 at addr ffff8881cffb1800 by task kworker/1:5/3257 > > > > CPU: 1 PID: 3257 Comm: kworker/1:5 Not tainted 5.8.0-rc1-syzkaller #0 > > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 > > Workqueue: events line6_startup_work > > Call Trace: > > __dump_stack lib/dump_stack.c:77 [inline] > > dump_stack+0xf6/0x16e lib/dump_stack.c:118 > > print_address_description.constprop.0+0x1a/0x210 mm/kasan/report.c:383 > > __kasan_report mm/kasan/report.c:513 [inline] > > kasan_report.cold+0x37/0x7c mm/kasan/report.c:530 > > line6_submit_audio_in_all_urbs+0x10b/0x120 sound/usb/line6/capture.c:72 > > line6_stream_start+0x207/0x230 sound/usb/line6/pcm.c:197 > > line6_pcm_acquire+0x161/0x210 sound/usb/line6/pcm.c:318 > > line6_startup_work+0x42/0x50 sound/usb/line6/driver.c:734 > > process_one_work+0x94c/0x15f0 kernel/workqueue.c:2269 > > worker_thread+0x64c/0x1120 kernel/workqueue.c:2415 > > kthread+0x392/0x470 kernel/kthread.c:291 > > ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 > > > > Allocated by task 76: > > save_stack+0x1b/0x40 mm/kasan/common.c:48 > > set_track mm/kasan/common.c:56 [inline] > > __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494 > > kmalloc include/linux/slab.h:555 [inline] > > kzalloc include/linux/slab.h:669 [inline] > > line6_init_pcm+0x2a7/0x9e0 sound/usb/line6/pcm.c:533 > > toneport_init+0xdd/0x6b0 sound/usb/line6/toneport.c:419 > > line6_probe+0xaa0/0x1330 sound/usb/line6/driver.c:809 > > It look like the cancel_delayed_work() in line6_disconnect() needs to be > cancel_delayed_work_sync(). Unfortunately we can't test this until syzbot > is able to reproduce the bug. Right, but fixing it now wouldn't be bad. The fix patch below. thanks, Takashi -- 8< -- From: Takashi Iwai Subject: [PATCH] ALSA: line6: Sync the pending work cancel at disconnection Recently syzkaller reported a UAF in LINE6 driver, and it's likely because we call cancel_delayed_work() at the disconnect callback instead of cancel_delayed_work_sync(). Let's use the correct one instead. Reported-by: syzbot+145012a46658ac00fc9e@syzkaller.appspotmail.com Suggested-by: Alan Stern Cc: Signed-off-by: Takashi Iwai --- sound/usb/line6/driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c index 7629116f570e..2746d9698180 100644 --- a/sound/usb/line6/driver.c +++ b/sound/usb/line6/driver.c @@ -840,7 +840,7 @@ void line6_disconnect(struct usb_interface *interface) if (WARN_ON(usbdev != line6->usbdev)) return; - cancel_delayed_work(&line6->startup_work); + cancel_delayed_work_sync(&line6->startup_work); if (line6->urb_listen != NULL) line6_stop_listen(line6); -- 2.16.4