From: Will Deacon <will@kernel.org>
To: linux-wireless@vger.kernel.org
Cc: nico@semmle.com, Will Deacon <will@kernel.org>,
stable@vger.kernel.org, Johannes Berg <johannes@sipsolutions.net>,
Kees Cook <keescook@chromium.org>
Subject: [PATCH 2/2] cfg80211: wext: Reject malformed SSID elements
Date: Fri, 4 Oct 2019 10:51:32 +0100 [thread overview]
Message-ID: <20191004095132.15777-2-will@kernel.org> (raw)
In-Reply-To: <20191004095132.15777-1-will@kernel.org>
Ensure the SSID element is bounds-checked prior to invoking memcpy()
with its length field.
Cc: <stable@vger.kernel.org>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Kees Cook <keescook@chromium.org>
Reported-by: Nicolas Waisman <nico@semmle.com>
Signed-off-by: Will Deacon <will@kernel.org>
---
net/wireless/wext-sme.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/wireless/wext-sme.c b/net/wireless/wext-sme.c
index c67d7a82ab13..3fd2cc7fc36a 100644
--- a/net/wireless/wext-sme.c
+++ b/net/wireless/wext-sme.c
@@ -201,6 +201,7 @@ int cfg80211_mgd_wext_giwessid(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *data, char *ssid)
{
+ int ret = 0;
struct wireless_dev *wdev = dev->ieee80211_ptr;
/* call only for station! */
@@ -219,7 +220,10 @@ int cfg80211_mgd_wext_giwessid(struct net_device *dev,
if (ie) {
data->flags = 1;
data->length = ie[1];
- memcpy(ssid, ie + 2, data->length);
+ if (data->length > IW_ESSID_MAX_SIZE)
+ ret = -EINVAL;
+ else
+ memcpy(ssid, ie + 2, data->length);
}
rcu_read_unlock();
} else if (wdev->wext.connect.ssid && wdev->wext.connect.ssid_len) {
@@ -229,7 +233,7 @@ int cfg80211_mgd_wext_giwessid(struct net_device *dev,
}
wdev_unlock(wdev);
- return 0;
+ return ret;
}
int cfg80211_mgd_wext_siwap(struct net_device *dev,
--
2.23.0.581.g78d2f28ef7-goog
next prev parent reply other threads:[~2019-10-04 9:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-04 9:51 [PATCH 1/2] mac80211: Reject malformed SSID elements Will Deacon
2019-10-04 9:51 ` Will Deacon [this message]
2019-10-04 15:56 ` [PATCH 2/2] cfg80211: wext: " Kees Cook
2019-10-04 15:55 ` [PATCH 1/2] mac80211: " Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191004095132.15777-2-will@kernel.org \
--to=will@kernel.org \
--cc=johannes@sipsolutions.net \
--cc=keescook@chromium.org \
--cc=linux-wireless@vger.kernel.org \
--cc=nico@semmle.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.