Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp65074rdb; Thu, 1 Feb 2024 02:06:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGV1kTmmvgk0doGHu2yFkyPkM2WFXWdugKhh8r9mdjMhkxJ7G9K/+nW/swxMJgS4cTkRjGm X-Received: by 2002:a05:6a20:b7aa:b0:19b:1eda:ab61 with SMTP id fh42-20020a056a20b7aa00b0019b1edaab61mr1293383pzb.54.1706781982579; Thu, 01 Feb 2024 02:06:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706781982; cv=pass; d=google.com; s=arc-20160816; b=KBGiCAQ+0MVDES52vr93ctZzdNke6PWJZrnkAMrpp5qDBfv/p3nNORO5R2j59O8lHt 9dUwTa45V1GLVq5XWGfZQ6L0sXQddPanY6mKwQtX1DPAbc8AZ+1pXm8W0MD05nzLOlY5 uOjORI9JnDm41lhC4SqiNdmXIsY0ukQNgSMyQ/zik1K+xk8YetUNe6kvMjOWbaa2D1az J7hWM0Mz5qqOVQ2KVmX+izZQ2dzo818Ss45s/QWBqlOaUnLNM2nlmoR6MXSIqKmroQ0C ck7XqoY/W+QcusfflKlmByDRJpw10y7hFokA+67hLZR6A3W9c24Hbg4fzAIF7eMevi+r JGaw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:message-id:user-agent:cc:to:references:in-reply-to:from :subject:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=bV1Mhk6r9MortrgSzQSWY2q3Kr3pg8hBMZC4xtcA7WI=; fh=bDNoYK/tWypunRhAwTgQuaGKl/GAvV9yXVfEexOtUiY=; b=heyciyxakPojMRob2755VdsI+HQVhwOnF8rtr72+P1ZKmr2ijE6yfeVg59CKSAhyKl CKHnpKD81RbamYGvA1SFzAe1eePzUKGxpBFgnHx9BPdYsBvazGBPnyyc1Ls/ExlPB927 ev3N0RG5lgVQadCP+U+e0Fjb5G2ApPWXmZZR9RDtS6MaQvDqxoEOhMr3a9Yu4YqDXR6V TAb/VrRDoFtOySacgy6WDnpywUYQlZZFVb+sNYjSQ6tPOtjhIlokYfB8LC82wzxhB6rO DF7KWKmyF3026EmMR7ED09fI5yaX5I5s+DqIhf/NJfJxZKmEpxVvI/C2ilwYxZ0jKy95 xyAA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Spb11YDQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47933-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47933-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXbPFgYTBpMqt3EOl4TvkbaErpsjnY87rvEoiMQkYRCdnkslrJUHwe6ocE1Z2fMYL7Ip+vMFje75ziltNLr6EP9THn1a9xUUhC2eqaVOQ== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id w17-20020a056a0014d100b006dde293d981si11933141pfu.217.2024.02.01.02.06.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 02:06:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47933-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Spb11YDQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47933-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47933-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id F418528F950 for ; Thu, 1 Feb 2024 10:05:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF1EA15B111; Thu, 1 Feb 2024 10:05:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Spb11YDQ" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4626157E8C; Thu, 1 Feb 2024 10:04:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706781899; cv=none; b=YBo5oo8hj0SWwTy2LgtRAysmRedfY+lHnmNNo/mK9Q91+8uZ/7QdbJYL8Tp3appBABqhvjOKvvYKE2wt8wSocqOmNlBgQg9Rie4qpAKrNUi28oFxh0GHBskCuT4uzgKArCJ2RO1xzNllkk7w8tA5emdezoQixwjm6rDOAb3AfVE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706781899; c=relaxed/simple; bh=8TIIbJywfSgXtb8lGT94VIK+gTj2yGJOv20IJhffFuw=; h=Content-Type:MIME-Version:Subject:From:In-Reply-To:References:To: Cc:Message-ID:Date; b=RUQmPw3bWu+e741YCUw2rYDrPOmXa+QQsdQ5ZCl9Cn9RXh5FpsgCOmjFGn+Q4DSpvLztjvJM7NpGURyjkGoxS+KIy4up5EDJ03Hu42fsb7DjH0zVJSx/Jmp8yoxWFk5+WjN79Sf5yq2KsuAReTyUdq5j0CiK50vwS/jWpvN/yI8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Spb11YDQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36F6BC43390; Thu, 1 Feb 2024 10:04:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706781899; bh=8TIIbJywfSgXtb8lGT94VIK+gTj2yGJOv20IJhffFuw=; h=Subject:From:In-Reply-To:References:To:Cc:Date:From; b=Spb11YDQ3+JmhooytAL0rCa5lO8q2jebhc1EbXXL77WVIXSNSYqWuTOyfb1sgRZPW LGEk0tHyT8k1BaTDpio/sunz5a/0MTFK9v0I8BT37d6V2w1TSzvce6nb+rrhLxZwN1 /sZ1T3KmW8sjZUnosO1eaLbK3VsS0aZ7iupBuubg9H8xqeeG96r/E4XViMha50BnGb ehDAE/XcdR/oUEFEF9fMxMYdzBXaEi2h3PhPMlv7noV1muJABt/Sx0GfwVAr6BJ1mP q07zIwXelyyaPikk5belAo9rX2PU3fBhchEc6OFjhaFW/cc8Jnz8i991IFEVkuzxeQ oFdgn3+1zGluw== Content-Type: text/plain; charset="utf-8" Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [PATCH] wifi: brcmfmac: Adjust n_channels usage for __counted_by From: Kalle Valo In-Reply-To: <20240126223150.work.548-kees@kernel.org> References: <20240126223150.work.548-kees@kernel.org> To: Kees Cook Cc: Arend van Spriel , Kees Cook , Franky Lin , Hante Meuleman , Chi-hsien Lin , Ian Lin , Johannes Berg , Wright Feng , Hector Martin , linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, "Gustavo A. R. Silva" , Linus Walleij , Jisoo Jang , Hans de Goede , Aloka Dixit , John Keeping , Jeff Johnson , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org User-Agent: pwcli/0.1.1-git (https://github.com/kvalo/pwcli/) Python/3.11.2 Message-ID: <170678189299.2736043.11616312910656558919.kvalo@kernel.org> Date: Thu, 1 Feb 2024 10:04:55 +0000 (UTC) Kees Cook wrote: > After commit e3eac9f32ec0 ("wifi: cfg80211: Annotate struct > cfg80211_scan_request with __counted_by"), the compiler may enforce > dynamic array indexing of req->channels to stay below n_channels. As a > result, n_channels needs to be increased _before_ accessing the newly > added array index. Increment it first, then use "i" for the prior index. > Solves this warning in the coming GCC that has __counted_by support: > > ../drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c: In function 'brcmf_internal_escan_add_info': > ../drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:3783:46: warning: operation on 'req-> > n_channels' may be undefined [-Wsequence-point] > 3783 | req->channels[req->n_channels++] = chan; > | ~~~~~~~~~~~~~~~^~ > > Fixes: e3eac9f32ec0 ("wifi: cfg80211: Annotate struct cfg80211_scan_request with __counted_by") > Cc: Arend van Spriel > Cc: Franky Lin > Cc: Hante Meuleman > Cc: Kalle Valo > Cc: Chi-hsien Lin > Cc: Ian Lin > Cc: Johannes Berg > Cc: Wright Feng > Cc: Hector Martin > Cc: linux-wireless@vger.kernel.org > Cc: brcm80211-dev-list.pdl@broadcom.com > Signed-off-by: Kees Cook > Reviewed-by: Hans de Goede > Reviewed-by: Linus Walleij > Reviewed-by: Gustavo A. R. Silva I'm planning to queue this for wireless tree. Arend, ack? -- https://patchwork.kernel.org/project/linux-wireless/patch/20240126223150.work.548-kees@kernel.org/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches