]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
mac80211: bail out if cipher schemes are invalid
authorJohannes Berg <johannes.berg@intel.com>
Thu, 8 Apr 2021 12:31:50 +0000 (14:31 +0200)
committerKelsey Skunberg <kelsey.skunberg@canonical.com>
Mon, 24 May 2021 23:46:36 +0000 (17:46 -0600)
BugLink: https://bugs.launchpad.net/bugs/1929455
[ Upstream commit db878e27a98106a70315d264cc92230d84009e72 ]

If any of the cipher schemes specified by the driver are invalid, bail
out and fail the registration rather than just warning.  Otherwise, we
might later crash when we try to use the invalid cipher scheme, e.g.
if the hdr_len is (significantly) less than the pn_offs + pn_len, we'd
have an out-of-bounds access in RX validation.

Fixes: 2475b1cc0d52 ("mac80211: add generic cipher scheme support")
Link: https://lore.kernel.org/r/20210408143149.38a3a13a1b19.I6b7f5790fa0958ed8049cf02ac2a535c61e9bc96@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
net/mac80211/main.c

index d1023188ef373ccf91f1f119899b18756fa2a47f..891d2b6f233e2805fca1baf484f241a24bf14316 100644 (file)
@@ -1138,8 +1138,11 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
        if (local->hw.wiphy->max_scan_ie_len)
                local->hw.wiphy->max_scan_ie_len -= local->scan_ies_len;
 
-       WARN_ON(!ieee80211_cs_list_valid(local->hw.cipher_schemes,
-                                        local->hw.n_cipher_schemes));
+       if (WARN_ON(!ieee80211_cs_list_valid(local->hw.cipher_schemes,
+                                            local->hw.n_cipher_schemes))) {
+               result = -EINVAL;
+               goto fail_workqueue;
+       }
 
        result = ieee80211_init_cipher_suites(local);
        if (result < 0)