linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Will Deacon <will@kernel.org>
Cc: linux-wireless@vger.kernel.org, nico@semmle.com,
	stable@vger.kernel.org, Johannes Berg <johannes@sipsolutions.net>
Subject: Re: [PATCH 1/2] mac80211: Reject malformed SSID elements
Date: Fri, 4 Oct 2019 08:55:50 -0700	[thread overview]
Message-ID: <201910040855.8E8B4D7A@keescook> (raw)
In-Reply-To: <20191004095132.15777-1-will@kernel.org>

On Fri, Oct 04, 2019 at 10:51:31AM +0100, Will Deacon wrote:
> Although this shouldn't occur in practice, it's a good idea to bounds
> check the length field of the SSID element prior to using it for things
> like allocations or memcpy operations.
> 
> Cc: <stable@vger.kernel.org>
> Cc: Johannes Berg <johannes@sipsolutions.net>
> Cc: Kees Cook <keescook@chromium.org>
> Reported-by: Nicolas Waisman <nico@semmle.com>
> Signed-off-by: Will Deacon <will@kernel.org>

Reviewed-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  net/mac80211/mlme.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
> index 26a2f49208b6..54dd8849d1cc 100644
> --- a/net/mac80211/mlme.c
> +++ b/net/mac80211/mlme.c
> @@ -2633,7 +2633,8 @@ struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw,
>  
>  	rcu_read_lock();
>  	ssid = ieee80211_bss_get_ie(cbss, WLAN_EID_SSID);
> -	if (WARN_ON_ONCE(ssid == NULL))
> +	if (WARN_ONCE(!ssid || ssid[1] > IEEE80211_MAX_SSID_LEN,
> +		      "invalid SSID element (len=%d)", ssid ? ssid[1] : -1))
>  		ssid_len = 0;
>  	else
>  		ssid_len = ssid[1];
> @@ -5233,7 +5234,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
>  
>  	rcu_read_lock();
>  	ssidie = ieee80211_bss_get_ie(req->bss, WLAN_EID_SSID);
> -	if (!ssidie) {
> +	if (!ssidie || ssidie[1] > sizeof(assoc_data->ssid)) {
>  		rcu_read_unlock();
>  		kfree(assoc_data);
>  		return -EINVAL;
> -- 
> 2.23.0.581.g78d2f28ef7-goog
> 

-- 
Kees Cook

      parent reply	other threads:[~2019-10-04 15:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-04  9:51 [PATCH 1/2] mac80211: Reject malformed SSID elements Will Deacon
2019-10-04  9:51 ` [PATCH 2/2] cfg80211: wext: " Will Deacon
2019-10-04 15:56   ` Kees Cook
2019-10-04 15:55 ` Kees Cook [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=201910040855.8E8B4D7A@keescook \
    --to=keescook@chromium.org \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=nico@semmle.com \
    --cc=stable@vger.kernel.org \
    --cc=will@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;
as well as URLs for NNTP newsgroup(s).