Skip to contentSkip to conversation

ipw2x00: potential buffer overflow in libipw_wx_set_encodeext()

PATCH In review Dan Carpenter 3 participants 3 messages Apr 14, 2021 – Apr 17, 2021

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

PATCH v2 1/1 ipw2x00: potential buffer overflow in libipw_wx_set_encodeext()

The "ext->key_len" is a u16 that comes from the user. If it's over SCM_KEY_LEN (32) that could lead to memory corruption.

Fixes e0d369d1d969 ("[PATCH] ieee82011: Added WE-18 support to default wireless extension handler")

---
v2: use clamp_val() instead of min_t()

 drivers/net/wireless/intel/ipw2x00/libipw_wx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/ipw2x00/libipw_wx.c +4 -2
index a0cf78c418ac..903de34028ef 100644
@@ -633,8 +633,10 @@ int libipw_wx_set_encodeext(struct libipw_device *ieee,
 	}
 
 	if (ext->alg != IW_ENCODE_ALG_NONE) {
-		memcpy(sec.keys[idx], ext->key, ext->key_len);
-		sec.key_sizes[idx] = ext->key_len;
+		int key_len = clamp_val(ext->key_len, 0, SCM_KEY_LEN);
+
+		memcpy(sec.keys[idx], ext->key, key_len);
+		sec.key_sizes[idx] = key_len;
 		sec.flags |= (1 << idx);
 		if (ext->alg == IW_ENCODE_ALG_WEP) {
 			sec.encode_alg[idx] = SEC_ALG_WEP;
Signature · 1 line
2.30.2
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 4 lines · Dan Carpenter

The "ext->key_len" is a u16 that comes from the user. If it's over SCM_KEY_LEN (32) that could lead to memory corruption.

Quoted 8 lines
Fixes e0d369d1d969 ("[PATCH] ieee82011: Added WE-18 support to default wireless extension handler")

---
v2: use clamp_val() instead of min_t()

 drivers/net/wireless/intel/ipw2x00/libipw_wx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Stanislav.

#2 lore raw
In reply to Dan Carpenter
Quoted 7 lines · Dan Carpenter

The "ext->key_len" is a u16 that comes from the user. If it's over SCM_KEY_LEN (32) that could lead to memory corruption.

Fixes e0d369d1d969 ("[PATCH] ieee82011: Added WE-18 support to default wireless extension handler")

Patch applied to wireless-drivers-next.git, thanks.

260a9ad94467 ipw2x00: potential buffer overflow in libipw_wx_set_encodeext()

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/YHaoA1i+8uT4ir4h@mwanda/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches