From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 784B363DA for ; Thu, 5 Jan 2023 12:57:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D19E2C433F0; Thu, 5 Jan 2023 12:57:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672923465; bh=1B+/QZ7STfzH61q93pC05PbGTMVU1N0gz1hEXiAvmxE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qDJKTa5WxtgJnGEABl/nMxmE45KR6ZUew1BNPh+pxdUuC3M9P/gz+wzCjge2YpbIt mC4KiPlTrB5eyk+Fp2PaSE8vv1ixwvzBS2Eua/OkP7CO4DkZW1mw7Iy4mQRZqyaA9q tb74Y/PcBxcj5D3eulpR1DNCS2VHxSOGY5m6aUUU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mark Brown , Sasha Levin Subject: [PATCH 4.9 004/251] ASoC: ops: Check bounds for second channel in snd_soc_put_volsw_sx() Date: Thu, 5 Jan 2023 13:52:21 +0100 Message-Id: <20230105125334.941372816@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230105125334.727282894@linuxfoundation.org> References: <20230105125334.727282894@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Mark Brown [ Upstream commit 97eea946b93961fffd29448dcda7398d0d51c4b2 ] The bounds checks in snd_soc_put_volsw_sx() are only being applied to the first channel, meaning it is possible to write out of bounds values to the second channel in stereo controls. Add appropriate checks. Signed-off-by: Mark Brown Link: https://lore.kernel.org/r/20220511134137.169575-2-broonie@kernel.org Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/soc-ops.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c index 5479927391d4..8294430aaf9a 100644 --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -465,6 +465,12 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol, if (snd_soc_volsw_is_stereo(mc)) { val_mask = mask << rshift; val2 = (ucontrol->value.integer.value[1] + min) & mask; + + if (mc->platform_max && val2 > mc->platform_max) + return -EINVAL; + if (val2 > max) + return -EINVAL; + val2 = val2 << rshift; err = snd_soc_component_update_bits(component, reg2, val_mask, -- 2.35.1