Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1775476pxp; Mon, 7 Mar 2022 02:02:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBu9ZBW0kVW97iBN9enrAjKCXIlxaRQyiUFtz3RZdO2UtpGRutjwUfDWCcQVyi/I0vSIb7 X-Received: by 2002:a05:6402:5150:b0:415:de72:5384 with SMTP id n16-20020a056402515000b00415de725384mr10074476edd.273.1646647356803; Mon, 07 Mar 2022 02:02:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646647356; cv=none; d=google.com; s=arc-20160816; b=TOhtJ8K0THPIQ3k3M6fCSFIHeVjOT2u9hrDCk1zZPZGB/tMU3ZbIT+eWgFpUqyz4ZR +oHZtC5iMuvFb9ecYdV3v++i0df0w+09o+CpbGUopRBUAc6VEUtMK8VgCjU4SyAwFyBH 6bssSHeMgrSZaw91+kLHjrKBgK8cfky9DQoNocfaE60cp7TmAj6sTU9ypLDKutGVo0yq nFdTtF2jrMJ/kbjKhNEjKTYniiLk4FJHI13rHpwaY4DIryZxbvRDCmChLCkk7luHcIIX N3FU8oNWfddLsZyzvxZfUx2521svKPgxJZxqeSKLUC5JjQFrz9tjytYTPOj9dpq0BmzN opuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jznLM0oYyyD3q0AKASgKV1e0P+VFJykZeCTPidcQy3c=; b=r+QmW72HCU5+/7YM9bGhKLYaq63HrnCWBgMFoGR6JOti7Cu5L6tnfr7esT5Oq2k7XN bBv5QNfkDnYfsjcatjm6Z1ZHUL1uUa4e7LLzl9BUXy6lzUKpz/NnjJgWK1kLSugfdEs6 8aVD/bw1ZhmpF+uw1t8oeE/hqE77e7Ahgu9QOvUnEpvRDxeTrJFq7B0pB3lZMMYF+3gh RPE18P/oSu11bbxX6Wjgg733xnG7hQpv0SbxX8qAw1Hz5dfRo6P4CRbLefdZtMcpqRTl IXkGkLBf2U3HwolhYBqvKcTete9dqzTNzou8h0HWB7kQJWMewr0zPCOu1mxKKRtRCojc TyIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TzUVpcfC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h14-20020a50e10e000000b003f8a4c98a47si8700372edl.217.2022.03.07.02.02.13; Mon, 07 Mar 2022 02:02:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TzUVpcfC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236663AbiCGJYU (ORCPT + 99 others); Mon, 7 Mar 2022 04:24:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237002AbiCGJXR (ORCPT ); Mon, 7 Mar 2022 04:23:17 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7944673FE; Mon, 7 Mar 2022 01:21:37 -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 ams.source.kernel.org (Postfix) with ESMTPS id 7113AB810BC; Mon, 7 Mar 2022 09:21:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA493C340E9; Mon, 7 Mar 2022 09:21:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646644895; bh=FiohOt7NoQYLxo5ix/ERErfoSi8NWtSUiMdB3zj+G9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TzUVpcfCxhpRKiRBd8h6WNDE0QZpV1O+3g3J+ujfM1pvt7x+RNuwGB0Z0447+DMys Vsds+bSVeKchDK1Zdvs9fSFCBXP7v2VnaswPNGneAHgvRG20tObYItnAVDzfwAqGZV Z3AyH00aDsJXOp8aS/edlvwpHmQPnXYkfWEWKSKQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marek Vasut , Mark Brown Subject: [PATCH 4.14 14/42] ASoC: ops: Shift tested values in snd_soc_put_volsw() by +min Date: Mon, 7 Mar 2022 10:18:48 +0100 Message-Id: <20220307091636.565053278@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091636.146155347@linuxfoundation.org> References: <20220307091636.146155347@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marek Vasut commit 9bdd10d57a8807dba0003af0325191f3cec0f11c upstream. While the $val/$val2 values passed in from userspace are always >= 0 integers, the limits of the control can be signed integers and the $min can be non-zero and less than zero. To correctly validate $val/$val2 against platform_max, add the $min offset to val first. Fixes: 817f7c9335ec0 ("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw()") Signed-off-by: Marek Vasut Cc: Mark Brown Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220215130645.164025-1-marex@denx.de Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/soc-ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -328,7 +328,7 @@ int snd_soc_put_volsw(struct snd_kcontro mask = BIT(sign_bit + 1) - 1; val = ucontrol->value.integer.value[0]; - if (mc->platform_max && val > mc->platform_max) + if (mc->platform_max && ((int)val + min) > mc->platform_max) return -EINVAL; if (val > max - min) return -EINVAL; @@ -341,7 +341,7 @@ int snd_soc_put_volsw(struct snd_kcontro val = val << shift; if (snd_soc_volsw_is_stereo(mc)) { val2 = ucontrol->value.integer.value[1]; - if (mc->platform_max && val2 > mc->platform_max) + if (mc->platform_max && ((int)val2 + min) > mc->platform_max) return -EINVAL; if (val2 > max - min) return -EINVAL;