Commit e163b982 authored by Dan Carpenter's avatar Dan Carpenter Committed by Greg Kroah-Hartman

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: 13a9930d ("staging: ks7010: add driver from Nanonote extra-repository")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/YD4fS8+HmM/Qmrw6@mwandaSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b93c1e39
...@@ -1120,6 +1120,7 @@ static int ks_wlan_set_scan(struct net_device *dev, ...@@ -1120,6 +1120,7 @@ static int ks_wlan_set_scan(struct net_device *dev,
{ {
struct ks_wlan_private *priv = netdev_priv(dev); struct ks_wlan_private *priv = netdev_priv(dev);
struct iw_scan_req *req = NULL; struct iw_scan_req *req = NULL;
int len;
if (priv->sleep_mode == SLP_SLEEP) if (priv->sleep_mode == SLP_SLEEP)
return -EPERM; return -EPERM;
...@@ -1129,8 +1130,9 @@ static int ks_wlan_set_scan(struct net_device *dev, ...@@ -1129,8 +1130,9 @@ static int ks_wlan_set_scan(struct net_device *dev,
if (wrqu->data.length == sizeof(struct iw_scan_req) && if (wrqu->data.length == sizeof(struct iw_scan_req) &&
wrqu->data.flags & IW_SCAN_THIS_ESSID) { wrqu->data.flags & IW_SCAN_THIS_ESSID) {
req = (struct iw_scan_req *)extra; req = (struct iw_scan_req *)extra;
priv->scan_ssid_len = req->essid_len; len = min_t(int, req->essid_len, IW_ESSID_MAX_SIZE);
memcpy(priv->scan_ssid, req->essid, priv->scan_ssid_len); priv->scan_ssid_len = len;
memcpy(priv->scan_ssid, req->essid, len);
} else { } else {
priv->scan_ssid_len = 0; priv->scan_ssid_len = 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment