From patchwork Mon Jun 8 10:06:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 192493 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=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS 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 C8EC3C433E0 for ; Mon, 8 Jun 2020 10:08:27 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5282A206D5 for ; Mon, 8 Jun 2020 10:08:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="kuBVH1VV"; dkim=pass (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="FviN4T+s" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5282A206D5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rere.qmqm.pl Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C164F1612; Mon, 8 Jun 2020 12:07:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C164F1612 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1591610905; bh=ToQ1Q88h9KXOgWqvqinbc9ShsgjvDBLo4uhp3BUbUok=; h=Date:In-Reply-To:References:From:Subject:To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=kuBVH1VV4KCy0uVyXzXY3LPKbSx/4kYs5WmV//a3PYiaXf6lqdHzILDsvHZcA9iaT yTGG3H5Orsu+fAzyEdVal7BTDMpHknNy55sVuE1Zp1jTj+7G98kmr6gehC95jwePu5 RFVG8Lx2j2AHKh/PcTF8zC6yBzSrm287KdgtqWFs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 498F9F80252; Mon, 8 Jun 2020 12:06:43 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7D7DEF8021E; Mon, 8 Jun 2020 12:06:40 +0200 (CEST) Received: from rere.qmqm.pl (rere.qmqm.pl [91.227.64.183]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 77019F80124 for ; Mon, 8 Jun 2020 12:06:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 77019F80124 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="FviN4T+s" Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 49gTRr5KF3zBn; Mon, 8 Jun 2020 12:06:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1591610792; bh=ToQ1Q88h9KXOgWqvqinbc9ShsgjvDBLo4uhp3BUbUok=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=FviN4T+s+yA3w3snpTxygawbBpqGW9kQuai95bbFPZtF/V3SwxE8KUQ4aFlTUTN57 MgFwOs674/5wWjejhCK43e7pfnq2KTu/5DwuKqpaQwKN1IVb1+J8lM+z0Bh/rnndMT GYPYF/3zwWrdTYXh60e2w3MhrCmn+uK4dvL1oJI10MB2g9KrQJsx8QT819d81oYSXX 5hfB2d2qrq+hthA1N3n2hiD6mscCAKXbTV7IXrGBBBDNHB39iZbXu0WFsXwiste72/ gKGsfUR4X55jYIRBPgPqnxXPauRp58xCTu5rf6zL5E9RaLVAqaN+Jnlf82YHb3C7Tn PMOZjLI8j5w5Q== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.2 at mail Date: Mon, 08 Jun 2020 12:06:32 +0200 Message-Id: In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH 1/2] ALSA: pcm: disallow linking stream to itself MIME-Version: 1.0 To: Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Prevent SNDRV_PCM_IOCTL_LINK linking stream to itself - the code can't handle it. Fixed commit is not where bug was introduced, but changes the context significantly. Cc: stable@vger.kernel.org Fixes: 0888c321de70 ("pcm_native: switch to fdget()/fdput()") Signed-off-by: Michał Mirosław --- sound/core/pcm_native.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index aef860256278..3ad399cb6f30 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -2166,6 +2166,12 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd) } pcm_file = f.file->private_data; substream1 = pcm_file->substream; + + if (substream == substream1) { + res = -EDEADLK; + goto _badf; + } + group = kzalloc(sizeof(*group), GFP_KERNEL); if (!group) { res = -ENOMEM;