Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1666062pxb; Wed, 9 Feb 2022 01:38:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwY+OK3YgyzgJGtfqU3CPCmujhhGDpdtJ0NLpDIvPZvZ4eXnHc+bqJzORcz3B23hIH8w4NI X-Received: by 2002:aa7:864f:: with SMTP id a15mr1360763pfo.14.1644399490715; Wed, 09 Feb 2022 01:38:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644399490; cv=none; d=google.com; s=arc-20160816; b=pzKYdCrCFH9IMC88yLoOAXREOUrpvY570iGADz+GPpTC/D6nFfObRtkV/1H3FNn9Eg HF7KYMFikTHF3iPmMb+XtCC6ECR+flg87zUOilVXOvqHmb5fuNk49pTKRFeXYagWQCQR Jm5MSqUHqpaLb38I6wq0hR8ZlhFjwJTy8zEfq+dkCrUJsnWvnhF/sBQVQ6BZ3UJtyf4W OyyRAD4qD/NQJJFOBsCFy8HwJvSh3PUzmFp25lCOHUJGkqKDaYwRoGiXzz4CvQLAqeUD krbBKFXkqsFbNWSwoBiEmCyyAJ2TquQq5VCYb/lDcC1OLVQ7RIRFAxOQcMPRPEBmKFbn ty6g== 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=fm8YvP4g6vZxxvekJEZaTLi9Yvi5JStlu8snLYD5vlUnZFrXJzzmpeHgF7qsS23r0V ri2vkkKdlH4LwQIR2eDYuc+FkzUJ915wBUI0KzWgbE5HV983rOwTBClbtq+cTH3RYY1Q 50C6r234v0jCaZsqD/B2CNFU3bbUSyZCYwMD+03Pv/zpdbwIZ0oIEpQc/QG9epBQ5G0c w+HEQCq+Q9tNU8UT5rdRuByc0qu9bLzq/U5jlneJJyTuQqJB2Y+NKBZvT1Sg1q6vp7iP hp9GHQklU5Udj3mlDYVuEpcqyT9uSFnE+qsUF4mJjV3ZuUcFKvJAEOl3Flr5q4ok7MBd GTnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hS3KZFwJ; 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 hk16si5653270pjb.87.2022.02.09.01.38.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 01:38:10 -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=hS3KZFwJ; 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 0A810E065946; Wed, 9 Feb 2022 01:02:48 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388065AbiBGLmr (ORCPT + 99 others); Mon, 7 Feb 2022 06:42:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385628AbiBGLcD (ORCPT ); Mon, 7 Feb 2022 06:32:03 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25EF8C03C188; Mon, 7 Feb 2022 03:31:16 -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 7DC4EB80EC3; Mon, 7 Feb 2022 11:31:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D640CC004E1; Mon, 7 Feb 2022 11:31:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233473; bh=PXxvrLo0f5n0j+2ESXkHAGvNHfjbEgwhgKzsc6FW1F4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hS3KZFwJCm2WI6hwWUN/YOrdvusyANhbjofhosbzGZ+JpWLVfeBlV7IMx+HYgxlGo tBKGrAqEkcWMpMlqewcqZDWqPvNNbKegp7Sz/FqKPvVdNAKDHUg5/0x1+f+b8XwjmY TVQKvnugsvNJ1L5qjIJo/9zhJsMLPKnTfGZMF8EU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Brown Subject: [PATCH 5.16 007/126] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw() Date: Mon, 7 Feb 2022 12:05:38 +0100 Message-Id: <20220207103804.313847490@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@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) {