mirror of
https://github.com/torvalds/linux.git
synced 2026-09-25 17:42:03 +02:00
wifi: mwifiex: prevent authentication frame length truncation
mwifiex_cfg80211_authenticate() derives the authentication frame length
from req->ie_len and req->auth_data_len, both of type size_t, but stores
it in a u16.
NL80211_ATTR_AUTH_DATA only has a minimum length policy. Since nla_len is
a u16, a single attribute can carry up to 65531 bytes of payload, so the
sum can exceed U16_MAX before it is assigned to pkt_len. The truncated
pkt_len determines the skb frame area, while the copy length remains
req->auth_data_len - 4, resulting in a heap buffer overflow.
For example, with auth_data_len equal to 65510 and no IEs, the sum is
65546. It is truncated to 10 and then reduced by four to 6. The driver
appends only six bytes to the skb with skb_put(), but then copies 65506
user-provided bytes into the authentication body.
Reaching this path requires CAP_NET_ADMIN in the user namespace owning
the network namespace, an up station netdev, and a suitable BSS/SAE
authentication request.
Compute the length in size_t, reject values that cannot be represented by
the firmware's u16 frame length field, and only then assign it to pkt_len.
Fixes: 36995892c2 ("wifi: mwifiex: add host mlme for client mode")
Cc: stable@vger.kernel.org # 6.12+
Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
Link: https://patch.msgid.link/20260820062155.3981976-1-lilinmao@kylinos.cn
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
a3d722190c
commit
fa00193eb9
|
|
@ -4277,6 +4277,7 @@ mwifiex_cfg80211_authenticate(struct wiphy *wiphy,
|
|||
struct mwifiex_adapter *adapter = priv->adapter;
|
||||
struct sk_buff *skb;
|
||||
u16 pkt_len, auth_alg;
|
||||
size_t frame_len;
|
||||
int ret;
|
||||
struct mwifiex_ieee80211_mgmt *mgmt;
|
||||
struct mwifiex_txinfo *tx_info;
|
||||
|
|
@ -4349,10 +4350,17 @@ mwifiex_cfg80211_authenticate(struct wiphy *wiphy,
|
|||
|
||||
mwifiex_cancel_scan(adapter);
|
||||
|
||||
pkt_len = (u16)req->ie_len + req->auth_data_len +
|
||||
frame_len = req->ie_len + req->auth_data_len +
|
||||
MWIFIEX_MGMT_HEADER_LEN + MWIFIEX_AUTH_BODY_LEN;
|
||||
if (req->auth_data_len >= 4)
|
||||
pkt_len -= 4;
|
||||
frame_len -= 4;
|
||||
|
||||
if (frame_len > U16_MAX) {
|
||||
mwifiex_dbg(priv->adapter, ERROR,
|
||||
"auth frame too long: %zu bytes\n", frame_len);
|
||||
return -EINVAL;
|
||||
}
|
||||
pkt_len = frame_len;
|
||||
|
||||
skb = dev_alloc_skb(MWIFIEX_MIN_DATA_HEADER_LEN +
|
||||
MWIFIEX_MGMT_FRAME_HEADER_SIZE +
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user