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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 988E1C43219 for ; Mon, 7 Feb 2022 11:23:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382134AbiBGLSW (ORCPT ); Mon, 7 Feb 2022 06:18:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356734AbiBGLNU (ORCPT ); Mon, 7 Feb 2022 06:13:20 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8088CC043189; Mon, 7 Feb 2022 03:13:18 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7A565611AA; Mon, 7 Feb 2022 11:13:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 591F4C004E1; Mon, 7 Feb 2022 11:13:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644232397; bh=pb9YFJqK6DzbsQ+nfYREskx+GD9DBVbjajIsy4tiFoo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SK4/z2x0cWp6NpAkx0VBRybfIGsvgbZkI2tdzJCkelLlqLgPDHCmtXkROnCR7S1AJ xMTDn/hakY7ZDGCiWSag/dOL2/iHDeTZhQD3nyWujFH1nmWaynK3XFaKzeAABp1CvI 5KgXrV+QJGFBtPHx0nhRg3OJAnyzUvHeef+s0rGk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Brown Subject: [PATCH 4.14 48/69] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx() Date: Mon, 7 Feb 2022 12:06:10 +0100 Message-Id: <20220207103757.202568011@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103755.604121441@linuxfoundation.org> References: <20220207103755.604121441@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Brown commit 4f1e50d6a9cf9c1b8c859d449b5031cacfa8404e upstream. We don't currently validate that the values being set are within the range we advertised to userspace as being valid, do so and reject any values that are out of range. Signed-off-by: Mark Brown Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220124153253.3548853-3-broonie@kernel.org Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/soc-ops.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -441,8 +441,15 @@ int snd_soc_put_volsw_sx(struct snd_kcon int err = 0; unsigned int val, val_mask, val2 = 0; + val = ucontrol->value.integer.value[0]; + if (mc->platform_max && val > mc->platform_max) + return -EINVAL; + if (val > max - min) + return -EINVAL; + if (val < 0) + return -EINVAL; val_mask = mask << shift; - val = (ucontrol->value.integer.value[0] + min) & mask; + val = (val + min) & mask; val = val << shift; err = snd_soc_component_update_bits(component, reg, val_mask, val);