Skip to content

Commit e163b98

Browse files
Dan Carpentergregkh
authored andcommitted
staging: ks7010: prevent buffer overflow in ks_wlan_set_scan()
The user can specify a "req->essid_len" of up to 255 but if it's over IW_ESSID_MAX_SIZE (32) that can lead to memory corruption. Fixes: 13a9930 ("staging: ks7010: add driver from Nanonote extra-repository") Signed-off-by: Dan Carpenter <[email protected]> Cc: stable <[email protected]> Link: https://lore.kernel.org/r/YD4fS8+HmM/Qmrw6@mwanda Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b93c1e3 commit e163b98

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
@@ -1120,6 +1120,7 @@ static int ks_wlan_set_scan(struct net_device *dev,
11201120
{
11211121
struct ks_wlan_private *priv = netdev_priv(dev);
11221122
struct iw_scan_req *req = NULL;
1123+
int len;
11231124

11241125
if (priv->sleep_mode == SLP_SLEEP)
11251126
return -EPERM;
@@ -1129,8 +1130,9 @@ static int ks_wlan_set_scan(struct net_device *dev,
11291130
if (wrqu->data.length == sizeof(struct iw_scan_req) &&
11301131
wrqu->data.flags & IW_SCAN_THIS_ESSID) {
11311132
req = (struct iw_scan_req *)extra;
1132-
priv->scan_ssid_len = req->essid_len;
1133-
memcpy(priv->scan_ssid, req->essid, priv->scan_ssid_len);
1133+
len = min_t(int, req->essid_len, IW_ESSID_MAX_SIZE);
1134+
priv->scan_ssid_len = len;
1135+
memcpy(priv->scan_ssid, req->essid, len);
11341136
} else {
11351137
priv->scan_ssid_len = 0;
11361138
}

0 commit comments

Comments
 (0)