From: Greg KH <gregkh@linuxfoundation.org>
To: Siddh Raman Pant <code@siddh.me>
Cc: Johannes Berg <johannes@sipsolutions.net>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev <netdev@vger.kernel.org>,
syzbot+6cb476b7c69916a0caca
<syzbot+6cb476b7c69916a0caca@syzkaller.appspotmail.com>,
linux-wireless <linux-wireless@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
syzbot+f9acff9bf08a845f225d
<syzbot+f9acff9bf08a845f225d@syzkaller.appspotmail.com>,
syzbot+9250865a55539d384347
<syzbot+9250865a55539d384347@syzkaller.appspotmail.com>,
linux-kernel-mentees
<linux-kernel-mentees@lists.linuxfoundation.org>
Subject: Re: [PATCH v2] wifi: cfg80211: Fix UAF in ieee80211_scan_rx()
Date: Fri, 12 Aug 2022 14:15:58 +0200 [thread overview]
Message-ID: <YvZEfnjGIpH6XjsD@kroah.com> (raw)
In-Reply-To: <18291779771.584fa6ab156295.3990923778713440655@siddh.me>
On Fri, Aug 12, 2022 at 03:21:50PM +0530, Siddh Raman Pant via Linux-kernel-mentees wrote:
> On Tue, 26 Jul 2022 18:09:21 +0530 Siddh Raman Pant wrote:
> > ieee80211_scan_rx() tries to access scan_req->flags after a null check
> > (see line 303 of mac80211/scan.c), but ___cfg80211_scan_done() uses
> > kfree() on the scan_req (see line 991 of wireless/scan.c).
> >
> > This results in a UAF.
> >
> > ieee80211_scan_rx() is called inside a RCU read-critical section
> > initiated by ieee80211_rx_napi() (see line 5044 of mac80211/rx.c).
> >
> > Thus, add an rcu_head to the scan_req struct, so that we can use
> > kfree_rcu() instead of kfree() and thus not free during the critical
> > section.
> >
> > We can clear the pointer before freeing here, since scan_req is
> > accessed using rcu_dereference().
> >
> > Bug report (3): https://syzkaller.appspot.com/bug?extid=f9acff9bf08a845f225d
> > Reported-by: syzbot+f9acff9bf08a845f225d@syzkaller.appspotmail.com
> > Reported-by: syzbot+6cb476b7c69916a0caca@syzkaller.appspotmail.com
> > Reported-by: syzbot+9250865a55539d384347@syzkaller.appspotmail.com
> >
> > Signed-off-by: Siddh Raman Pant code@siddh.me>
> > ---
> > Changes since v1 as requested:
> > - Fixed commit heading and better commit message.
> > - Clear pointer before freeing.
> >
> > include/net/cfg80211.h | 2 ++
> > net/wireless/scan.c | 2 +-
> > 2 files changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
> > index 80f41446b1f0..7e0b448c4cdb 100644
> > --- a/include/net/cfg80211.h
> > +++ b/include/net/cfg80211.h
> > @@ -2368,6 +2368,7 @@ struct cfg80211_scan_6ghz_params {
> > * @n_6ghz_params: number of 6 GHz params
> > * @scan_6ghz_params: 6 GHz params
> > * @bssid: BSSID to scan for (most commonly, the wildcard BSSID)
> > + * @rcu_head: (internal) RCU head to use for freeing
> > */
> > struct cfg80211_scan_request {
> > struct cfg80211_ssid *ssids;
> > @@ -2397,6 +2398,7 @@ struct cfg80211_scan_request {
> > bool scan_6ghz;
> > u32 n_6ghz_params;
> > struct cfg80211_scan_6ghz_params *scan_6ghz_params;
> > + struct rcu_head rcu_head;
> >
> > /* keep last */
> > struct ieee80211_channel *channels[];
> > diff --git a/net/wireless/scan.c b/net/wireless/scan.c
> > index 6d82bd9eaf8c..6cf58fe6dea0 100644
> > --- a/net/wireless/scan.c
> > +++ b/net/wireless/scan.c
> > @@ -988,8 +988,8 @@ void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,
> > kfree(rdev->int_scan_req);
> > rdev->int_scan_req = NULL;
> >
> > - kfree(rdev->scan_req);
> > rdev->scan_req = NULL;
> > + kfree_rcu(rdev_req, rcu_head);
> >
> > if (!send_message)
> > rdev->scan_msg = msg;
> > --
> > 2.35.1
> >
>
> Hello,
>
> Probably the above quoted patch was missed, which can be found on
> https://lore.kernel.org/linux-wireless/20220726123921.29664-1-code@siddh.me/
>
> This patch was posted more than 2 weeks ago, with changes as requested.
>
> With the merge window almost ending, may I request for another look at
> this patch?
The merge window is for new features to be added, bugfixes can be merged
at any point in time, but most maintainers close their trees until after
the merge window is closed before accepting new fixes, like this one.
So just relax, wait another week or so, and if there's no response,
resend it then.
Personally, this patch seems very incorrect, but hey, I'm not the wifi
subsystem maintainer :)
thanks,
greg k-h
next prev parent reply other threads:[~2022-08-12 12:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-26 12:39 [PATCH v2] wifi: cfg80211: Fix UAF in ieee80211_scan_rx() Siddh Raman Pant
2022-08-12 9:51 ` Siddh Raman Pant
2022-08-12 12:15 ` Greg KH [this message]
2022-08-12 14:33 ` Siddh Raman Pant
2022-08-12 15:27 ` Greg KH
2022-08-12 16:27 ` Siddh Raman Pant
2022-08-12 19:25 ` Jakub Kicinski
2022-08-13 16:19 ` Siddh Raman Pant
[not found] ` <20220815094722.3c275087@kernel.org>
2022-08-15 19:58 ` Johannes Berg
2022-08-16 8:52 ` Siddh Raman Pant
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=YvZEfnjGIpH6XjsD@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=code@siddh.me \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=johannes@sipsolutions.net \
--cc=kuba@kernel.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=syzbot+6cb476b7c69916a0caca@syzkaller.appspotmail.com \
--cc=syzbot+9250865a55539d384347@syzkaller.appspotmail.com \
--cc=syzbot+f9acff9bf08a845f225d@syzkaller.appspotmail.com \
/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).