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=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=no 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 E946CC433E0 for ; Mon, 8 Jun 2020 12:48:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4A232072F for ; Mon, 8 Jun 2020 12:48:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729214AbgFHMsn (ORCPT ); Mon, 8 Jun 2020 08:48:43 -0400 Received: from mx2.suse.de ([195.135.220.15]:50576 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727003AbgFHMsl (ORCPT ); Mon, 8 Jun 2020 08:48:41 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 24660AD7D; Mon, 8 Jun 2020 12:48:44 +0000 (UTC) Date: Mon, 08 Jun 2020 14:48:40 +0200 Message-ID: From: Takashi Iwai To: =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] ALSA: pcm: disallow linking stream to itself In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") 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 On Mon, 08 Jun 2020 12:06:32 +0200, Michał Mirosław wrote: > > 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 Thanks for the fix. Just a minor point: > @@ -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; We've never used this error code, hence it may confuse the user-space side. I'd use a more standard -EINVAL instead; the error is basically an invalid argument, after all. thanks, Takashi