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=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 A4215C282CE for ; Tue, 4 Jun 2019 23:29:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7342F206B8 for ; Tue, 4 Jun 2019 23:29:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559690958; bh=wdwNfT7L/APAJt2FHLI4nduL/yE6vKdYEff+qNJKzkI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=lwdcCiM7Jf0sx5thWpKLrIDWGDxCu/JYzRyEeZemRc2TFfLvw75tHPiBcRvQG1y3s 1W7vmbf2x5Fg1xU/l+/szJCahaj0VORAvS2XElSqXaG/J7WxdyxUWf9yUjyiusHjdF wuETPKQBaGSFIN8l7QfL3JssgPue/+9mitkGofhY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727107AbfFDX3N (ORCPT ); Tue, 4 Jun 2019 19:29:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:35544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727599AbfFDXYa (ORCPT ); Tue, 4 Jun 2019 19:24:30 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5599420863; Tue, 4 Jun 2019 23:24:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559690669; bh=wdwNfT7L/APAJt2FHLI4nduL/yE6vKdYEff+qNJKzkI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qYXW7Lbg9plJD8Izke5s7UvtYo/7K/Jy7uOAVRf9rQQMcWgnZyZ+negnZr+5RJi8V ZScOo9HmTaM7TVJixWfmdcIKmfHN/TElTTfARedMz+o0Qj8me07b6AGoOkOd0zc0gO C1Wx25eUhdYmNX/uAMnxLShR2DnjjlE8ZA+4lFQs= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Takashi Iwai , syzbot+e4c8abb920efa77bace9@syzkaller.appspotmail.com, Sasha Levin Subject: [PATCH AUTOSEL 4.14 05/24] ALSA: seq: Cover unsubscribe_port() in list_mutex Date: Tue, 4 Jun 2019 19:23:56 -0400 Message-Id: <20190604232416.7479-5-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190604232416.7479-1-sashal@kernel.org> References: <20190604232416.7479-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Takashi Iwai [ Upstream commit 7c32ae35fbf9cffb7aa3736f44dec10c944ca18e ] The call of unsubscribe_port() which manages the group count and module refcount from delete_and_unsubscribe_port() looks racy; it's not covered by the group list lock, and it's likely a cause of the reported unbalance at port deletion. Let's move the call inside the group list_mutex to plug the hole. Reported-by: syzbot+e4c8abb920efa77bace9@syzkaller.appspotmail.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/core/seq/seq_ports.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c index edcb7ab21bf5..c8fa4336bccd 100644 --- a/sound/core/seq/seq_ports.c +++ b/sound/core/seq/seq_ports.c @@ -550,10 +550,10 @@ static void delete_and_unsubscribe_port(struct snd_seq_client *client, list_del_init(list); grp->exclusive = 0; write_unlock_irq(&grp->list_lock); - up_write(&grp->list_mutex); if (!empty) unsubscribe_port(client, port, grp, &subs->info, ack); + up_write(&grp->list_mutex); } /* connect two ports */ -- 2.20.1