From: Arend van Spriel <arend.vanspriel@broadcom.com>
To: Gokul Sivakumar <gokulkumar.sivakumar@infineon.com>,
Richard Reigh <richard@govivid.ai>
Cc: linux-wireless@vger.kernel.org, wahrenst@gmx.net,
brcm80211-dev-list.pdl@broadcom.com, brcm80211@lists.linux.dev,
chris@streetlogic.pro, s311332@gmail.com,
wlan-kernel-dev-list@infineon.com
Subject: Re: [PATCH v2] brcmfmac: Fix NULL pointer dereference in P2P action frame handling
Date: Wed, 8 Oct 2025 20:45:15 +0200 [thread overview]
Message-ID: <9a0849d8-befd-4fca-9d5d-a24520ccfa26@broadcom.com> (raw)
In-Reply-To: <aOUyLfSuIkby_8TZ@ISCN5CG14747PP.infineon.com>
On 10/7/2025 5:30 PM, Gokul Sivakumar wrote:
> On 10/06, Richard Reigh wrote:
>> When iPhones query network information via the WiFi settings "i" button,
>> the brcmfmac driver crashes with a NULL pointer dereference. This occurs
>> because the P2P device vif is not initialized when handling certain action
>> frames.
>>
>> Added an early check in brcmf_cfg80211_mgmt_tx() to verify P2P device vif
>> availability before attepting to send action frames. Also added a defensive
>> check in brcmf_p2p_tx_action_frame() as a safety net.
>>
>> Tested on Raspberry Pi Zero 2 W with kernel 6.1.21-v8+
>>
>> Fixes: 18e2f61db3b7 ("brcmfmac: P2P action frame tx")
>> Signed-off-by: Richard Reigh <richard@govivid.ai>
>>
>> ---
>> Changes in v2:
>> - Added early check in cfg80211.c before calling P2P functions (suggested by
>> Stefan Wahren)
>> - Changed error message to debug level in p2p.c (suggested by Stefan Wahren)
>> - Added fixes tag
>> ---
>> .../wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 13 +++++++++++++
>> .../net/wireless/broadcom/brcm80211/brcmfmac/p2p.c | 6 ++++++
>> 2 files changed, 19 insertions(+)
>>
>> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
>> index ea8409e0e..9983136a7 100644
>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
>> @@ -5137,6 +5137,19 @@ brcmf_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
>>
>> vif = container_of(wdev, struct brcmf_cfg80211_vif, wdev);
>>
>> + /* check if P2P device vif is available before attempting */
>> + /* action frames */
>> + if (ieee80211_is_action(mgmt->frame_control)) {
>
> The action frame type specific operations are done already below in the
> else if (ieee80211_is_action()) block. So ideally, it is better to do
> all action frame type specific operations in the existing else if{} block,
> instead of introducing a new if{} block, until unless it is really needed.
>
>> + struct brcmf_p2p_info *p2p = &cfg->p2p;
>> +
>> + if (!p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif) {
>> + brcmf_dbg(TRACE, "P2P device vif not available\n");
>> + cfg80211_mgmt_tx_status(wdev, *cookie, buf, len, false,
>> + GFP_KERNEL);
>> + return 0;
>> + }
>> + }
>> +
>
> IMHO, bailing out here without responding to the ANQP Request, may not be
> a viable solution for the crash. Need to have a way for the AP to respond
> with the ANQP Response Public Action frame without crashing the driver.
Carying the historical burden. The action frame transmission support in
brcmfmac was originally introduced with only P2P in mind. So it ended up
very entwined with the P2P code. In my opinion the action frame handling
should be implemented in a separate source file in the driver.
> Have a solution in mind, will send the patch for review after testing it.
Okay. Go ahead.
Gr. AvS
>> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>> index 10d9d9c63..e62135cd4 100644
>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>> @@ -1559,6 +1559,12 @@ static s32 brcmf_p2p_tx_action_frame(struct brcmf_p2p_info *p2p,
>> else
>> vif = p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif;
>>
>> + /* add NULL check */
>> + if (!vif) {
>> + brcmf_dbg(TRACE, "vif is NULL, cannot send action frame\n");
>> + return -ENODEV;
>> + }
>> +
>> err = brcmf_fil_bsscfg_data_set(vif->ifp, "actframe", af_params,
>> sizeof(*af_params));
>> if (err) {
>> --
>> 2.34.1
>>
>>
next prev parent reply other threads:[~2025-10-08 18:45 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAE3HL_yv8t1Rkd+jLfQMkc3YrNONQp0pRFESV+v92ECf_+7Xjw@mail.gmail.com>
2025-09-24 2:59 ` brcmfmac: driver crash with iOS 18.6.1, potential DoS Hsien Chou
2025-09-25 18:31 ` Arend van Spriel
2025-09-26 1:36 ` Hsien Chou
2025-09-26 12:01 ` Pablo MARTIN-GOMEZ
2025-09-28 18:31 ` Arend van Spriel
2025-09-29 17:06 ` Stefan Wahren
2025-09-29 17:24 ` Chris Spargo
2025-09-29 18:23 ` Arend van Spriel
2025-10-02 23:20 ` [PATCH] brcmfmac: Fix NULL pointer dereference in P2P action frame handling Richard Reigh
2025-10-03 16:00 ` Arend van Spriel
2025-10-03 17:02 ` Stefan Wahren
2025-10-04 9:22 ` Arend van Spriel
2025-10-06 15:47 ` Stefan Wahren
2025-10-06 17:08 ` Richard Reigh
2025-10-06 17:28 ` Stefan Wahren
2025-10-06 18:37 ` Richard Reigh
2025-10-08 18:47 ` Arend van Spriel
2025-10-08 20:21 ` Richard Reigh
2025-10-06 19:41 ` Stefan Wahren
2025-10-06 23:13 ` [PATCH v2] " Richard Reigh
2025-10-07 15:30 ` Gokul Sivakumar
2025-10-08 18:45 ` Arend van Spriel [this message]
2025-10-09 7:39 ` [PATCH wireless-next] wifi: brcmfmac: fix crash while sending Action Frames in standalone AP Mode Gokul Sivakumar
2025-10-10 18:35 ` Richard Reigh
2025-10-12 6:15 ` Arend van Spriel
2025-10-12 6:07 ` Arend van Spriel
2025-10-13 7:28 ` Gokul Sivakumar
2025-10-13 9:26 ` Arend van Spriel
2025-10-13 10:28 ` [PATCH wireless v2] " Gokul Sivakumar
2025-10-13 11:33 ` Arend van Spriel
2025-10-12 6:14 ` [PATCH wireless-next] " Arend van Spriel
2025-10-12 6:12 ` [PATCH v2] brcmfmac: Fix NULL pointer dereference in P2P action frame handling Arend van Spriel
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=9a0849d8-befd-4fca-9d5d-a24520ccfa26@broadcom.com \
--to=arend.vanspriel@broadcom.com \
--cc=brcm80211-dev-list.pdl@broadcom.com \
--cc=brcm80211@lists.linux.dev \
--cc=chris@streetlogic.pro \
--cc=gokulkumar.sivakumar@infineon.com \
--cc=linux-wireless@vger.kernel.org \
--cc=richard@govivid.ai \
--cc=s311332@gmail.com \
--cc=wahrenst@gmx.net \
--cc=wlan-kernel-dev-list@infineon.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).