Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4994405rwb; Mon, 31 Jul 2023 16:18:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlEDSVlpEtQZOKO07+3GFy/4FjEDhKBywAwVdPSBYHizYG+xVRMEJFLCJw+6EN1bhYeuCudC X-Received: by 2002:a05:6808:1205:b0:3a3:f45b:aa3d with SMTP id a5-20020a056808120500b003a3f45baa3dmr14507869oil.39.1690845511055; Mon, 31 Jul 2023 16:18:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690845511; cv=none; d=google.com; s=arc-20160816; b=R97yda8BLD5qElA8pn7fXZcaiQqMPVXnawmdsVtZGj3WtkK0zueYMqwaPOGW8xKTOK S/QI3Gfgxc378kIB+wKxvok+iZzewR/Zl6IJuIYxhh8czpZtbrZU4xF1Q8mPsQdDC8Jq R7h2QtoAg6+TCtjUkraUzJF0qRM/gpSN0buDngjcCmZJGefUEySTYVRNAplLc64kHW0v Hn2bj49RX1YyCl9OhcbncOf3dvb/C76p8OwUO/U30O1hbvZBvmjXwrefxYK4c1sUPcMt TR00J2PcNGlqmm+aPOJmxtsCu7WX06u1OblxSDtv4GkJetlcIq0A9J+mf3z+2pVCpaS+ wq3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=jM8pm+E+CXbfooJNhDR8HGuge+AEaE1NLBAsYmmAzr0=; fh=Hegjb4IRcJn2XVSprOL2il5q242OragDp4hGm05RHEM=; b=twYY5jkxSuJ1VM4vQU9rX72mFiDtVXwU91pnN9zzy/aS+dLvWWRa794rMrZJvjHydH 1wjz/goMqxz2CXkW/m5DV8U/4Z06rHui9SRbTIcDkro7eZ17ZEULqShsWasRUggwKjNn lSTKRWDB/zkCLX1w1Le8qkowSJmoMvrT1xuqcaPcGI36JjPyJ8OPnFQOapFpTYeQAwcp YfDXSYG5v+hYM7S62h1zPtt+cYzFE+Gg0Qy7b/ua3Fe67gy9a5Tc5N8I5TjLvz14L3kP orEHwo6lSSuW++Z440Il1ttZY0y0NrXVxkRAfK7ct0D+nSM5BA6hI90TAT38KHqf9dlp /k6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=N1hwJWEi; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a63574b000000b00553ce421356si7953918pgm.56.2023.07.31.16.18.23; Mon, 31 Jul 2023 16:18:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=@chromium.org header.s=google header.b=N1hwJWEi; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230301AbjGaXGQ (ORCPT + 59 others); Mon, 31 Jul 2023 19:06:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229558AbjGaXGP (ORCPT ); Mon, 31 Jul 2023 19:06:15 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61420FB for ; Mon, 31 Jul 2023 16:06:14 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-686f25d045cso3371444b3a.0 for ; Mon, 31 Jul 2023 16:06:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690844774; x=1691449574; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=jM8pm+E+CXbfooJNhDR8HGuge+AEaE1NLBAsYmmAzr0=; b=N1hwJWEiqpsml5Bo2TgnS3AB/U40NkvabYIHbcFb5+A5l3504hshHCBqDFCWQ5JAlV +C6LSQyAGjKXpTSgWJU8/HxkWI7bHMv+Pz0BxDwvBYx1NC/VQD/sQgEYUzLKftFhSOA1 Vp336OUbiXyy1rEw7UNb8Uff2dnhtUwBnM40s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690844774; x=1691449574; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=jM8pm+E+CXbfooJNhDR8HGuge+AEaE1NLBAsYmmAzr0=; b=lH+VZ5Ogx+Vpa4n5mh09H1HwvL7fh/O1MlNAiQO2W1vJm1EUvl0YgVW9jx1TmnIzBD xZe1HB0ivioMUySuimOanjRSQDEWmuRgs4c+qTeqU1iYnkU+3cl8du7dQiM4VDyORgxW vc2jBtC9kkA2zWx2DO2W1uPqncHDpyPcoVNR/L81JBtbC7VKC6pHVgpZlOlrMcBk60iz Q/7HxZ/tnUvtQa6FYRveMA61QZoVOicc5KbzruxCGohmVsuYUDDDH5lFX5oQTVSfrZ36 NNUx+0D0r06s6WeVuLxohaCGPrxVJD2pAGIwRhmlrlQtFlKemDUj6vat86N307pW+ETA GmMw== X-Gm-Message-State: ABy/qLYqs1otZWP5UML9keK0dcHM4CiyRjcFy6YyuvElwvaPpq1y1jD/ NiCSjcMb0lOE4PBk9nIXeWhjpw== X-Received: by 2002:a05:6a20:3d1e:b0:13d:17cc:5bca with SMTP id y30-20020a056a203d1e00b0013d17cc5bcamr9836125pzi.18.1690844773849; Mon, 31 Jul 2023 16:06:13 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id q13-20020a656a8d000000b0053051d50a48sm7858683pgu.79.2023.07.31.16.06.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 16:06:13 -0700 (PDT) Date: Mon, 31 Jul 2023 16:06:12 -0700 From: Kees Cook To: Hans de Goede Cc: Arend van Spriel , Franky Lin , Hante Meuleman , Kalle Valo , linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, SHA-cyfmac-dev-list@infineon.com Subject: Re: [PATCH] wifi: brcmfmac: Fix field-spanning write in brcmf_scan_params_v2_to_v1() Message-ID: <202307311605.706EEC44FD@keescook> References: <20230729140500.27892-1-hdegoede@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230729140500.27892-1-hdegoede@redhat.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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-wireless@vger.kernel.org On Sat, Jul 29, 2023 at 04:05:00PM +0200, Hans de Goede wrote: > Using brcmfmac with 6.5-rc3 on a brcmfmac43241b4-sdio triggers > a backtrace caused by the following field-spanning error: > > memcpy: detected field-spanning write (size 120) of single field > "¶ms_le->channel_list[0]" at > drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:1072 (size 2) > > Fix this by replacing the channel_list[1] declaration at the end of > the struct with a flexible array declaration. > > Most users of struct brcmf_scan_params_le calculate the size to alloc > using the size of the non flex-array part of the struct + needed extra > space, so they do not care about sizeof(struct brcmf_scan_params_le). > > brcmf_notify_escan_complete() however uses the struct on the stack, > expecting there to be room for at least 1 entry in the channel-list > to store the special -1 abort channel-id. > > To make this work use an anonymous union with a padding member > added + the actual channel_list flexible array. > > Cc: Kees Cook > Signed-off-by: Hans de Goede Looks good to me; it's consistent with how similar 1-element arrays with sensitive structure sizes have been updated lately. Thanks for the investigation! Reviewed-by: Kees Cook -Kees -- Kees Cook