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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 7430AC433E0 for ; Tue, 16 Jun 2020 16:02:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CDC221475 for ; Tue, 16 Jun 2020 16:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592323326; bh=XHEuO4r47xY7A+3I/JXGsP7brObpMbZLd6nC4UwXYZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=psN9KAEvLHGfP0R2wTpWCVI6Jrh2aOL4ZPNr7kMykPmVUsOApzw5BgxKiXvP0X8AD kQ4Y8jECXO7eExPh4ZgIZLCsJe4TSnpswA09FyapYFrXlLLafeTPV/KqxiTu3WBvki k5hdQ0109h2D3XI7ZlFt+c8qdP+xhvOKN1xw+GiU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732855AbgFPQCF (ORCPT ); Tue, 16 Jun 2020 12:02:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:48642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732705AbgFPPvr (ORCPT ); Tue, 16 Jun 2020 11:51:47 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4D77F214DB; Tue, 16 Jun 2020 15:51:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592322706; bh=XHEuO4r47xY7A+3I/JXGsP7brObpMbZLd6nC4UwXYZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hDpgbumirjPsAlLsrCGshHT7+SoUKmoL2UErE9HGuxgWptKU6CFsdyMGkWaM5kj/G +BTu5vcXktTJlOstvc8218D/bKoytkUFfKZJbB1Z1ruDnKEvjfNH1SJjUAIR66N2ok vpM4UT5ZGbkun4ZTPXL0H11YrI2BsMv71+j1kw2w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Takashi Iwai Subject: [PATCH 5.6 073/161] ALSA: pcm: disallow linking stream to itself Date: Tue, 16 Jun 2020 17:34:23 +0200 Message-Id: <20200616153109.856644999@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200616153106.402291280@linuxfoundation.org> References: <20200616153106.402291280@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michał Mirosław commit 951e2736f4b11b58dc44d41964fa17c3527d882a upstream. 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 Link: https://lore.kernel.org/r/89c4a2487609a0ed6af3ecf01cc972bdc59a7a2d.1591634956.git.mirq-linux@rere.qmqm.pl Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/core/pcm_native.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -2163,6 +2163,12 @@ static int snd_pcm_link(struct snd_pcm_s } 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;