From: Johannes Berg <johannes@sipsolutions.net>
To: linux-wireless@vger.kernel.org
Cc: Max Schulze <max.schulze@online.de>
Subject: Re: [RFC PATCH v3 6.1] wifi: cfg80211: fix cqm_config access race
Date: Wed, 16 Aug 2023 15:36:38 +0200 [thread overview]
Message-ID: <7bef5ebb985dacc7d497f2ab6d24a0f3402ce39a.camel@sipsolutions.net> (raw)
In-Reply-To: <20230816153202.07a31b651a28.I1a1bb102329fc88e4712eaf394cba3025ada0dc7@changeid>
Oh, wait, there's another bug here ... One that makes more sense.
On Wed, 2023-08-16 at 15:32 +0200, Johannes Berg wrote:
>
> @@ -12629,6 +12630,7 @@ static int nl80211_set_cqm_rssi(struct genl_info *info,
> u32 hysteresis)
> {
> struct cfg80211_registered_device *rdev = info->user_ptr[0];
> + struct cfg80211_cqm_config *cqm_config = NULL, *old;
> struct net_device *dev = info->user_ptr[1];
> struct wireless_dev *wdev = dev->ieee80211_ptr;
> int i, err;
> @@ -12646,10 +12648,6 @@ static int nl80211_set_cqm_rssi(struct genl_info *info,
> wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)
> return -EOPNOTSUPP;
>
> - wdev_lock(wdev);
> - cfg80211_cqm_config_free(wdev);
This used to NULL out the value on freeing
> - wdev_unlock(wdev);
> -
> if (n_thresholds <= 1 && rdev->ops->set_cqm_rssi_config) {
> if (n_thresholds == 0 || thresholds[0] == 0) /* Disabling */
> return rdev_set_cqm_rssi_config(rdev, dev, 0, 0);
> @@ -12666,9 +12664,9 @@ static int nl80211_set_cqm_rssi(struct genl_info *info,
> n_thresholds = 0;
>
> wdev_lock(wdev);
> + old = rcu_dereference_protected(wdev->cqm_config,
> + lockdep_is_held(&wdev->mtx));
> if (n_thresholds) {
> - struct cfg80211_cqm_config *cqm_config;
> -
> cqm_config = kzalloc(struct_size(cqm_config, rssi_thresholds,
> n_thresholds),
> GFP_KERNEL);
> @@ -12683,10 +12681,16 @@ static int nl80211_set_cqm_rssi(struct genl_info *info,
> flex_array_size(cqm_config, rssi_thresholds,
> n_thresholds));
>
> - wdev->cqm_config = cqm_config;
> + rcu_assign_pointer(wdev->cqm_config, cqm_config);
> }
>
> - err = cfg80211_cqm_rssi_update(rdev, dev);
> + err = cfg80211_cqm_rssi_update(rdev, dev, cqm_config);
> + if (err) {
> + rcu_assign_pointer(wdev->cqm_config, old);
> + kfree_rcu(cqm_config, rcu_head);
> + } else {
> + kfree_rcu(old, rcu_head);
But I didn't put that here! So you obviously have UAF when removing a
CQM config.
johannes
next prev parent reply other threads:[~2023-08-16 13:37 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-09 14:11 BCM43455: brcmf_notify_rssi / cfg80211_cqm_rssi_notify : Unable to handle kernel NULL pointer dereference Max Schulze
2023-08-10 8:34 ` BCM43455: brcmf_notify_rssi / cfg80211_cqm_rssi_notify : Unable to handle kernel NULL pointer dereference (RSSI notification after station disconnect?) Max Schulze
2023-08-11 7:30 ` [PATCH] wifi: nl80211: avoid NULL-ptr deref after cfg80211_cqm_rssi_update Max Schulze
2023-08-11 9:54 ` Johannes Berg
2023-08-12 9:35 ` Max Schulze
2023-08-12 9:23 ` BCM43455: brcmf_notify_rssi / cfg80211_cqm_rssi_notify : Unable to handle kernel NULL pointer dereference (RSSI notification after station disconnect?) Max Schulze
2023-08-13 13:18 ` [RFC PATCH] wifi: cfg80211: fix cqm_config access race Johannes Berg
2023-08-15 10:56 ` Max Schulze
2023-08-15 11:02 ` Johannes Berg
2023-08-15 11:42 ` [RFC PATCH v2] " Johannes Berg
2023-08-15 13:24 ` Max Schulze
2023-08-15 13:25 ` Johannes Berg
2023-08-15 13:37 ` [RFC PATCH v2 6.1] " Johannes Berg
2023-08-16 7:23 ` Max Schulze
2023-08-16 7:30 ` Johannes Berg
2023-08-16 11:24 ` Max Schulze
2023-08-16 13:08 ` Max Schulze
2023-08-16 13:17 ` Johannes Berg
2023-08-16 13:33 ` Max Schulze
2023-08-16 13:27 ` Johannes Berg
2023-08-16 13:32 ` [RFC PATCH v3 " Johannes Berg
2023-08-16 13:36 ` Johannes Berg [this message]
2023-08-16 13:38 ` [RFC PATCH v4 " Johannes Berg
2023-09-11 13:16 ` Max Schulze
2023-09-11 16:23 ` Max Schulze
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=7bef5ebb985dacc7d497f2ab6d24a0f3402ce39a.camel@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=max.schulze@online.de \
/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