Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp4252257ybg; Mon, 8 Jun 2020 03:08:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFzxWmfvZ/9ILy3SmDFfgL4IZIZj+C13bVbiMu5g+VBZts+Bl4+khVPgn3vX9m+73dwswU X-Received: by 2002:a17:906:6dcd:: with SMTP id j13mr17566645ejt.131.1591610934274; Mon, 08 Jun 2020 03:08:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591610934; cv=none; d=google.com; s=arc-20160816; b=OignNzJravDVULBmy59GuFIhDgDPgsZ5IO5XX3vYUYHkqb73YiV+w+dxwAIr/xStPl Dm1ULwvL7KY2scox182zgpTbnmkxbyX0dH/vg8vrNTqwJylG6HCglqF9ohFbmH/a6jN7 ysscFA9jVbx6zpXYpjOUYOgh9/NgUGblgGZZR4LG6aL6MJaVRB2S3/zqJKGEpswO5Wab m9r7SSuvImbXyqwSjJD49GThKQdUVkkAohBSL9yGJqVcoHfoElX8EQUSyhCSdNTWLUD4 eQvbhf4s7HR5BQty5HIinEu5xn4fRngtPiLhzIN5iLlevgtuNpmGEgfHERJfkKjKfuzN NdZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:content-transfer-encoding :mime-version:subject:from:references:in-reply-to:message-id:date :dkim-signature; bh=eRnmvuy80t/V25nlcm6ow/dUiNapEctCCyLi3S74UeM=; b=tRoZt6mFTcpTf9n2w0iFRnLPo8Vvy0QPRPk1WmXqLxieGc15scWQJmrMSOu8T+GZvq 0kZ+FmIme9ZU0469I2NyB0HO1vDtEYWwICntKt2K2p48RLsJ6J/o0xD6146V2dUSCArg F5COGJI7EvcS82e/EcgSYHNRca9Lno1UbE+hDYqaIVTWHyzE2/+dULe/oVTI66wfyA/L pdUmBELMDIjZsY0gCeoEyFGnQE9ulPUUf54O+7iEOM1KdWF4ONTPaSl48KZLONssmZuR G73OgeefJvy86N+GrGSFNwVqQI8L47s0WAhzma+yUYBedfWevhdiIJG02k1XvhUsCvEr 8ceQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=FviN4T+s; 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 w19si7718618edl.458.2020.06.08.03.08.30; Mon, 08 Jun 2020 03:08:54 -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; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=FviN4T+s; 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 S1729308AbgFHKGg (ORCPT + 99 others); Mon, 8 Jun 2020 06:06:36 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:31416 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729260AbgFHKGe (ORCPT ); Mon, 8 Jun 2020 06:06:34 -0400 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?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH 1/2] ALSA: pcm: disallow linking stream to itself MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.20.1