Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1082543ybl; Wed, 14 Aug 2019 10:24:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmUuuiqQyAlrH9z8V0Qy2ywayVSgbD92HyEOpTp40exsy+tSrKt99NWIWJqpRT+2CPQNde X-Received: by 2002:a17:90a:3aaf:: with SMTP id b44mr772699pjc.87.1565803484756; Wed, 14 Aug 2019 10:24:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803484; cv=none; d=google.com; s=arc-20160816; b=viEbQV8ZFqIrA9oDMfrR80snv90GOcieKcxtcBeTb4sLlGw8DoxYBPHNcenq+pz2Vu j6a3gyKS6PcSjDmAHUgZa5PBU1jNxNVXQMSe0GUF9geztqMOmOXQxeomMgEBbTRo8fk7 br0YQspQ7q77ZBoL/gI1f3N7j+ExkhyEQowdw/e9igY05Nc6yszn+lgUna6vTjfuDKMs y0RQHCxl0BuYQucgMo9sOEYyMV+3sMSRohXxWJU0bfERFb53MNgT8V7fnGPEcYHCWr3+ N6F/1TvZtCy7QQLQgqvMYeVeQrbBlox4t68FjTqb0WMIAZrzGSJ0Q5Hcbe3c6JhfBZGt Zt0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ztAe+DT+RGB18ySKUMG/ndDTZUmu038kY/GVhWwEdaA=; b=ldmKyMBlIWh8NISi1CQ1c8FGxFOARLBrdBfHDIHCCfbVP1feqNgRyu7Cl7niBO/Ysu p3ck0nWZLp8jl63jdvfL8rppp+LYrs7RSZZyKutIGuUBTdosXIdl+ZkoowD9opD7TwFy gu/Do5kgf1/Oy+NhD+dhsr7pkOcpeLAW8lkYwQ+gIG1ixK5Z/l4q6FdVVpl2hW2iFB/u ACBXqGX48SVyrwMAfyW0zc+rHKp96iFFca+/sRh8SMGcFXjY93yLLOKdkcTA22SsCy4S 7MYTel/UHA/LIEQifyyvrseMMwr9Us4NpqlKE3qkPETRqFpIepBAOjVTF1f3GCTYOeGt icog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KgQBePD1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v8si90420pfm.83.2019.08.14.10.24.28; Wed, 14 Aug 2019 10:24:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KgQBePD1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729201AbfHNRX6 (ORCPT + 99 others); Wed, 14 Aug 2019 13:23:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:56376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729770AbfHNRHC (ORCPT ); Wed, 14 Aug 2019 13:07:02 -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 37CFE216F4; Wed, 14 Aug 2019 17:07:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802421; bh=/7FQWTuEgflCb1wse58HEE79sQhIfIBlTkQEguacW3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KgQBePD1RzUYhgdUsmJXl/7irg48/M8q13Y/+YgJUv6r+pEv27n8HwuXxRNYnILjc G+8fU4Vc4YHFvBAHZ9Ie7iDkiyuo+H/P4guJmw6vwiXaX4t/dkSZ/9TTuhtj7VNkVP zuc3JyUUCZAqPmNRkqsfc+KET8zuvKP3f2ALVBig= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Charles Keepax , Vinod Koul , Takashi Iwai , Sasha Levin Subject: [PATCH 5.2 093/144] ALSA: compress: Prevent bypasses of set_params Date: Wed, 14 Aug 2019 19:00:49 +0200 Message-Id: <20190814165803.765934139@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@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 [ Upstream commit 26c3f1542f5064310ad26794c09321780d00c57d ] Currently, whilst in SNDRV_PCM_STATE_OPEN it is possible to call snd_compr_stop, snd_compr_drain and snd_compr_partial_drain, which allow a transition to SNDRV_PCM_STATE_SETUP. The stream should only be able to move to the setup state once it has received a SNDRV_COMPRESS_SET_PARAMS ioctl. Fix this issue by not allowing those ioctls whilst in the open state. Signed-off-by: Charles Keepax Acked-by: Vinod Koul Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/core/compress_offload.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index d79aee6b9edd2..40dae723c59db 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -711,9 +711,15 @@ static int snd_compr_stop(struct snd_compr_stream *stream) { int retval; - if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED || - stream->runtime->state == SNDRV_PCM_STATE_SETUP) + switch (stream->runtime->state) { + case SNDRV_PCM_STATE_OPEN: + case SNDRV_PCM_STATE_SETUP: + case SNDRV_PCM_STATE_PREPARED: return -EPERM; + default: + break; + } + retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP); if (!retval) { snd_compr_drain_notify(stream); @@ -801,9 +807,14 @@ static int snd_compr_drain(struct snd_compr_stream *stream) { int retval; - if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED || - stream->runtime->state == SNDRV_PCM_STATE_SETUP) + switch (stream->runtime->state) { + case SNDRV_PCM_STATE_OPEN: + case SNDRV_PCM_STATE_SETUP: + case SNDRV_PCM_STATE_PREPARED: return -EPERM; + default: + break; + } retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN); if (retval) { @@ -840,9 +851,16 @@ static int snd_compr_next_track(struct snd_compr_stream *stream) static int snd_compr_partial_drain(struct snd_compr_stream *stream) { int retval; - if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED || - stream->runtime->state == SNDRV_PCM_STATE_SETUP) + + switch (stream->runtime->state) { + case SNDRV_PCM_STATE_OPEN: + case SNDRV_PCM_STATE_SETUP: + case SNDRV_PCM_STATE_PREPARED: return -EPERM; + default: + break; + } + /* stream can be drained only when next track has been signalled */ if (stream->next_track == false) return -EPERM; -- 2.20.1