stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hector Martin <marcan@marcan.st>
To: Alexander Wetzel <alexander@wetzel-home.de>,
	linux-wireless@vger.kernel.org,
	Johannes Berg <johannes.berg@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: johannes@sipsolutions.net, stable@vger.kernel.org,
	Asahi Linux <asahi@lists.linux.dev>, Ilya <me@0upti.me>,
	Janne Grunau <j@jannau.net>, LKML <linux-kernel@vger.kernel.org>,
	regressions@lists.linux.dev
Subject: [REGRESSION] Patch broke WPA auth: Re: [PATCH v2] wifi: cfg80211: Fix use after free for wext
Date: Sat, 11 Mar 2023 18:55:59 +0900	[thread overview]
Message-ID: <d6851c2b-7966-6cb4-a51c-7268c60e0a86@marcan.st> (raw)
In-Reply-To: <20230124141856.356646-1-alexander@wetzel-home.de>

Hi,

This broke WPA auth entirely on brcmfmac (in offload mode) and probably
others, including on stable 6.2.3 and 6.3-rc1 (tested with iwd). Please
revert or fix. Notes below.

Reported-by: Ilya <me@0upti.me>
Reported-by: Janne Grunau <j@jannau.net>

#regzbot introduced: 015b8cc5e7c4d7
#regzbot monitor:
https://lore.kernel.org/linux-wireless/20230124141856.356646-1-alexander@wetzel-home.de/

On 24/01/2023 23.18, Alexander Wetzel wrote:
> Key information in wext.connect is not reset on (re)connect and can hold
> data from a previous connection.
> 
> Reset key data to avoid that drivers or mac80211 incorrectly detect a
> WEP connection request and access the freed or already reused memory.
> 
> Additionally optimize cfg80211_sme_connect() and avoid an useless
> schedule of conn_work.
> 
> Fixes: fffd0934b939 ("cfg80211: rework key operation")
> Cc: stable@vger.kernel.org
> Link: https://lore.kernel.org/r/c80f04d2-8159-a02a-9287-26e5ec838826@wetzel-home.de
> Signed-off-by: Alexander Wetzel <alexander@wetzel-home.de>
> 
> ---
> V2 changes:
> - updated comment
> - reset more key data
> 
> ---
>  net/wireless/sme.c | 31 ++++++++++++++++++++++++++-----
>  1 file changed, 26 insertions(+), 5 deletions(-)
> 
> diff --git a/net/wireless/sme.c b/net/wireless/sme.c
> index 123248b2c0be..0cc841c0c59b 100644
> --- a/net/wireless/sme.c
> +++ b/net/wireless/sme.c
[snip]
> @@ -1464,6 +1476,15 @@ int cfg80211_connect(struct cfg80211_registered_device *rdev,

This if branch only fires if the connection is WEP.

>  	} else {
>  		if (WARN_ON(connkeys))
>  			return -EINVAL;
> +
> +		/* connect can point to wdev->wext.connect which
> +		 * can hold key data from a previous connection
> +		 */
> +		connect->key = NULL;
> +		connect->key_len = 0;
> +		connect->key_idx = 0;

And these are indeed only used by WEP.

> +		connect->crypto.cipher_group = 0;
> +		connect->crypto.n_ciphers_pairwise = 0;

But here you're killing the info that is used for *other* auth modes too
if !WEP, breaking WPA and everything else.

>  	}
>  
>  	wdev->connect_keys = connkeys;

- Hector

  reply	other threads:[~2023-03-11  9:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-24 14:18 [PATCH v2] wifi: cfg80211: Fix use after free for wext Alexander Wetzel
2023-03-11  9:55 ` Hector Martin [this message]
2023-03-11 11:03   ` [REGRESSION] Patch broke WPA auth: " Hans de Goede
2023-03-11 12:30     ` Greg Kroah-Hartman
2023-03-11 14:19   ` [PATCH] wifi: cfg80211: Partial revert "wifi: cfg80211: Fix use after free for wext" Hector Martin
2023-03-11 14:22     ` Janne Grunau
2023-03-11 14:31     ` Eric Curtin
2023-03-13 14:18   ` [REGRESSION] Patch broke WPA auth: Re: [PATCH v2] wifi: cfg80211: Fix use after free for wext Linux regression tracking #update (Thorsten Leemhuis)
     [not found] <1b393dfc-76be-9404-e7c9-a2f9fff215a8@manjaro.org>
     [not found] ` <ZA3m5s7yfTGMVthu@kroah.com>
     [not found]   ` <5dc06a75-9913-8f47-a79e-38b0879808bb@manjaro.org>
     [not found]     ` <ZA3xjPWtCHtE9pAQ@kroah.com>
2023-03-12 15:46       ` Philip Müller

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=d6851c2b-7966-6cb4-a51c-7268c60e0a86@marcan.st \
    --to=marcan@marcan.st \
    --cc=alexander@wetzel-home.de \
    --cc=asahi@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=j@jannau.net \
    --cc=johannes.berg@intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=me@0upti.me \
    --cc=regressions@lists.linux.dev \
    --cc=stable@vger.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).