staging: rtl8723bs: fix heap buffer overflow in cfg80211_rtw_add_key
PATCH 1/1 staging: rtl8723bs: fix heap buffer overflow in cfg80211_rtw_add_key
From: Feng Ning <[email protected]>
To: [email protected]
Cc: [email protected], [email protected]
Subject: [PATCH] staging: rtl8723bs: fix heap buffer overflow in cfg80211_rtw_add_key
The cfg80211 framework allows key sequence counters (NL80211_KEY_SEQ) up to 16 bytes, but ieee_param.crypt.seq is a fixed 8-byte buffer. When cfg80211_rtw_add_key() copies the sequence counter via memcpy() without checking seq_len, a heap buffer overflow of up to 8 bytes occurs, overwriting adjacent fields key_len and key[].
Cap the copy length at the buffer size using min_t().
--- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +5 -2
@@ -883,8 +883,11 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, param->u.crypt.idx = key_index; -if (params->seq_len && params->seq) -memcpy (param->u.crypt.seq, (u8 *)params->seq, params->seq_len); +if (params->seq_len && params->seq) { +size_t seq_copy =min_t (size_t, params->seq_len, +sizeof (param->u.crypt.seq)); +memcpy (param->u.crypt.seq, (u8 *)params->seq, seq_copy); + }if (params->key_len && params->key) { param->u.crypt.key_len = params->key_len;
Signature · 1 line
2.43.0
Quoted 27 lines · Feng Ning
From: Feng Ning <[email protected]>
To: [email protected]
Cc: [email protected], [email protected]
Subject: [PATCH] staging: rtl8723bs: fix heap buffer overflow incfg80211_rtw_add_keyThe cfg80211 framework allows key sequence counters (
NL80211_KEY_SEQ) up to 16 bytes, but ieee_param.crypt.seq is a fixed 8-byte buffer. Whencfg80211_rtw_add_key()copies the sequence counter viamemcpy()without checkingseq_len, a heap buffer overflow of up to 8 bytes occurs, overwriting adjacent fieldskey_lenand key[].Cap the copy length at the buffer size using
min_t().Fixes 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver")Signed-off-by Feng Ning <[email protected]>--- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +0
-0@@ -883,8 +883,11 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, param->u.crypt.idx = key_index;
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, · line 893
Quoted 10 lines
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +5
-2-if (params->seq_len && params->seq) -memcpy (param->u.crypt.seq, (u8 *)params->seq, params->seq_len); +if (params->seq_len && params->seq) { +size_t seq_copy =min_t (size_t, params->seq_len, +sizeof (param->u.crypt.seq)); +memcpy (param->u.crypt.seq, (u8 *)params->seq, seq_copy); + }if (params->key_len && params->key) { param->u.crypt.key_len = params->key_len;
Hi Feng,
one quick question, why did you send same patch as before? If it is because it hasn't been merged yet please wait because it is currently merge window and we are not accepting any new patches. We will come to your patch eventually, just be patient.
Best regards,
Luka Gejak
Hi Luka,
Thank you for the clarification. I apologize for the duplicate submission — it was sent in error. I understand that the patch is already in the queue and will wait for the merge window to close before any further action.
Best regards,
Feng Ning