Linux Hardening
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Kees Cook <kees@kernel.org>, Johannes Berg <johannes@sipsolutions.net>
Cc: John Rowley <lkml@johnrowley.me>,
	Dmitry Antipov <dmantipov@yandex.ru>,
	Nathan Chancellor <nathan@kernel.org>,
	linux-wireless@vger.kernel.org,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] wifi: cfg80211: Move cfg80211_scan_req_add_chan() n_channels increment earlier
Date: Mon, 30 Dec 2024 12:58:46 -0600	[thread overview]
Message-ID: <68b4d078-f275-4e42-8eba-e6002bd3db59@embeddedor.com> (raw)
In-Reply-To: <20241230183610.work.680-kees@kernel.org>



On 30/12/24 12:36, Kees Cook wrote:
> Since adding __counted_by(n_channels) to struct cfg80211_scan_request,
> anything adding to the channels array must increment n_channels first.
> Move n_channels increment earlier.
> 
> Reported-by: John Rowley <lkml@johnrowley.me>
> Closes: https://lore.kernel.org/stable/1815535c709ba9d9.156c6a5c9cdf6e59.b249b6b6a5ee4634@localhost.localdomain/
> Fixes: aa4ec06c455d ("wifi: cfg80211: use __counted_by where appropriate")
> Signed-off-by: Kees Cook <kees@kernel.org>

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

-Gustavo

> ---
> Cc: Johannes Berg <johannes@sipsolutions.net>
> Cc: Dmitry Antipov <dmantipov@yandex.ru>
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: linux-wireless@vger.kernel.org
> ---
>   net/wireless/scan.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/wireless/scan.c b/net/wireless/scan.c
> index 1c6fd45aa809..ccdbeb604639 100644
> --- a/net/wireless/scan.c
> +++ b/net/wireless/scan.c
> @@ -763,12 +763,11 @@ static  void cfg80211_scan_req_add_chan(struct cfg80211_scan_request *request,
>   		}
>   	}
>   
> +	request->n_channels++;
>   	request->channels[n_channels] = chan;
>   	if (add_to_6ghz)
>   		request->scan_6ghz_params[request->n_6ghz_params].channel_idx =
>   			n_channels;
> -
> -	request->n_channels++;
>   }
>   
>   static bool cfg80211_find_ssid_match(struct cfg80211_colocated_ap *ap,


      reply	other threads:[~2024-12-30 18:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-30 18:36 [PATCH] wifi: cfg80211: Move cfg80211_scan_req_add_chan() n_channels increment earlier Kees Cook
2024-12-30 18:58 ` Gustavo A. R. Silva [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=68b4d078-f275-4e42-8eba-e6002bd3db59@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=dmantipov@yandex.ru \
    --cc=gustavoars@kernel.org \
    --cc=johannes@sipsolutions.net \
    --cc=kees@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lkml@johnrowley.me \
    --cc=nathan@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox