Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7260C433F5 for ; Sun, 17 Oct 2021 07:45:02 +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 E428F61152 for ; Sun, 17 Oct 2021 07:45:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E428F61152 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=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 108A917DD; Sun, 17 Oct 2021 09:44:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 108A917DD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1634456700; bh=PZLWL9KH7GOpiTHZWizoijrlVZzZXkFjgFlYDNlt6lU=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=S8ffIVmqt7lmyqu90Q5di6XtUrX3833wNNUHnkF8lJ1BtIwfd/GgN90Yz9hYMldv2 1CGED5vIrlUULtT6ht6r3T94SSoL32lpsByHwaaHlh025mPVJmYVAmYZ8SyM3yCfrB 4Ud2bd6/IlChAGaIBciapFdxugfv4EZDRp8LiA94= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D656EF802E0; Sun, 17 Oct 2021 09:44:08 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 87255F804E5; Sun, 17 Oct 2021 09:44:06 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 87478F801DB for ; Sun, 17 Oct 2021 09:43:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 87478F801DB Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Z0Dx17nd"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="7iLs2vLX" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id D9C282197A; Sun, 17 Oct 2021 07:43:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1634456629; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=yPyZ9XdJZhmwah2a/ner+Q/w4gzju7DMPhD+XTq/AOk=; b=Z0Dx17ndTfjQ4Y29+RtOxC14Z4sqUFhXf82DJTdBBLEk4O95dfReN9xUHTk24wj3JYOSx6 /zFIwD1FmAsWP7zTnI+FFSpFdLvnVmJsJEPaHgaucrJULJmfaptV7LI6L5W5VIAtkDvSfX T0WaNseAUhqnzezOpa6VnmgUIEZJivk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1634456629; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=yPyZ9XdJZhmwah2a/ner+Q/w4gzju7DMPhD+XTq/AOk=; b=7iLs2vLXBznD372qBWh/7eQtDv8C8aV2bMel2GpDZlssEMm7zRa2GrVncVLrKnFvnCFM6J MjYAczoiVGHm8NBw== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id C9367A3B81; Sun, 17 Oct 2021 07:43:49 +0000 (UTC) Date: Sun, 17 Oct 2021 09:43:49 +0200 Message-ID: From: Takashi Iwai To: Pierre-Louis Bossart Subject: Re: [PATCH v3 1/4] ALSA: pcm: unconditionally check if appl_ptr is in 0..boundary range In-Reply-To: <20211015195932.224925-2-pierre-louis.bossart@linux.intel.com> References: <20211015195932.224925-1-pierre-louis.bossart@linux.intel.com> <20211015195932.224925-2-pierre-louis.bossart@linux.intel.com> 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=US-ASCII Cc: Kai Vehmanen , alsa-devel@alsa-project.org, broonie@kernel.org, Ranjani Sridharan 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" On Fri, 15 Oct 2021 21:59:29 +0200, Pierre-Louis Bossart wrote: > > In some cases, the appl_ptr passed by userspace is not checked before > being used. This patch adds an unconditional check and returns an > error code should the appl_ptr exceed the ALSA 'boundary'. > > Suggested-by: Takashi Iwai > Signed-off-by: Pierre-Louis Bossart > Reviewed-by: Ranjani Sridharan > Reviewed-by: Kai Vehmanen Reviewed-by: Takashi Iwai thanks, Takashi > --- > sound/core/pcm_lib.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c > index a144a3f68e9e..ec53a3e7cf35 100644 > --- a/sound/core/pcm_lib.c > +++ b/sound/core/pcm_lib.c > @@ -2132,6 +2132,9 @@ int pcm_lib_apply_appl_ptr(struct snd_pcm_substream *substream, > if (old_appl_ptr == appl_ptr) > return 0; > > + if (appl_ptr >= runtime->boundary) > + return -EINVAL; > + > runtime->control->appl_ptr = appl_ptr; > if (substream->ops->ack) { > ret = substream->ops->ack(substream); > -- > 2.25.1 >