Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp4558562ybg; Mon, 8 Jun 2020 10:50:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQtYBlGEJES79OKs81y1xJ10oy7g+cTziHh3YNBVtf0nxam9nEKKKkdSfZ22zy5aBo9ZyN X-Received: by 2002:a50:a418:: with SMTP id u24mr23992677edb.141.1591638643922; Mon, 08 Jun 2020 10:50:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591638643; cv=none; d=google.com; s=arc-20160816; b=RHXoFezhweTEq2O0kv7Khc9iu+ArQL6wDX7cqOWL5BtX/ilKIbLGw2lwdlOB00DBtx y7w5k6wzaHxiHKRgV6U7mn5CT5kyQlPUOxNorqLU3beZcAzC2ygs+f6uIKN37+HPPajQ WffFZRFKZmZwJ6/Ug6H4Cf8VemNxPzmfhJ4xwGUX7l0wNRzuakDYuIlCHf6QImz6bCxc W7g2K1qiB955Nxos5L8EPnV2BawlBlGj/l5e9H+aoird2YZBwd10AcsuQqHnmLChYulQ 879sAFdlMgpBhgbCn6DAaJLqBxS4lbQp/3H4zOI6QvmnqVlMDaZcSOpyCAtg8KEMPTxz dSPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:in-reply-to :content-transfer-encoding:mime-version:subject:from:message-id:date :dkim-signature; bh=bterT/eDaz2dErslN/NuoW5kl2Vuo1BqIe4mR9PTTIY=; b=VvsJQgx9bDIdXiVZIzZSsoaC3dsjL59zV8yTdGL4zKizrm3LSXAdCQ99qOVNRL1SIL nyzzunsdpR7xNNnNwHhyxhxKGUQRW76J1Q2ZNucaxuJ7JmbXotY3JwvTB1b2wqzTUebr quGM6in9/6RU4oHKHuVjzmUM78UHLfyKuhGLLvZaXOyUeOi2JqeCVwnrXu1fREjSlfPB UJ2XBJ/E7eu+8Uy3/9QYPh017zuovyONiuu5ZeUZ+wRp9Yck63fE3g3Z+a7wjHWhg01u vOZRDzpFNVDG7KNklI1ookvz3NLPhzPuUlD1XMis3a91HCJC2LrbLDxLFkc3JpoMrFZ0 WAug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=WIBIrIjA; 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 f1si8085951ejh.665.2020.06.08.10.50.21; Mon, 08 Jun 2020 10:50:43 -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=WIBIrIjA; 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 S1730656AbgFHQuq (ORCPT + 99 others); Mon, 8 Jun 2020 12:50:46 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:65270 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730523AbgFHQun (ORCPT ); Mon, 8 Jun 2020 12:50:43 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 49gfQ936Zrz9Y; Mon, 8 Jun 2020 18:50:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1591635041; bh=jarQlXIMyEgpDzCHnwhZ/Ic2auBBKSklH+JwJ3xa7B4=; h=Date:From:Subject:In-Reply-To:To:Cc:From; b=WIBIrIjAnzgKDgG6E50IKD77VgKzVIV8iGsIicqtwyayhblgJCDpssMGVGb/e9f3Q /L/Rm/NAJETHnUPdke3Ps44VsduuhUW/Fzta2QM5AvGLrDnxMlmdIR74cMlgZwyfKh nCo7zoOqxB1MVIpBbDgs2gyc6DTwyF/ZsO+yKF8k5dJXovvNPnk9tQAuqChINds6S9 NUc+zFDdLdRknF8msc3kZfihqczV5tR+yJL+wwU3wqtg/asdXvuc02vC9g7PFDv95F R1kJBfR40X1Hx98FG5ajsIp5DR1bHue0BBA0lsVFkxKQLW4mCD1w+frrNl7NyOnTxu 5MHfL6Api4IGg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.2 at mail Date: Mon, 08 Jun 2020 18:50:39 +0200 Message-Id: <89c4a2487609a0ed6af3ecf01cc972bdc59a7a2d.1591634956.git.mirq-linux@rere.qmqm.pl> From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH v2] ALSA: pcm: disallow linking stream to itself MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In-Reply-To: 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 --- v2: EDEADLK -> EINVAL --- 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..434e7b604bad 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 = -EINVAL; + goto _badf; + } + group = kzalloc(sizeof(*group), GFP_KERNEL); if (!group) { res = -ENOMEM; -- 2.20.1