Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1830971pxa; Sun, 2 Aug 2020 23:21:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEKos9HQJZhzMxwk0zT9ub+mBbhNgBjV494CmjtoOArugqhU5h9dNyUO57JJvSvEdSel8s X-Received: by 2002:a17:906:aad2:: with SMTP id kt18mr15579446ejb.537.1596435704399; Sun, 02 Aug 2020 23:21:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596435704; cv=none; d=google.com; s=arc-20160816; b=jxsGCPlC4IGdhhZ/VNTN/t1eFZf0Vd4lPhyuBtE4sbncDtXojU5RXzBaFQue5ylA/M itZoCmFe9RTXoJR9H8cI/SsA3ofUtOz93rV1O0jWFPUabLm0pBZSm6T915hRleAVC4k7 v4SdeCFmHvPKV4YFP5foRXBAuHq8R+r/NGs2tSvtIenc+45vQctlUyAbHb0Fho7z0dyY kNb5ctgblmD4FtSYYPg0GE79ikiicLY8XYLp/UeIJXyyp+QgaJNnX5Z6ZrptB6kI6pNh 2xdHMIxDfSeAn6a4lS7VrfAYY/Owi9psd5GoT4kv1I4iDY0le3fwWKqgZLeP7TAsvXvu Ejvw== 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=124QrGjhlTgJsl5QiRRyyCB/33NJu/Ha9SfhjkuQPO8=; b=YvhMJKBSpYpF8FFumhBJacgvhrlzi+ySaI+LHm/Lxig6CIg/D9KjnF7MnSVOIHryGK /KYC+5RUUbe89r9FbLr4d+25lv/4xmTUbjSisQd/EK++IhOvJCfPewtIgMHS8obBJolu JzwA83n59wZ17qeEgP0K1v5xCpCyEZOcFoqLUOwdCjPiSEijzQSsBtJge2C9auvWnPcl j08alguzcGn9ykYNnpoDzF/9Qu7HOYOZ60yo5QNQnDDxMLNPFlhSTw4O7j2EmKctW/oG otJ5gI8Djp8DhFyibAu6swNtPIaCFaJ1SL4K3v06vuDn9qe2DT9qBd+f4LygyHJsDHLw HJEA== 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 v19si9594449ejf.83.2020.08.02.23.21.22; Sun, 02 Aug 2020 23:21:44 -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 S1726511AbgHCGQW (ORCPT + 99 others); Mon, 3 Aug 2020 02:16:22 -0400 Received: from mx2.suse.de ([195.135.220.15]:59906 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725831AbgHCGQW (ORCPT ); Mon, 3 Aug 2020 02:16:22 -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 64D6BAF38; Mon, 3 Aug 2020 06:16:35 +0000 (UTC) Date: Mon, 03 Aug 2020 08:16:20 +0200 Message-ID: From: Takashi Iwai To: "Zhang, Qiang" Cc: "perex@perex.cz" , "tiwai@suse.com" , "alsa-devel@alsa-project.org" , "linux-kernel@vger.kernel.org" Subject: Re: =?UTF-8?B?5Zue5aSNOg==?= [PATCH] ALSA: seq: KASAN: use-after-free Read in delete_and_unsubscribe_port In-Reply-To: References: <20200801062403.8005-1-qiang.zhang@windriver.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/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 Mon, 03 Aug 2020 03:35:05 +0200, Zhang, Qiang wrote: > > >Thanks for the patch. But I'm afraid that this change would break the > >existing behavior and might have a bad side-effect. > > >It's likely the same issue as reported in another syzkaller report > >("KASAN: invalid-free in snd_seq_port_disconnect"), and Hillf's patch > >below should covert this as well. Could you check whether it works? > > yes It's should same issue, add mutex lock in odev_ioctl, ensure serialization. > however, it should not be necessary to mutually exclusive with open and close. That's a big-hammer approach indeed, but it should be more reasonable in this case. It makes the patch shorter and simpler, while the OSS sequencer is an ancient interface that wasn't considered much for the concurrency, and this might also cover the case where the access to another sequencer object that is being to be closed. So, it'd be great if you can confirm that the patch actually works. Then we can brush up and merge it for 5.9-rc1. thanks, Takashi > > > > >thanks, > > >Takashi > > >--- > >--- a/sound/core/seq/oss/seq_oss.c > >+++ b/sound/core/seq/oss/seq_oss.c > >@@ -167,11 +167,17 @@ odev_write(struct file *file, const char > >static long > >odev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > >{ > >+ long rc; > > struct seq_oss_devinfo *dp; > >+ > >+ mutex_lock(®ister_mutex); > > dp = file->private_data; > > if (snd_BUG_ON(!dp)) > >- return -ENXIO; > >- return snd_seq_oss_ioctl(dp, cmd, arg); > >+ rc = -ENXIO; > >+ else > >+ rc = snd_seq_oss_ioctl(dp, cmd, arg); > >+ mutex_unlock(®ister_mutex); > >+ return rc; > >} > > >#ifdef CONFIG_COMPAT