[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_5153B668C0283CAA15AA518325346E026A09@qq.com>
Date: Sun, 9 Jul 2023 13:50:07 +0800
From: Zhang Shurong <zhang_shurong@...mail.com>
To: gregkh@...uxfoundation.org
Cc: error27@...il.com, xu.panda@....com.cn,
linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org,
Zhang Shurong <zhang_shurong@...mail.com>
Subject: [PATCH] staging: ks7010: potential buffer overflow in ks_wlan_set_encode_ext()
The "exc->key_len" is a u16 that comes from the user. If it's over
IW_ENCODING_TOKEN_MAX (64) that could lead to memory corruption.
Fixes: b121d84882b9 ("staging: ks7010: simplify calls to memcpy()")
Signed-off-by: Zhang Shurong <zhang_shurong@...mail.com>
---
drivers/staging/ks7010/ks_wlan_net.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index e03c87f0bfe7..0fb97a79ad0b 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1583,8 +1583,10 @@ static int ks_wlan_set_encode_ext(struct net_device *dev,
commit |= SME_WEP_FLAG;
}
if (enc->key_len) {
- memcpy(&key->key_val[0], &enc->key[0], enc->key_len);
- key->key_len = enc->key_len;
+ int key_len = clamp_val(enc->key_len, 0, IW_ENCODING_TOKEN_MAX);
+
+ memcpy(&key->key_val[0], &enc->key[0], key_len);
+ key->key_len = key_len;
commit |= (SME_WEP_VAL1 << index);
}
break;
--
2.30.2
Powered by blists - more mailing lists