Skip to content

Commit 99880fb

Browse files
gokulkumar-ifxUlrich Hecht
authored andcommitted
wifi: brcmfmac: fix crash while sending Action Frames in standalone AP Mode
[ Upstream commit 3776c685ebe5f43e9060af06872661de55e80b9a ] Currently, whenever there is a need to transmit an Action frame, the brcmfmac driver always uses the P2P vif to send the "actframe" IOVAR to firmware. The P2P interfaces were available when wpa_supplicant is managing the wlan interface. However, the P2P interfaces are not created/initialized when only hostapd is managing the wlan interface. And if hostapd receives an ANQP Query REQ Action frame even from an un-associated STA, the brcmfmac driver tries to use an uninitialized P2P vif pointer for sending the IOVAR to firmware. This NULL pointer dereferencing triggers a driver crash. [ 1417.074538] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 [...] [ 1417.075188] Hardware name: Raspberry Pi 4 Model B Rev 1.5 (DT) [...] [ 1417.075653] Call trace: [ 1417.075662] brcmf_p2p_send_action_frame+0x23c/0xc58 [brcmfmac] [ 1417.075738] brcmf_cfg80211_mgmt_tx+0x304/0x5c0 [brcmfmac] [ 1417.075810] cfg80211_mlme_mgmt_tx+0x1b0/0x428 [cfg80211] [ 1417.076067] nl80211_tx_mgmt+0x238/0x388 [cfg80211] [ 1417.076281] genl_family_rcv_msg_doit+0xe0/0x158 [ 1417.076302] genl_rcv_msg+0x220/0x2a0 [ 1417.076317] netlink_rcv_skb+0x68/0x140 [ 1417.076330] genl_rcv+0x40/0x60 [ 1417.076343] netlink_unicast+0x330/0x3b8 [ 1417.076357] netlink_sendmsg+0x19c/0x3f8 [ 1417.076370] __sock_sendmsg+0x64/0xc0 [ 1417.076391] ____sys_sendmsg+0x268/0x2a0 [ 1417.076408] ___sys_sendmsg+0xb8/0x118 [ 1417.076427] __sys_sendmsg+0x90/0xf8 [ 1417.076445] __arm64_sys_sendmsg+0x2c/0x40 [ 1417.076465] invoke_syscall+0x50/0x120 [ 1417.076486] el0_svc_common.constprop.0+0x48/0xf0 [ 1417.076506] do_el0_svc+0x24/0x38 [ 1417.076525] el0_svc+0x30/0x100 [ 1417.076548] el0t_64_sync_handler+0x100/0x130 [ 1417.076569] el0t_64_sync+0x190/0x198 [ 1417.076589] Code: f9401e80 aa1603e2 f9403be1 5280e483 (f9400000) Fix this, by always using the vif corresponding to the wdev on which the Action frame Transmission request was initiated by the userspace. This way, even if P2P vif is not available, the IOVAR is sent to firmware on AP vif and the ANQP Query RESP Action frame is transmitted without crashing the driver. Move init_completion() for "send_af_done" from brcmf_p2p_create_p2pdev() to brcmf_p2p_attach(). Because the former function would not get executed when only hostapd is managing wlan interface, and it is not safe to do reinit_completion() later in brcmf_p2p_tx_action_frame(), without any prior init_completion(). And in the brcmf_p2p_tx_action_frame() function, the condition check for P2P Presence response frame is not needed, since the wpa_supplicant is properly sending the P2P Presense Response frame on the P2P-GO vif instead of the P2P-Device vif. Cc: stable@vger.kernel.org Fixes: 18e2f61 ("brcmfmac: P2P action frame tx") Signed-off-by: Gokul Sivakumar <gokulkumar.sivakumar@infineon.com> Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com> Link: https://patch.msgid.link/20251013102819.9727-1-gokulkumar.sivakumar@infineon.com [Cc stable] Signed-off-by: Johannes Berg <johannes.berg@intel.com> [ removed hunks for P2P presence response check and dwell_overflow logic ] Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> [uli: backport to 4.19] Signed-off-by: Ulrich Hecht <uli@kernel.org> Reviewed-by: Pavel Machek <pavel@nabladev.com>
1 parent c015511 commit 99880fb

3 files changed

Lines changed: 12 additions & 15 deletions

File tree

drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4866,8 +4866,7 @@ brcmf_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
48664866
brcmf_dbg(TRACE, "Action frame, cookie=%lld, len=%d, freq=%d\n",
48674867
*cookie, le16_to_cpu(action_frame->len), freq);
48684868

4869-
ack = brcmf_p2p_send_action_frame(cfg, cfg_to_ndev(cfg),
4870-
af_params);
4869+
ack = brcmf_p2p_send_action_frame(vif->ifp, af_params);
48714870

48724871
cfg80211_mgmt_tx_status(wdev, *cookie, buf, len, ack,
48734872
GFP_KERNEL);

drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,7 @@ int brcmf_p2p_notify_action_tx_complete(struct brcmf_if *ifp,
14801480
/**
14811481
* brcmf_p2p_tx_action_frame() - send action frame over fil.
14821482
*
1483+
* @ifp: interface to transmit on.
14831484
* @p2p: p2p info struct for vif.
14841485
* @af_params: action frame data/info.
14851486
*
@@ -1489,10 +1490,10 @@ int brcmf_p2p_notify_action_tx_complete(struct brcmf_if *ifp,
14891490
* The WLC_E_ACTION_FRAME_COMPLETE event will be received when the action
14901491
* frame is transmitted.
14911492
*/
1492-
static s32 brcmf_p2p_tx_action_frame(struct brcmf_p2p_info *p2p,
1493+
static s32 brcmf_p2p_tx_action_frame(struct brcmf_if *ifp,
1494+
struct brcmf_p2p_info *p2p,
14931495
struct brcmf_fil_af_params_le *af_params)
14941496
{
1495-
struct brcmf_cfg80211_vif *vif;
14961497
s32 err = 0;
14971498
s32 timeout = 0;
14981499

@@ -1502,8 +1503,7 @@ static s32 brcmf_p2p_tx_action_frame(struct brcmf_p2p_info *p2p,
15021503
clear_bit(BRCMF_P2P_STATUS_ACTION_TX_COMPLETED, &p2p->status);
15031504
clear_bit(BRCMF_P2P_STATUS_ACTION_TX_NOACK, &p2p->status);
15041505

1505-
vif = p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif;
1506-
err = brcmf_fil_bsscfg_data_set(vif->ifp, "actframe", af_params,
1506+
err = brcmf_fil_bsscfg_data_set(ifp, "actframe", af_params,
15071507
sizeof(*af_params));
15081508
if (err) {
15091509
brcmf_err(" sending action frame has failed\n");
@@ -1644,16 +1644,14 @@ static s32 brcmf_p2p_pub_af_tx(struct brcmf_cfg80211_info *cfg,
16441644
/**
16451645
* brcmf_p2p_send_action_frame() - send action frame .
16461646
*
1647-
* @cfg: driver private data for cfg80211 interface.
1648-
* @ndev: net device to transmit on.
1647+
* @ifp: interface to transmit on.
16491648
* @af_params: configuration data for action frame.
16501649
*/
1651-
bool brcmf_p2p_send_action_frame(struct brcmf_cfg80211_info *cfg,
1652-
struct net_device *ndev,
1650+
bool brcmf_p2p_send_action_frame(struct brcmf_if *ifp,
16531651
struct brcmf_fil_af_params_le *af_params)
16541652
{
1653+
struct brcmf_cfg80211_info *cfg = ifp->drvr->config;
16551654
struct brcmf_p2p_info *p2p = &cfg->p2p;
1656-
struct brcmf_if *ifp = netdev_priv(ndev);
16571655
struct brcmf_fil_action_frame_le *action_frame;
16581656
struct brcmf_config_af_params config_af_params;
16591657
struct afx_hdl *afx_hdl = &p2p->afx_hdl;
@@ -1779,7 +1777,7 @@ bool brcmf_p2p_send_action_frame(struct brcmf_cfg80211_info *cfg,
17791777
tx_retry = 0;
17801778
while (!p2p->block_gon_req_tx &&
17811779
(ack == false) && (tx_retry < P2P_AF_TX_MAX_RETRY)) {
1782-
ack = !brcmf_p2p_tx_action_frame(p2p, af_params);
1780+
ack = !brcmf_p2p_tx_action_frame(ifp, p2p, af_params);
17831781
tx_retry++;
17841782
}
17851783
if (ack == false) {
@@ -2133,7 +2131,6 @@ static struct wireless_dev *brcmf_p2p_create_p2pdev(struct brcmf_p2p_info *p2p,
21332131

21342132
WARN_ON(p2p_ifp->bsscfgidx != bsscfgidx);
21352133

2136-
init_completion(&p2p->send_af_done);
21372134
INIT_WORK(&p2p->afx_hdl.afx_work, brcmf_p2p_afx_handler);
21382135
init_completion(&p2p->afx_hdl.act_frm_scan);
21392136
init_completion(&p2p->wait_next_af);
@@ -2384,6 +2381,8 @@ s32 brcmf_p2p_attach(struct brcmf_cfg80211_info *cfg, bool p2pdev_forced)
23842381
pri_ifp = brcmf_get_ifp(cfg->pub, 0);
23852382
p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif = pri_ifp->vif;
23862383

2384+
init_completion(&p2p->send_af_done);
2385+
23872386
if (p2pdev_forced) {
23882387
err_ptr = brcmf_p2p_create_p2pdev(p2p, NULL, NULL);
23892388
if (IS_ERR(err_ptr)) {

drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,7 @@ int brcmf_p2p_notify_action_frame_rx(struct brcmf_if *ifp,
176176
int brcmf_p2p_notify_action_tx_complete(struct brcmf_if *ifp,
177177
const struct brcmf_event_msg *e,
178178
void *data);
179-
bool brcmf_p2p_send_action_frame(struct brcmf_cfg80211_info *cfg,
180-
struct net_device *ndev,
179+
bool brcmf_p2p_send_action_frame(struct brcmf_if *ifp,
181180
struct brcmf_fil_af_params_le *af_params);
182181
bool brcmf_p2p_scan_finding_common_channel(struct brcmf_cfg80211_info *cfg,
183182
struct brcmf_bss_info_le *bi);

0 commit comments

Comments
 (0)