Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1829714pxb; Wed, 9 Feb 2022 05:30:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJxn8duikHJMYqkXsJXCQU2PLtNZtC+V3KoPKqRXVuROkGysqEaAVl+y5Ip62OfqCkQXzqyo X-Received: by 2002:a17:90b:1d90:: with SMTP id pf16mr2564992pjb.245.1644413405215; Wed, 09 Feb 2022 05:30:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644413405; cv=none; d=google.com; s=arc-20160816; b=jJLtonRqbBJk43nxQV3psyESnIFMt1DKolVtMyTRuUXOWeWG4Cx0ucjSIKZYeNYFVX f+P8b87SewhgaecBiXG65JGrsUCfm7fdeM5SKy84IYxUvrb/mGGBTFs4USYSjy0wKk+Y Zxb4HsXSMfmMCi9+ahVXVB85q4RJNT32O4mrC2OvWewtKqvFEGj0Ufs1dhe/XvSeW863 NefZwgpEWDiQI4A0hzWUXNwjrlmZzJRMVGOu9/9kdOonEuvTfm9NaJJC6bbex2VWmqOg KpXtVJPDWUU0INg5T83TYt6RoPUv9SjIS3VRejHMSlrrjloxeChrjzrH4c/2FCQ0w4gp MrVg== 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=0a4RQ8HUVU+4cYrBU17l5Lvk3C/DV/a7uHcuOAEIP/M=; b=RAiWQWOOXdvCnI0ZSHsoDWL2l0wToIEJtWd1VsKNaMa7Z1+Fw3F5W9CJT6qEq2mIdr 6zN77eS1UiuXIDdSkqOG9FwpE4tF5Z7JSYIC7nG0BpqzVBZExMO6iUW1xzDkGt/Pbxa+ +kGPmAntmR5cx+VWKkrYIvhdJVUM0PK5OaPwnw+b3gtkAuo17G3KexO0yeJtCEw6LXQd H3CUImfvECyqcBqUy6+H0uKh85VO+M3sXfyXzu5q2eKm/Aksw/blkHgU3gmUjHdY9uAQ fpkv1ODq+Mp+sBybrfQiISiqWJIg5MO29xHMfMybOjRYVHqgUvGE4VNGF7CIOIC28k1M 0F+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zCBkWLvg; 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 t1si641093plg.149.2022.02.09.05.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 05:30:05 -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=zCBkWLvg; 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 3C3CCE08D185; Wed, 9 Feb 2022 02:14:41 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381155AbiBGLRC (ORCPT + 99 others); Mon, 7 Feb 2022 06:17:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379885AbiBGLQ2 (ORCPT ); Mon, 7 Feb 2022 06:16:28 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA6D5C043181; Mon, 7 Feb 2022 03:16:27 -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 7B52CB80EC3; Mon, 7 Feb 2022 11:16:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55234C004E1; Mon, 7 Feb 2022 11:16:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644232585; bh=V5zhYNZoU8n/q3yA/4X3J6GPtvrP5VLschKaveJCJQg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zCBkWLvgYWX9IWwHEIlX492eEOnKY69/aRoWQBtfBH05zMEBxiKKvLu4Upk6m551Z wt+Gd3puThWX02xmKb22STnBv8RkNNUX6Wn9/Exk4iAgvvTqp5FRMJ02aBJV8WSIjH hIWO90eLDIsP/DoeHTSmLzu6MomAtbOIB9a/2pWo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Brown Subject: [PATCH 4.19 56/86] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx() Date: Mon, 7 Feb 2022 12:06:19 +0100 Message-Id: <20220207103759.397178352@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103757.550973048@linuxfoundation.org> References: <20220207103757.550973048@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 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 @@ -436,8 +436,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);