Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1729541pxb; Wed, 9 Feb 2022 03:18:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwkDkQv3x4StXzhd8++jRWekSy2MwoEuuKdv3yLMi2ZwPDXW5GpSGA4lv9qgaVUh4OJUNLh X-Received: by 2002:a17:90a:3484:: with SMTP id p4mr1966729pjb.91.1644405484004; Wed, 09 Feb 2022 03:18:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644405483; cv=none; d=google.com; s=arc-20160816; b=jRP1zeEtAb1tJ1tYY0LKE2q4r+0FlL3SQHHU5OIyEzGzX5G6JrIVbd9QV9gL0v+GLO tS5JdpP7ec1fbANJrxrlh9uaSVL5sxx8OQDzYU/ZqQSQWfQViqNfYHDSFPYYr8bTPj8W zHZ9oInkrBEDyKRoDMJKPmw0URDrWBlEr+kaMIZxdA7HqUu0C0JsUMCR6JttFiBfn7oL lB+3R+vCMErRN157cIv4P/bHW5WPscokKu60xeQT5U0BSUzjQd9msg4IQnWjTB5eo2Bn QvhQokTJnvalQKdYzhU9j4jfWT2UXTcdKMIFQ5DmfGB+G8w0OUq+r7qJnHGNMujxEIcc 2V1g== 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=cTeRmJ+6AUlrzBF6yg5/HD+hFqhvQ9LWkQDysfktyeo=; b=gj1Rx3rntFckd8P1gxNKULoGKmhxYoBBGALDCmJuxA0+yk0KntPJflcmPOFG3jkTuo 6wLucZ4aBxqS/X5xyxHSkUQHqMqmbphGMVuIN71LfF4NDmyh1MxX7UYIhEliiqQ5LowS m2azExChjBewQ3YyH56fpXM5kd8xjBQLRhQ35H6OYJhuL/EbfdLQLvnj1rxc0PlRD1Ad D9Ig+uhqDd0kI+iE2M+pdOcIoLl5C1vKfz2bmN2OFykLNpSOGeF54mSZK0xEsR3ADV/z J0o50igJU49uaiyeBzP21K39Bf2Attng4UBE7MWY3JCQZUQYglsQOClJ5jgI+KlNLfJH qodg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iG5vhJGL; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k35si15193478pgl.310.2022.02.09.03.17.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 03:18:03 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iG5vhJGL; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 28528E06FB19; Wed, 9 Feb 2022 01:45:34 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379728AbiBGLhr (ORCPT + 99 others); Mon, 7 Feb 2022 06:37:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352941AbiBGLZO (ORCPT ); Mon, 7 Feb 2022 06:25:14 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8685BC0401C8; Mon, 7 Feb 2022 03:25:11 -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 48098B81028; Mon, 7 Feb 2022 11:25:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DEDFC004E1; Mon, 7 Feb 2022 11:25:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233109; bh=PXxvrLo0f5n0j+2ESXkHAGvNHfjbEgwhgKzsc6FW1F4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iG5vhJGLs+OLRSd+nwub68O2lJD1RSWeaBOdQpYAPHZgrSHe33xT4KyNGoxd018EU xLaPqtUxotsMQG31FRPPQtyzLsLHmu87/+PM4pBNa/y8HetS8StrokdDA3CArGAXxe P1VlJRVXhyblynBl8TUioYeNDQ1eEFq1nZ6oxmPw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Brown Subject: [PATCH 5.15 007/110] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw() Date: Mon, 7 Feb 2022 12:05:40 +0100 Message-Id: <20220207103802.532613748@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: Mark Brown commit 817f7c9335ec01e0f5e8caffc4f1dcd5e458a4c0 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-2-broonie@kernel.org Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/soc-ops.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -316,13 +316,27 @@ int snd_soc_put_volsw(struct snd_kcontro if (sign_bit) mask = BIT(sign_bit + 1) - 1; - val = ((ucontrol->value.integer.value[0] + min) & mask); + 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 = (val + min) & mask; if (invert) val = max - val; val_mask = mask << shift; val = val << shift; if (snd_soc_volsw_is_stereo(mc)) { - val2 = ((ucontrol->value.integer.value[1] + min) & mask); + val2 = ucontrol->value.integer.value[1]; + if (mc->platform_max && val2 > mc->platform_max) + return -EINVAL; + if (val2 > max - min) + return -EINVAL; + if (val2 < 0) + return -EINVAL; + val2 = (val2 + min) & mask; if (invert) val2 = max - val2; if (reg == reg2) {