linux-pine64-pinephonepro: add WiFi CVE backports (MR 3552)
These are the patches added to mitigate the CVE's which have been found in wifi stack. More information on these CVE's can be found over here: https://seclists.org/oss-sec/2022/q4/20 [ci:skip-build]: Already built successfully in CI
This commit is contained in:
parent
5c42cad7a6
commit
a526c9213d
6 changed files with 382 additions and 1 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
pkgname=linux-pine64-pinephonepro
|
||||
pkgver=5.17.9
|
||||
pkgrel=2
|
||||
pkgrel=3
|
||||
pkgdesc="Mainline kernel for the pinephone pro"
|
||||
arch="aarch64"
|
||||
_flavor="${pkgname#linux-}"
|
||||
|
@ -41,6 +41,11 @@ case $pkgver in
|
|||
esac
|
||||
source="
|
||||
https://gitlab.com/pine64-org/linux/-/archive/ppp-$pkgver/linux-ppp-$pkgver.tar.gz
|
||||
CVE-2022-41674.patch
|
||||
CVE-2022-42719.patch
|
||||
CVE-2022-42720.patch
|
||||
CVE-2022-42721.patch
|
||||
CVE-2022-42722.patch
|
||||
config-$_flavor.aarch64
|
||||
"
|
||||
builddir="$srcdir/linux-ppp-$pkgver"
|
||||
|
@ -74,5 +79,10 @@ package() {
|
|||
|
||||
sha512sums="
|
||||
9508e0947a242f83b803e2667247c7a46aa9f602926096f8a98fa90ace297b4be6cd153eb75820c44d8dc2d94d1994560402e93dc2f771ad1719fc4f10c799e2 linux-ppp-5.17.9.tar.gz
|
||||
967ce8182838f62c89dfc9cce2378465c8d4db1c4186f08e0e7ef38f2fc5e9b01a88dd6323028fd88c39c6778b7b662c01b49652f0c116f25c79ff52a34403ea CVE-2022-41674.patch
|
||||
90b2a6ec2d83dd532a25c4c70c03cf6a544ea11533cdf631a3b1e5008edc488850074c27ff49aa9fc16edf3f45a293b85cda38f4ad8832eae38f7b399946d336 CVE-2022-42719.patch
|
||||
0770f0e49a449d1f6ff72f862a2caba15ba4d4d5df33c7e3b24bab51bc292aa02c1cabb9380c11b8c37184ee7574075421465f7423e79aa5304466bc722c83b1 CVE-2022-42720.patch
|
||||
82b168de132d7038e0759b42d095ff78eb3c2bc182498ffbc5e8a71a7095dda8aedb0889dce996854820582028353594c1f11294e8565c3134e9c87279387332 CVE-2022-42721.patch
|
||||
85e00353048b74fd7345a101ad9146ab18b59bf9a3c699de5a753291f0e9946aa5ff871bd0a69aba5f799647c0c34fd20878b6eb7bfd2377232ef29baf0871da CVE-2022-42722.patch
|
||||
687b3b04d1fa479aae3f5f351188364e13ea96cdcbd2785993379c3cb8da19ae74516f7db85847c0845f27f376a73623d1f6e4f964779c186f2f6cde87c58df8 config-pine64-pinephonepro.aarch64
|
||||
"
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
From 42ea11a81ac853c3e870c70d61ab435d0b09b851 Mon Sep 17 00:00:00 2001
|
||||
From: Johannes Berg <johannes.berg@intel.com>
|
||||
Date: Wed, 28 Sep 2022 21:56:15 +0200
|
||||
Subject: wifi: cfg80211: fix u8 overflow in
|
||||
cfg80211_update_notlisted_nontrans()
|
||||
|
||||
commit aebe9f4639b13a1f4e9a6b42cdd2e38c617b442d upstream.
|
||||
|
||||
In the copy code of the elements, we do the following calculation
|
||||
to reach the end of the MBSSID element:
|
||||
|
||||
/* copy the IEs after MBSSID */
|
||||
cpy_len = mbssid[1] + 2;
|
||||
|
||||
This looks fine, however, cpy_len is a u8, the same as mbssid[1],
|
||||
so the addition of two can overflow. In this case the subsequent
|
||||
memcpy() will overflow the allocated buffer, since it copies 256
|
||||
bytes too much due to the way the allocation and memcpy() sizes
|
||||
are calculated.
|
||||
|
||||
Fix this by using size_t for the cpy_len variable.
|
||||
|
||||
This fixes CVE-2022-41674.
|
||||
|
||||
Reported-by: Soenke Huster <shuster@seemoo.tu-darmstadt.de>
|
||||
Tested-by: Soenke Huster <shuster@seemoo.tu-darmstadt.de>
|
||||
Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning")
|
||||
Reviewed-by: Kees Cook <keescook@chromium.org>
|
||||
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
net/wireless/scan.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
|
||||
index 0134e5d5c81a4..f59bfc09ca60f 100644
|
||||
--- a/net/wireless/scan.c
|
||||
+++ b/net/wireless/scan.c
|
||||
@@ -2279,7 +2279,7 @@ cfg80211_update_notlisted_nontrans(struct wiphy *wiphy,
|
||||
size_t new_ie_len;
|
||||
struct cfg80211_bss_ies *new_ies;
|
||||
const struct cfg80211_bss_ies *old;
|
||||
- u8 cpy_len;
|
||||
+ size_t cpy_len;
|
||||
|
||||
lockdep_assert_held(&wiphy_to_rdev(wiphy)->bss_lock);
|
||||
|
||||
--
|
||||
cgit
|
||||
|
109
device/community/linux-pine64-pinephonepro/CVE-2022-42719.patch
Normal file
109
device/community/linux-pine64-pinephonepro/CVE-2022-42719.patch
Normal file
|
@ -0,0 +1,109 @@
|
|||
From e6d77ac0132da7e73fdcc4a38dd4c40ac0226466 Mon Sep 17 00:00:00 2001
|
||||
From: Johannes Berg <johannes.berg@intel.com>
|
||||
Date: Wed, 28 Sep 2022 22:07:15 +0200
|
||||
Subject: wifi: mac80211: fix MBSSID parsing use-after-free
|
||||
|
||||
commit ff05d4b45dd89b922578dac497dcabf57cf771c6 upstream.
|
||||
|
||||
When we parse a multi-BSSID element, we might point some
|
||||
element pointers into the allocated nontransmitted_profile.
|
||||
However, we free this before returning, causing UAF when the
|
||||
relevant pointers in the parsed elements are accessed.
|
||||
|
||||
Fix this by not allocating the scratch buffer separately but
|
||||
as part of the returned structure instead, that way, there
|
||||
are no lifetime issues with it.
|
||||
|
||||
The scratch buffer introduction as part of the returned data
|
||||
here is taken from MLO feature work done by Ilan.
|
||||
|
||||
This fixes CVE-2022-42719.
|
||||
|
||||
Fixes: 5023b14cf4df ("mac80211: support profile split between elements")
|
||||
Co-developed-by: Ilan Peer <ilan.peer@intel.com>
|
||||
Signed-off-by: Ilan Peer <ilan.peer@intel.com>
|
||||
Reviewed-by: Kees Cook <keescook@chromium.org>
|
||||
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
net/mac80211/ieee80211_i.h | 8 ++++++++
|
||||
net/mac80211/util.c | 32 ++++++++++++++++----------------
|
||||
2 files changed, 24 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
|
||||
index 48fbccbf2a545..44c8701af95c0 100644
|
||||
--- a/net/mac80211/ieee80211_i.h
|
||||
+++ b/net/mac80211/ieee80211_i.h
|
||||
@@ -1640,6 +1640,14 @@ struct ieee802_11_elems {
|
||||
|
||||
/* whether a parse error occurred while retrieving these elements */
|
||||
bool parse_error;
|
||||
+
|
||||
+ /*
|
||||
+ * scratch buffer that can be used for various element parsing related
|
||||
+ * tasks, e.g., element de-fragmentation etc.
|
||||
+ */
|
||||
+ size_t scratch_len;
|
||||
+ u8 *scratch_pos;
|
||||
+ u8 scratch[];
|
||||
};
|
||||
|
||||
static inline struct ieee80211_local *hw_to_local(
|
||||
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
|
||||
index 504422cc683e9..8f36ab8fcfb24 100644
|
||||
--- a/net/mac80211/util.c
|
||||
+++ b/net/mac80211/util.c
|
||||
@@ -1503,25 +1503,27 @@ struct ieee802_11_elems *ieee802_11_parse_elems_crc(const u8 *start, size_t len,
|
||||
const struct element *non_inherit = NULL;
|
||||
u8 *nontransmitted_profile;
|
||||
int nontransmitted_profile_len = 0;
|
||||
+ size_t scratch_len = len;
|
||||
|
||||
- elems = kzalloc(sizeof(*elems), GFP_ATOMIC);
|
||||
+ elems = kzalloc(sizeof(*elems) + scratch_len, GFP_ATOMIC);
|
||||
if (!elems)
|
||||
return NULL;
|
||||
elems->ie_start = start;
|
||||
elems->total_len = len;
|
||||
-
|
||||
- nontransmitted_profile = kmalloc(len, GFP_ATOMIC);
|
||||
- if (nontransmitted_profile) {
|
||||
- nontransmitted_profile_len =
|
||||
- ieee802_11_find_bssid_profile(start, len, elems,
|
||||
- transmitter_bssid,
|
||||
- bss_bssid,
|
||||
- nontransmitted_profile);
|
||||
- non_inherit =
|
||||
- cfg80211_find_ext_elem(WLAN_EID_EXT_NON_INHERITANCE,
|
||||
- nontransmitted_profile,
|
||||
- nontransmitted_profile_len);
|
||||
- }
|
||||
+ elems->scratch_len = scratch_len;
|
||||
+ elems->scratch_pos = elems->scratch;
|
||||
+
|
||||
+ nontransmitted_profile = elems->scratch_pos;
|
||||
+ nontransmitted_profile_len =
|
||||
+ ieee802_11_find_bssid_profile(start, len, elems,
|
||||
+ transmitter_bssid,
|
||||
+ bss_bssid,
|
||||
+ nontransmitted_profile);
|
||||
+ elems->scratch_pos += nontransmitted_profile_len;
|
||||
+ elems->scratch_len -= nontransmitted_profile_len;
|
||||
+ non_inherit = cfg80211_find_ext_elem(WLAN_EID_EXT_NON_INHERITANCE,
|
||||
+ nontransmitted_profile,
|
||||
+ nontransmitted_profile_len);
|
||||
|
||||
crc = _ieee802_11_parse_elems_crc(start, len, action, elems, filter,
|
||||
crc, non_inherit);
|
||||
@@ -1550,8 +1552,6 @@ struct ieee802_11_elems *ieee802_11_parse_elems_crc(const u8 *start, size_t len,
|
||||
offsetofend(struct ieee80211_bssid_index, dtim_count))
|
||||
elems->dtim_count = elems->bssid_index->dtim_count;
|
||||
|
||||
- kfree(nontransmitted_profile);
|
||||
-
|
||||
elems->crc = crc;
|
||||
|
||||
return elems;
|
||||
--
|
||||
cgit
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
From 46b23a9559580a72d8cc5811b1bce8db099806d6 Mon Sep 17 00:00:00 2001
|
||||
From: Johannes Berg <johannes.berg@intel.com>
|
||||
Date: Fri, 30 Sep 2022 23:44:23 +0200
|
||||
Subject: wifi: cfg80211: fix BSS refcounting bugs
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
commit 0b7808818cb9df6680f98996b8e9a439fa7bcc2f upstream.
|
||||
|
||||
There are multiple refcounting bugs related to multi-BSSID:
|
||||
- In bss_ref_get(), if the BSS has a hidden_beacon_bss, then
|
||||
the bss pointer is overwritten before checking for the
|
||||
transmitted BSS, which is clearly wrong. Fix this by using
|
||||
the bss_from_pub() macro.
|
||||
|
||||
- In cfg80211_bss_update() we copy the transmitted_bss pointer
|
||||
from tmp into new, but then if we release new, we'll unref
|
||||
it erroneously. We already set the pointer and ref it, but
|
||||
need to NULL it since it was copied from the tmp data.
|
||||
|
||||
- In cfg80211_inform_single_bss_data(), if adding to the non-
|
||||
transmitted list fails, we unlink the BSS and yet still we
|
||||
return it, but this results in returning an entry without
|
||||
a reference. We shouldn't return it anyway if it was broken
|
||||
enough to not get added there.
|
||||
|
||||
This fixes CVE-2022-42720.
|
||||
|
||||
Reported-by: Sönke Huster <shuster@seemoo.tu-darmstadt.de>
|
||||
Tested-by: Sönke Huster <shuster@seemoo.tu-darmstadt.de>
|
||||
Fixes: a3584f56de1c ("cfg80211: Properly track transmitting and non-transmitting BSS")
|
||||
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
net/wireless/scan.c | 27 ++++++++++++++-------------
|
||||
1 file changed, 14 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
|
||||
index fa7d94f505b0b..56a876b155984 100644
|
||||
--- a/net/wireless/scan.c
|
||||
+++ b/net/wireless/scan.c
|
||||
@@ -143,18 +143,12 @@ static inline void bss_ref_get(struct cfg80211_registered_device *rdev,
|
||||
lockdep_assert_held(&rdev->bss_lock);
|
||||
|
||||
bss->refcount++;
|
||||
- if (bss->pub.hidden_beacon_bss) {
|
||||
- bss = container_of(bss->pub.hidden_beacon_bss,
|
||||
- struct cfg80211_internal_bss,
|
||||
- pub);
|
||||
- bss->refcount++;
|
||||
- }
|
||||
- if (bss->pub.transmitted_bss) {
|
||||
- bss = container_of(bss->pub.transmitted_bss,
|
||||
- struct cfg80211_internal_bss,
|
||||
- pub);
|
||||
- bss->refcount++;
|
||||
- }
|
||||
+
|
||||
+ if (bss->pub.hidden_beacon_bss)
|
||||
+ bss_from_pub(bss->pub.hidden_beacon_bss)->refcount++;
|
||||
+
|
||||
+ if (bss->pub.transmitted_bss)
|
||||
+ bss_from_pub(bss->pub.transmitted_bss)->refcount++;
|
||||
}
|
||||
|
||||
static inline void bss_ref_put(struct cfg80211_registered_device *rdev,
|
||||
@@ -1741,6 +1735,8 @@ cfg80211_bss_update(struct cfg80211_registered_device *rdev,
|
||||
new->refcount = 1;
|
||||
INIT_LIST_HEAD(&new->hidden_list);
|
||||
INIT_LIST_HEAD(&new->pub.nontrans_list);
|
||||
+ /* we'll set this later if it was non-NULL */
|
||||
+ new->pub.transmitted_bss = NULL;
|
||||
|
||||
if (rcu_access_pointer(tmp->pub.proberesp_ies)) {
|
||||
hidden = rb_find_bss(rdev, tmp, BSS_CMP_HIDE_ZLEN);
|
||||
@@ -2023,10 +2019,15 @@ cfg80211_inform_single_bss_data(struct wiphy *wiphy,
|
||||
spin_lock_bh(&rdev->bss_lock);
|
||||
if (cfg80211_add_nontrans_list(non_tx_data->tx_bss,
|
||||
&res->pub)) {
|
||||
- if (__cfg80211_unlink_bss(rdev, res))
|
||||
+ if (__cfg80211_unlink_bss(rdev, res)) {
|
||||
rdev->bss_generation++;
|
||||
+ res = NULL;
|
||||
+ }
|
||||
}
|
||||
spin_unlock_bh(&rdev->bss_lock);
|
||||
+
|
||||
+ if (!res)
|
||||
+ return NULL;
|
||||
}
|
||||
|
||||
trace_cfg80211_return_bss(&res->pub);
|
||||
--
|
||||
cgit
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
From 1d73c990e9bafc2754b1ced71345f73f5beb1781 Mon Sep 17 00:00:00 2001
|
||||
From: Johannes Berg <johannes.berg@intel.com>
|
||||
Date: Sat, 1 Oct 2022 00:01:44 +0200
|
||||
Subject: wifi: cfg80211: avoid nontransmitted BSS list corruption
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
commit bcca852027e5878aec911a347407ecc88d6fff7f upstream.
|
||||
|
||||
If a non-transmitted BSS shares enough information (both
|
||||
SSID and BSSID!) with another non-transmitted BSS of a
|
||||
different AP, then we can find and update it, and then
|
||||
try to add it to the non-transmitted BSS list. We do a
|
||||
search for it on the transmitted BSS, but if it's not
|
||||
there (but belongs to another transmitted BSS), the list
|
||||
gets corrupted.
|
||||
|
||||
Since this is an erroneous situation, simply fail the
|
||||
list insertion in this case and free the non-transmitted
|
||||
BSS.
|
||||
|
||||
This fixes CVE-2022-42721.
|
||||
|
||||
Reported-by: Sönke Huster <shuster@seemoo.tu-darmstadt.de>
|
||||
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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
net/wireless/scan.c | 9 +++++++++
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
|
||||
index 56a876b155984..a12c30ad9e5a0 100644
|
||||
--- a/net/wireless/scan.c
|
||||
+++ b/net/wireless/scan.c
|
||||
@@ -423,6 +423,15 @@ cfg80211_add_nontrans_list(struct cfg80211_bss *trans_bss,
|
||||
|
||||
rcu_read_unlock();
|
||||
|
||||
+ /*
|
||||
+ * This is a bit weird - it's not on the list, but already on another
|
||||
+ * one! The only way that could happen is if there's some BSSID/SSID
|
||||
+ * shared by multiple APs in their multi-BSSID profiles, potentially
|
||||
+ * with hidden SSID mixed in ... ignore it.
|
||||
+ */
|
||||
+ if (!list_empty(&nontrans_bss->nontrans_list))
|
||||
+ return -EINVAL;
|
||||
+
|
||||
/* add to the list */
|
||||
list_add_tail(&nontrans_bss->nontrans_list, &trans_bss->nontrans_list);
|
||||
return 0;
|
||||
--
|
||||
cgit
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
From fa63b5f6f8853ace755d9a23fb75817d5ba20df5 Mon Sep 17 00:00:00 2001
|
||||
From: Johannes Berg <johannes.berg@intel.com>
|
||||
Date: Wed, 5 Oct 2022 21:24:10 +0200
|
||||
Subject: wifi: mac80211: fix crash in beacon protection for P2P-device
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
commit b2d03cabe2b2e150ff5a381731ea0355459be09f upstream.
|
||||
|
||||
If beacon protection is active but the beacon cannot be
|
||||
decrypted or is otherwise malformed, we call the cfg80211
|
||||
API to report this to userspace, but that uses a netdev
|
||||
pointer, which isn't present for P2P-Device. Fix this to
|
||||
call it only conditionally to ensure cfg80211 won't crash
|
||||
in the case of P2P-Device.
|
||||
|
||||
This fixes CVE-2022-42722.
|
||||
|
||||
Reported-by: Sönke Huster <shuster@seemoo.tu-darmstadt.de>
|
||||
Fixes: 9eaf183af741 ("mac80211: Report beacon protection failures to user space")
|
||||
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
net/mac80211/rx.c | 12 +++++++-----
|
||||
1 file changed, 7 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
|
||||
index b938806a5184a..2d584a86dbf39 100644
|
||||
--- a/net/mac80211/rx.c
|
||||
+++ b/net/mac80211/rx.c
|
||||
@@ -1988,10 +1988,11 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
|
||||
|
||||
if (mmie_keyidx < NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS ||
|
||||
mmie_keyidx >= NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS +
|
||||
- NUM_DEFAULT_BEACON_KEYS) {
|
||||
- cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev,
|
||||
- skb->data,
|
||||
- skb->len);
|
||||
+ NUM_DEFAULT_BEACON_KEYS) {
|
||||
+ if (rx->sdata->dev)
|
||||
+ cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev,
|
||||
+ skb->data,
|
||||
+ skb->len);
|
||||
return RX_DROP_MONITOR; /* unexpected BIP keyidx */
|
||||
}
|
||||
|
||||
@@ -2139,7 +2140,8 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
|
||||
/* either the frame has been decrypted or will be dropped */
|
||||
status->flag |= RX_FLAG_DECRYPTED;
|
||||
|
||||
- if (unlikely(ieee80211_is_beacon(fc) && result == RX_DROP_UNUSABLE))
|
||||
+ if (unlikely(ieee80211_is_beacon(fc) && result == RX_DROP_UNUSABLE &&
|
||||
+ rx->sdata->dev))
|
||||
cfg80211_rx_unprot_mlme_mgmt(rx->sdata->dev,
|
||||
skb->data, skb->len);
|
||||
|
||||
--
|
||||
cgit
|
||||
|
Loading…
Reference in a new issue