Skip to content

Commit 5f1c703

Browse files
ZhangShuronggregkh
authored andcommitted
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: b121d84 ("staging: ks7010: simplify calls to memcpy()") Cc: stable <[email protected]> Signed-off-by: Zhang Shurong <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4912649 commit 5f1c703

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/staging/ks7010/ks_wlan_net.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,8 +1583,10 @@ static int ks_wlan_set_encode_ext(struct net_device *dev,
15831583
commit |= SME_WEP_FLAG;
15841584
}
15851585
if (enc->key_len) {
1586-
memcpy(&key->key_val[0], &enc->key[0], enc->key_len);
1587-
key->key_len = enc->key_len;
1586+
int key_len = clamp_val(enc->key_len, 0, IW_ENCODING_TOKEN_MAX);
1587+
1588+
memcpy(&key->key_val[0], &enc->key[0], key_len);
1589+
key->key_len = key_len;
15881590
commit |= (SME_WEP_VAL1 << index);
15891591
}
15901592
break;

0 commit comments

Comments
 (0)