Message ID | ZQSr15AYJpDpipg6@work |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1269039vqi; Fri, 15 Sep 2023 12:21:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFM/dR0kQ8D01hRBZbq8lIqOEGdxlRpnwbeuHpp1z3kY9OWDoV3zYsw1t14OwX0aqYR6LYD X-Received: by 2002:a05:6358:3398:b0:134:d78f:67bc with SMTP id i24-20020a056358339800b00134d78f67bcmr2374030rwd.14.1694805676866; Fri, 15 Sep 2023 12:21:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694805676; cv=none; d=google.com; s=arc-20160816; b=PUE96LPkO9ABccn0h6+JbeU2r55a3ARTWS8fCx86KdPIbqz98kyhZKW3/IaSwWup0B BIRz0fz0cQlczxYW5Y61GPUFek988s3vBkr51FwvGTKq50kqu4Xm8ciwnziM1wsjVN/P J1eLd2/hkA8UqYLr4f6x/b5fVozK4APupKfhmQyxqciszI7HW993A3f+NEp3FZ/ebtfy vTnjLNXL4XeX/5fcm0VFbL6X6cIVoGFRFkDw5v21TchoPjnIoIhZYlAa3RYS4IfoaNbH c2Z5guxg4aE67AIyGi7LfT+/7cxLrDSo2TqsOkthaCWeXI4EBvPFy39sjKOPt8dfdPUg 6X/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=3mpTwQ0qDfY1S3hp7cZeYaNJzygwbpisyv4fM5hAHf0=; fh=ggHRXwYsmVRnlJJHySxHbJXzje9llUQuM0pl2FBjKqY=; b=NjfPQnHoZK1Xiaqo5Qqc0XE1MGvNvsIB7qr8tIafXPjm7OgvzyFUhwu56xzcBize5K P8at3HN1gx+vwv+PduF6Set+vfyNO+I+AJ/V8pCEQRDEFSjiDiCIYah3xSagePbTJDKl xt3HDTjzHOgcZlzbUpKQll5AvYcGGudP+KA3iKMzQPtSzKerISdfO0JP1SJ4iW4qelUn rOcU1WaOIQMiGiElYa1GkQAtqFx9gVkf5Ya1jKnfZqHSc2WtDKk9etMWgl5jRRndugGa j8fVWo2VViHM/0dKLZA+K2VLN+Zs9ARjyq1USF4QpQjbLIyCoqb0YMol9+0nFoZQ+EcO 0y+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gYy38NgD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id x15-20020a63170f000000b005774aba519dsi3582099pgl.298.2023.09.15.12.21.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 12:21:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gYy38NgD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id EA6FA8345672; Fri, 15 Sep 2023 12:09:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236983AbjIOTIu (ORCPT <rfc822;ruipengqi7@gmail.com> + 30 others); Fri, 15 Sep 2023 15:08:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236990AbjIOTIW (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 15 Sep 2023 15:08:22 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFE7BB2; Fri, 15 Sep 2023 12:08:17 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E4FFC433C9; Fri, 15 Sep 2023 19:08:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694804897; bh=MyIJinpQ9MRMn81ExQ9ajAd6WI7sU/Hkeyd+BcDwjgM=; h=Date:From:To:Cc:Subject:From; b=gYy38NgDEaxdxsygoAP+2/quW8rTNMyRpJP9ZV8TtK+g5Y5u0QXK1UTwRMjbwk8Gz XANgzlbvILid7tntD8XrkILDhzG8La55yDL8I9VW2nMh0CAvBxKoCC72EJZlWuDfbS R6P/JlkAL+PZbhxiQFlm3lBN/9NXAGye5UD+DJ1n0hdLE/CPGjDxAl6I1wNBmYwraW Knm0vmboBjTLurGoatMl48Nr1+bWEfcPBBUw5Y5D6rLzt+U4fWGs8HzKHBzyvbUhU2 5IlYhZPOSckqWgsP3grA4OJE/G+1aO6xdYnq+rrEzHBEd/6WqK0AU5zPhLHxgr/8TJ RNEs8sBPAwZGg== Date: Fri, 15 Sep 2023 13:09:11 -0600 From: "Gustavo A. R. Silva" <gustavoars@kernel.org> To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>, Liam Girdwood <lgirdwood@gmail.com>, Peter Ujfalusi <peter.ujfalusi@linux.intel.com>, Bard Liao <yung-chuan.liao@linux.intel.com>, Ranjani Sridharan <ranjani.sridharan@linux.intel.com>, Daniel Baluta <daniel.baluta@nxp.com>, Kai Vehmanen <kai.vehmanen@linux.intel.com>, Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com> Cc: sound-open-firmware@alsa-project.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, linux-hardening@vger.kernel.org Subject: [PATCH][next] ASoC: SOF: ipc4-topology: Use size_add() in call to struct_size() Message-ID: <ZQSr15AYJpDpipg6@work> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 15 Sep 2023 12:09:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777132557589290084 X-GMAIL-MSGID: 1777132557589290084 |
Series |
[next] ASoC: SOF: ipc4-topology: Use size_add() in call to struct_size()
|
|
Commit Message
Gustavo A. R. Silva
Sept. 15, 2023, 7:09 p.m. UTC
If, for any reason, the open-coded arithmetic causes a wraparound,
the protection that `struct_size()` adds against potential integer
overflows is defeated. Fix this by hardening call to `struct_size()`
with `size_add()`.
Fixes: f9efae954905 ("ASoC: SOF: ipc4-topology: Add support for base config extension")
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
sound/soc/sof/ipc4-topology.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Fri, Sep 15, 2023 at 01:09:11PM -0600, Gustavo A. R. Silva wrote: > If, for any reason, the open-coded arithmetic causes a wraparound, > the protection that `struct_size()` adds against potential integer > overflows is defeated. Fix this by hardening call to `struct_size()` > with `size_add()`. > > Fixes: f9efae954905 ("ASoC: SOF: ipc4-topology: Add support for base config extension") > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org>
On Fri, 15 Sep 2023 13:09:11 -0600, Gustavo A. R. Silva wrote: > If, for any reason, the open-coded arithmetic causes a wraparound, > the protection that `struct_size()` adds against potential integer > overflows is defeated. Fix this by hardening call to `struct_size()` > with `size_add()`. > > Applied to for-next/hardening, thanks! [1/1] ASoC: SOF: ipc4-topology: Use size_add() in call to struct_size() https://git.kernel.org/kees/c/93d2858dd630 Take care,
On Fri, Sep 29, 2023 at 12:14:59PM -0700, Kees Cook wrote: > On Fri, 15 Sep 2023 13:09:11 -0600, Gustavo A. R. Silva wrote: > > If, for any reason, the open-coded arithmetic causes a wraparound, > > the protection that `struct_size()` adds against potential integer > > overflows is defeated. Fix this by hardening call to `struct_size()` > > with `size_add()`. > [1/1] ASoC: SOF: ipc4-topology: Use size_add() in call to struct_size() > https://git.kernel.org/kees/c/93d2858dd630 Why is this bypassing the ASoC tree?
On Sun, Oct 01, 2023 at 11:25:59AM +0100, Mark Brown wrote: > On Fri, Sep 29, 2023 at 12:14:59PM -0700, Kees Cook wrote: > > On Fri, 15 Sep 2023 13:09:11 -0600, Gustavo A. R. Silva wrote: > > > > If, for any reason, the open-coded arithmetic causes a wraparound, > > > the protection that `struct_size()` adds against potential integer > > > overflows is defeated. Fix this by hardening call to `struct_size()` > > > with `size_add()`. > > > [1/1] ASoC: SOF: ipc4-topology: Use size_add() in call to struct_size() > > https://git.kernel.org/kees/c/93d2858dd630 > > Why is this bypassing the ASoC tree? Hi! Sorry, I can drop it if you want to take it? I tend to collect trivial hardening changes with reviews that haven't been otherwise commented on for at least 2 weeks. -Kees
On Sun, Oct 01, 2023 at 01:37:04PM -0700, Kees Cook wrote: > On Sun, Oct 01, 2023 at 11:25:59AM +0100, Mark Brown wrote: > > Why is this bypassing the ASoC tree? > Hi! Sorry, I can drop it if you want to take it? I tend to collect trivial > hardening changes with reviews that haven't been otherwise commented on > for at least 2 weeks. Yes, it's in my queue - 2 weeks is really rather fast between people not being available and waiting for driver authors to review if they normally look at things.
On Fri, 15 Sep 2023 13:09:11 -0600, Gustavo A. R. Silva wrote: > If, for any reason, the open-coded arithmetic causes a wraparound, > the protection that `struct_size()` adds against potential integer > overflows is defeated. Fix this by hardening call to `struct_size()` > with `size_add()`. > > Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next Thanks! [1/1] ASoC: SOF: ipc4-topology: Use size_add() in call to struct_size() commit: 3746284c233d5cf5f456400e61cd4a46a69c6e8c All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark
On Mon, Oct 02, 2023 at 04:17:24PM +0100, Mark Brown wrote: > On Fri, 15 Sep 2023 13:09:11 -0600, Gustavo A. R. Silva wrote: > > If, for any reason, the open-coded arithmetic causes a wraparound, > > the protection that `struct_size()` adds against potential integer > > overflows is defeated. Fix this by hardening call to `struct_size()` > > with `size_add()`. > > > > > > Applied to > > https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next > > Thanks! > > [1/1] ASoC: SOF: ipc4-topology: Use size_add() in call to struct_size() > commit: 3746284c233d5cf5f456400e61cd4a46a69c6e8c Thanks! I've dropped it from my tree. -Kees
diff --git a/sound/soc/sof/ipc4-topology.c b/sound/soc/sof/ipc4-topology.c index f2a30cd31378..2a19dd022aaf 100644 --- a/sound/soc/sof/ipc4-topology.c +++ b/sound/soc/sof/ipc4-topology.c @@ -895,7 +895,8 @@ static int sof_ipc4_widget_setup_comp_process(struct snd_sof_widget *swidget) if (process->init_config == SOF_IPC4_MODULE_INIT_CONFIG_TYPE_BASE_CFG_WITH_EXT) { struct sof_ipc4_base_module_cfg_ext *base_cfg_ext; u32 ext_size = struct_size(base_cfg_ext, pin_formats, - swidget->num_input_pins + swidget->num_output_pins); + size_add(swidget->num_input_pins, + swidget->num_output_pins)); base_cfg_ext = kzalloc(ext_size, GFP_KERNEL); if (!base_cfg_ext) {