lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <380ac5df-017b-47cf-a039-c60eb4eba39d@embeddedor.com>
Date: Sat, 27 Jan 2024 11:00:12 -0600
From: "Gustavo A. R. Silva" <gustavo@...eddedor.com>
To: Kees Cook <keescook@...omium.org>, Arend van Spriel <aspriel@...il.com>
Cc: Franky Lin <franky.lin@...adcom.com>,
 Hante Meuleman <hante.meuleman@...adcom.com>, Kalle Valo <kvalo@...nel.org>,
 Chi-hsien Lin <chi-hsien.lin@...ineon.com>, Ian Lin <ian.lin@...ineon.com>,
 Johannes Berg <johannes.berg@...el.com>,
 Wright Feng <wright.feng@...ress.com>, Hector Martin <marcan@...can.st>,
 linux-wireless@...r.kernel.org, brcm80211-dev-list.pdl@...adcom.com,
 "Gustavo A. R. Silva" <gustavoars@...nel.org>,
 Linus Walleij <linus.walleij@...aro.org>,
 Jisoo Jang <jisoo.jang@...sei.ac.kr>, Hans de Goede <hdegoede@...hat.com>,
 Aloka Dixit <quic_alokad@...cinc.com>, John Keeping <john@...ping.me.uk>,
 Jeff Johnson <quic_jjohnson@...cinc.com>, linux-kernel@...r.kernel.org,
 linux-hardening@...r.kernel.org
Subject: Re: [PATCH] wifi: brcmfmac: Adjust n_channels usage for __counted_by



On 1/26/24 16:31, 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 <aspriel@...il.com>
> Cc: Franky Lin <franky.lin@...adcom.com>
> Cc: Hante Meuleman <hante.meuleman@...adcom.com>
> Cc: Kalle Valo <kvalo@...nel.org>
> Cc: Chi-hsien Lin <chi-hsien.lin@...ineon.com>
> Cc: Ian Lin <ian.lin@...ineon.com>
> Cc: Johannes Berg <johannes.berg@...el.com>
> Cc: Wright Feng <wright.feng@...ress.com>
> Cc: Hector Martin <marcan@...can.st>
> Cc: linux-wireless@...r.kernel.org
> Cc: brcm80211-dev-list.pdl@...adcom.com
> Signed-off-by: Kees Cook <keescook@...omium.org>

Reviewed-by: Gustavo A. R. Silva <gustavoars@...nel.org>

Thanks!
-- 
Gustavo

> ---
>   drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
> index 133c5ea6429c..28d6a30cc010 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
> @@ -3779,8 +3779,10 @@ static int brcmf_internal_escan_add_info(struct cfg80211_scan_request *req,
>   		if (req->channels[i] == chan)
>   			break;
>   	}
> -	if (i == req->n_channels)
> -		req->channels[req->n_channels++] = chan;
> +	if (i == req->n_channels) {
> +		req->n_channels++;
> +		req->channels[i] = chan;
> +	}
>   
>   	for (i = 0; i < req->n_ssids; i++) {
>   		if (req->ssids[i].ssid_len == ssid_len &&

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ