9e1f78136794c7bb53f72f847574373b3e4b3154
[openwrt/staging/hauke.git] /
1 From: Johannes Berg <johannes.berg@intel.com>
2 Date: Wed, 28 Sep 2022 21:56:15 +0200
3 Subject: [PATCH] wifi: cfg80211: fix u8 overflow in
4 cfg80211_update_notlisted_nontrans()
5
6 commit aebe9f4639b13a1f4e9a6b42cdd2e38c617b442d upstream.
7
8 In the copy code of the elements, we do the following calculation
9 to reach the end of the MBSSID element:
10
11 /* copy the IEs after MBSSID */
12 cpy_len = mbssid[1] + 2;
13
14 This looks fine, however, cpy_len is a u8, the same as mbssid[1],
15 so the addition of two can overflow. In this case the subsequent
16 memcpy() will overflow the allocated buffer, since it copies 256
17 bytes too much due to the way the allocation and memcpy() sizes
18 are calculated.
19
20 Fix this by using size_t for the cpy_len variable.
21
22 This fixes CVE-2022-41674.
23
24 Reported-by: Soenke Huster <shuster@seemoo.tu-darmstadt.de>
25 Tested-by: Soenke Huster <shuster@seemoo.tu-darmstadt.de>
26 Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning")
27 Reviewed-by: Kees Cook <keescook@chromium.org>
28 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
29 ---
30
31 --- a/net/wireless/scan.c
32 +++ b/net/wireless/scan.c
33 @@ -2238,7 +2238,7 @@ cfg80211_update_notlisted_nontrans(struc
34 size_t new_ie_len;
35 struct cfg80211_bss_ies *new_ies;
36 const struct cfg80211_bss_ies *old;
37 - u8 cpy_len;
38 + size_t cpy_len;
39
40 lockdep_assert_held(&wiphy_to_rdev(wiphy)->bss_lock);
41