Skip to contentSkip to conversation

mac80211_hwsim: correctly handle zero length frames

PATCH In review Anirudh Rayabharam 2 participants 3 messages Jun 10, 2021 – Jun 23, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac80211_hwsim: correctly handle zero length frames

syzbot, using KMSAN, has reported an uninit-value access in hwsim_cloned_frame_received_nl(). This is happening because frame_data_len is 0. The code doesn't detect this case and blindly tries to read the frame's header.

Fix this by bailing out in case frame_data_len is 0.

---
 drivers/net/wireless/mac80211_hwsim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mac80211_hwsim.c +1 -1
index 51ce767eaf88..ccfe40313109 100644
@@ -3649,7 +3649,7 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2,
 	if (skb == NULL)
 		goto err;
 
-	if (frame_data_len > IEEE80211_MAX_DATA_LEN)
+	if (frame_data_len == 0 || frame_data_len > IEEE80211_MAX_DATA_LEN)
 		goto err;
 
 	/* Copy the data */
Signature · 6 lines
2.26.2

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
maintainer
#1 lore raw
Quoted 6 lines · Anirudh Rayabharam

syzbot, using KMSAN, has reported an uninit-value access in hwsim_cloned_frame_received_nl(). This is happening because frame_data_len is 0. The code doesn't detect this case and blindly tries to read the frame's header.

Fix this by bailing out in case frame_data_len is 0.

This really seems quite pointless - you should bail out if the frame is too short for what we need to do, not just when it's 0.

johannes

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

#2 lore raw
Quoted 10 lines · Johannes Berg
Quoted 6 lines · Anirudh Rayabharam

syzbot, using KMSAN, has reported an uninit-value access in hwsim_cloned_frame_received_nl(). This is happening because frame_data_len is 0. The code doesn't detect this case and blindly tries to read the frame's header.

Fix this by bailing out in case frame_data_len is 0.

This really seems quite pointless - you should bail out if the frame is too short for what we need to do, not just when it's 0.

That makes sense. Do you happen to know what the min length of a valid frame is? There doesn't seem to be constant defined for that already.

- Anirudh

Quoted 3 lines

johannes