From mboxrd@z Thu Jan 1 00:00:00 1970 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 B3A4A82896; Fri, 2 Feb 2024 10:35:01 +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=1706870101; cv=none; b=RKAbu7cNGbtTaKpZiP0ItLd4KUETUoSJ8f8uId8/sncjuAjWsYPy6/FqyeMHMbJtUU3eL34mTYVlfm+kqnh/OkjtCraXQzDqBDhFit27VeIVTkbb3vbGfoh8WX1sYJl3PCj5qIeAr5hpKbRwo+fivmjj2UmeqTIII3GsTvKq0xs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706870101; c=relaxed/simple; bh=uD/sPc7FMJ/uY13jycAiw319CMk1mhe2FbFR5UM4LCo=; h=From:To:Cc:Subject:References:Date:In-Reply-To:Message-ID: MIME-Version:Content-Type; b=BM3R6+GG9XFfT8yDPv4rBlAdl1qf6z1+FCeKxmzyxKwDIRKupMmHB/5Zb9vL0gVpTAJYzYE2TujwPZxfUwK6VNouO9xn3bF2NHlYrVVTF6MQA+6hP+TnACVh62sD1pxYvHZ2XvZLdZAU66HhHnPPdIjypKgmG/BnkSshv7IhBH0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Rrx9tZLd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Rrx9tZLd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E41DC433C7; Fri, 2 Feb 2024 10:34:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706870101; bh=uD/sPc7FMJ/uY13jycAiw319CMk1mhe2FbFR5UM4LCo=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Rrx9tZLdm0GUAzf3hhCrj99t2K7tE2YFipabCOhmLwfTwbP05vhk0npEfIycZWRQY LDXyp9K5JgESqlVT3Si1xDf0UlR+CePpjDYRZtQmonq5efdbNuyrMe7dvvOpRSIgkF AAu1NVzwj65B+bCxC+Pgf3ahfp96h7ZP4MV1O4iQ1WjhhROuzLY1RzlwYa+SEtHEfy +6EputEp7XjMrfLzfOPCsifhzBNQeyU/3xL9pB++tf0nhs1YWkSSp2luaoUDpPmSk0 GQKUdjXcG8C6/LbXJdaqrs2W53Jl5C2wvDoCz6Q/gATd3c+APGY8keSSAAUWR79m1D bvBJChBiCeB6g== From: Kalle Valo To: Arend Van Spriel Cc: 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 Subject: Re: [PATCH] wifi: brcmfmac: Adjust n_channels usage for __counted_by References: <20240126223150.work.548-kees@kernel.org> <170678189299.2736043.11616312910656558919.kvalo@kernel.org> Date: Fri, 02 Feb 2024 12:34:54 +0200 In-Reply-To: (Arend Van Spriel's message of "Fri, 2 Feb 2024 11:00:51 +0100") Message-ID: <87v877tar5.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Arend Van Spriel writes: > On 2/2/2024 10:58 AM, Arend Van Spriel wrote: > >> On 2/1/2024 11:04 AM, Kalle Valo wrote: >>> 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 inde= x. >>>> 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] >>>> =C2=A0 3783 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 req->channels[req->n_channels++] = =3D chan; >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= ~~~~~~~~~~~~~~~^~ >>>> >>>> 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? >> This slipped past my broadcom email. As the Fixes commit is in 6.7 I >> would say ACK. Thanks. > Cc: to stable? Is commit e3eac9f32ec0 in stable releases? (I don't follow stable and don't know what commits they take.) I propose that as we have Fixes tag let's not add cc but instead let stable maintainers to decide. --=20 https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatc= hes