From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 519F1C46460 for ; Tue, 14 Aug 2018 20:54:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D9CA21725 for ; Tue, 14 Aug 2018 20:54:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D9CA21725 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730245AbeHNXne (ORCPT ); Tue, 14 Aug 2018 19:43:34 -0400 Received: from mx2.suse.de ([195.135.220.15]:47386 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730113AbeHNXne (ORCPT ); Tue, 14 Aug 2018 19:43:34 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0F5B0AD82; Tue, 14 Aug 2018 20:54:35 +0000 (UTC) Date: Tue, 14 Aug 2018 22:54:34 +0200 Message-ID: From: Takashi Iwai To: syzbot Cc: , , , , Subject: Re: WARNING in __snd_rawmidi_transmit_ack (2) In-Reply-To: <000000000000e1226c057365e75d@google.com> References: <000000000000e1226c057365e75d@google.com> 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/26 (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 Tue, 14 Aug 2018 16:20:02 +0200, syzbot wrote: > > Hello, > > syzbot found the following crash on: > > HEAD commit: 4e8b38549b50 Add linux-next specific files for 20180814 > git tree: linux-next > console output: https://syzkaller.appspot.com/x/log.txt?x=11f5e78c400000 > kernel config: https://syzkaller.appspot.com/x/.config?x=18edf0289d1b5ab > dashboard link: https://syzkaller.appspot.com/bug?extid=ec5f605c91812d200367 > compiler: gcc (GCC) 8.0.1 20180413 (experimental) > syzkaller repro:https://syzkaller.appspot.com/x/repro.syz?x=12f8c6d2400000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16976b72400000 > > IMPORTANT: if you fix the bug, please add the following tag to the commit: > Reported-by: syzbot+ec5f605c91812d200367@syzkaller.appspotmail.com > > WARNING: CPU: 1 PID: 1691 at sound/core/rawmidi.c:1170 > __snd_rawmidi_transmit_ack+0x263/0x2f0 sound/core/rawmidi.c:1170 This seems to be a bad side-effect by the code change along with the offloading the virmidi work. I'm going to queue the fix below. thanks, Takashi -- 8< -- From: Takashi Iwai Subject: [PATCH] ALSA: seq: virmidi: Fix discarding the unsubscribed output The recent change to move the virmidi output processing to a work slightly modified the code to discard the unsubscribed outputs so that it works without a temporary buffer. However, this is actually buggy, and may spew a kernel warning due to the unexpected call of snd_rawmidi_transmit_ack(), as triggered by syzbot. This patch takes back to the original code in that part, use a temporary buffer and simply repeat snd_rawmidi_transmit(), in order to address the regression. Fixes: f7debfe54090 ("ALSA: seq: virmidi: Offload the output event processing") Reported-by: syzbot+ec5f605c91812d200367@syzkaller.appspotmail.com Signed-off-by: Takashi Iwai --- sound/core/seq/seq_virmidi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c index a2f1c6b58693..cb988efd1ed0 100644 --- a/sound/core/seq/seq_virmidi.c +++ b/sound/core/seq/seq_virmidi.c @@ -149,8 +149,9 @@ static void snd_vmidi_output_work(struct work_struct *work) /* discard the outputs in dispatch mode unless subscribed */ if (vmidi->seq_mode == SNDRV_VIRMIDI_SEQ_DISPATCH && !(vmidi->rdev->flags & SNDRV_VIRMIDI_SUBSCRIBE)) { - while (!snd_rawmidi_transmit_empty(substream)) - snd_rawmidi_transmit_ack(substream, 1); + char buf[32]; + while (snd_rawmidi_transmit(substream, buf, sizeof(buf)) > 0) + ; /* ignored */ return; } -- 2.18.0