summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2022-11-25 12:36:57 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-12-08 11:23:03 +0100
commitf5c2ec288a865dbe3706b09bed12302e9f6d696b (patch)
treef6f0439123f45e6e2e8458a3d8a826fa7acba828
parent06785845e1509f50ecd6ae9295ff0f0d872f1178 (diff)
downloadlinux-stable-f5c2ec288a865dbe3706b09bed12302e9f6d696b.tar.gz
linux-stable-f5c2ec288a865dbe3706b09bed12302e9f6d696b.tar.bz2
linux-stable-f5c2ec288a865dbe3706b09bed12302e9f6d696b.zip
wifi: cfg80211: fix buffer overflow in elem comparison
[ Upstream commit 9f16b5c82a025cd4c864737409234ddc44fb166a ] For vendor elements, the code here assumes that 5 octets are present without checking. Since the element itself is already checked to fit, we only need to check the length. Reported-and-tested-by: Sönke Huster <shuster@seemoo.tu-darmstadt.de> Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning") Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--net/wireless/scan.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 630c64520516..c4c124cb5332 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -291,7 +291,8 @@ static size_t cfg80211_gen_new_ie(const u8 *ie, size_t ielen,
* determine if they are the same ie.
*/
if (tmp_old[0] == WLAN_EID_VENDOR_SPECIFIC) {
- if (!memcmp(tmp_old + 2, tmp + 2, 5)) {
+ if (tmp_old[1] >= 5 && tmp[1] >= 5 &&
+ !memcmp(tmp_old + 2, tmp + 2, 5)) {
/* same vendor ie, copy from
* subelement
*/