From 80a0aef60a0e7369f70b045cbe1631c0f52f2a1f Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Wed, 12 Feb 2020 23:33:43 -0500 Subject: [PATCH] fixes for 4.14 Signed-off-by: Sasha Levin --- ...xit-from-lbs_ibss_join_existing-with.patch | 40 +++++++++++++++++ ...s_ibss_join_existing-return-error-co.patch | 44 +++++++++++++++++++ ...ible-buffer-overflows-in-mwifiex_cmd.patch | 44 +++++++++++++++++++ ...ible-buffer-overflows-in-mwifiex_ret.patch | 41 +++++++++++++++++ queue-4.14/series | 4 ++ 5 files changed, 173 insertions(+) create mode 100644 queue-4.14/libertas-don-t-exit-from-lbs_ibss_join_existing-with.patch create mode 100644 queue-4.14/libertas-make-lbs_ibss_join_existing-return-error-co.patch create mode 100644 queue-4.14/mwifiex-fix-possible-buffer-overflows-in-mwifiex_cmd.patch create mode 100644 queue-4.14/mwifiex-fix-possible-buffer-overflows-in-mwifiex_ret.patch diff --git a/queue-4.14/libertas-don-t-exit-from-lbs_ibss_join_existing-with.patch b/queue-4.14/libertas-don-t-exit-from-lbs_ibss_join_existing-with.patch new file mode 100644 index 00000000000..08b978c117b --- /dev/null +++ b/queue-4.14/libertas-don-t-exit-from-lbs_ibss_join_existing-with.patch @@ -0,0 +1,40 @@ +From 155d66355227ab0ecde8dac1026f575c0b1212ab Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 14 Jan 2020 11:39:02 +0100 +Subject: libertas: don't exit from lbs_ibss_join_existing() with RCU read lock + held + +From: Nicolai Stange + +[ Upstream commit c7bf1fb7ddca331780b9a733ae308737b39f1ad4 ] + +Commit e5e884b42639 ("libertas: Fix two buffer overflows at parsing bss +descriptor") introduced a bounds check on the number of supplied rates to +lbs_ibss_join_existing(). + +Unfortunately, it introduced a return path from within a RCU read side +critical section without a corresponding rcu_read_unlock(). Fix this. + +Fixes: e5e884b42639 ("libertas: Fix two buffer overflows at parsing bss descriptor") +Signed-off-by: Nicolai Stange +Signed-off-by: Kalle Valo +Signed-off-by: Sasha Levin +--- + drivers/net/wireless/marvell/libertas/cfg.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/net/wireless/marvell/libertas/cfg.c b/drivers/net/wireless/marvell/libertas/cfg.c +index 4ffc188d2ffd3..a2874f111d122 100644 +--- a/drivers/net/wireless/marvell/libertas/cfg.c ++++ b/drivers/net/wireless/marvell/libertas/cfg.c +@@ -1788,6 +1788,7 @@ static int lbs_ibss_join_existing(struct lbs_private *priv, + rates_max = rates_eid[1]; + if (rates_max > MAX_RATES) { + lbs_deb_join("invalid rates"); ++ rcu_read_unlock(); + goto out; + } + rates = cmd.bss.rates; +-- +2.20.1 + diff --git a/queue-4.14/libertas-make-lbs_ibss_join_existing-return-error-co.patch b/queue-4.14/libertas-make-lbs_ibss_join_existing-return-error-co.patch new file mode 100644 index 00000000000..9d5109ddae5 --- /dev/null +++ b/queue-4.14/libertas-make-lbs_ibss_join_existing-return-error-co.patch @@ -0,0 +1,44 @@ +From 94e1b7e164176a8c16550d8696bb094ef69955f0 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 14 Jan 2020 11:39:03 +0100 +Subject: libertas: make lbs_ibss_join_existing() return error code on rates + overflow + +From: Nicolai Stange + +[ Upstream commit 1754c4f60aaf1e17d886afefee97e94d7f27b4cb ] + +Commit e5e884b42639 ("libertas: Fix two buffer overflows at parsing bss +descriptor") introduced a bounds check on the number of supplied rates to +lbs_ibss_join_existing() and made it to return on overflow. + +However, the aforementioned commit doesn't set the return value accordingly +and thus, lbs_ibss_join_existing() would return with zero even though it +failed. + +Make lbs_ibss_join_existing return -EINVAL in case the bounds check on the +number of supplied rates fails. + +Fixes: e5e884b42639 ("libertas: Fix two buffer overflows at parsing bss descriptor") +Signed-off-by: Nicolai Stange +Signed-off-by: Kalle Valo +Signed-off-by: Sasha Levin +--- + drivers/net/wireless/marvell/libertas/cfg.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/net/wireless/marvell/libertas/cfg.c b/drivers/net/wireless/marvell/libertas/cfg.c +index a2874f111d122..fbeb12018c3d6 100644 +--- a/drivers/net/wireless/marvell/libertas/cfg.c ++++ b/drivers/net/wireless/marvell/libertas/cfg.c +@@ -1789,6 +1789,7 @@ static int lbs_ibss_join_existing(struct lbs_private *priv, + if (rates_max > MAX_RATES) { + lbs_deb_join("invalid rates"); + rcu_read_unlock(); ++ ret = -EINVAL; + goto out; + } + rates = cmd.bss.rates; +-- +2.20.1 + diff --git a/queue-4.14/mwifiex-fix-possible-buffer-overflows-in-mwifiex_cmd.patch b/queue-4.14/mwifiex-fix-possible-buffer-overflows-in-mwifiex_cmd.patch new file mode 100644 index 00000000000..62523bfadf6 --- /dev/null +++ b/queue-4.14/mwifiex-fix-possible-buffer-overflows-in-mwifiex_cmd.patch @@ -0,0 +1,44 @@ +From 51770587d01cd2e774ea53072a091ff3eef1a534 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 2 Jan 2020 10:39:27 +0800 +Subject: mwifiex: Fix possible buffer overflows in + mwifiex_cmd_append_vsie_tlv() + +From: Qing Xu + +[ Upstream commit b70261a288ea4d2f4ac7cd04be08a9f0f2de4f4d ] + +mwifiex_cmd_append_vsie_tlv() calls memcpy() without checking +the destination size may trigger a buffer overflower, +which a local user could use to cause denial of service +or the execution of arbitrary code. +Fix it by putting the length check before calling memcpy(). + +Signed-off-by: Qing Xu +Signed-off-by: Kalle Valo +Signed-off-by: Sasha Levin +--- + drivers/net/wireless/marvell/mwifiex/scan.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c +index c013c94fbf15f..0071c40afe81b 100644 +--- a/drivers/net/wireless/marvell/mwifiex/scan.c ++++ b/drivers/net/wireless/marvell/mwifiex/scan.c +@@ -2890,6 +2890,13 @@ mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv, + vs_param_set->header.len = + cpu_to_le16((((u16) priv->vs_ie[id].ie[1]) + & 0x00FF) + 2); ++ if (le16_to_cpu(vs_param_set->header.len) > ++ MWIFIEX_MAX_VSIE_LEN) { ++ mwifiex_dbg(priv->adapter, ERROR, ++ "Invalid param length!\n"); ++ break; ++ } ++ + memcpy(vs_param_set->ie, priv->vs_ie[id].ie, + le16_to_cpu(vs_param_set->header.len)); + *buffer += le16_to_cpu(vs_param_set->header.len) + +-- +2.20.1 + diff --git a/queue-4.14/mwifiex-fix-possible-buffer-overflows-in-mwifiex_ret.patch b/queue-4.14/mwifiex-fix-possible-buffer-overflows-in-mwifiex_ret.patch new file mode 100644 index 00000000000..f60cb152bcb --- /dev/null +++ b/queue-4.14/mwifiex-fix-possible-buffer-overflows-in-mwifiex_ret.patch @@ -0,0 +1,41 @@ +From 2930cf0a44ae866b91a848b86e95d0f640329b8c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 2 Jan 2020 10:39:26 +0800 +Subject: mwifiex: Fix possible buffer overflows in + mwifiex_ret_wmm_get_status() + +From: Qing Xu + +[ Upstream commit 3a9b153c5591548612c3955c9600a98150c81875 ] + +mwifiex_ret_wmm_get_status() calls memcpy() without checking the +destination size.Since the source is given from remote AP which +contains illegal wmm elements , this may trigger a heap buffer +overflow. +Fix it by putting the length check before calling memcpy(). + +Signed-off-by: Qing Xu +Signed-off-by: Kalle Valo +Signed-off-by: Sasha Levin +--- + drivers/net/wireless/marvell/mwifiex/wmm.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/drivers/net/wireless/marvell/mwifiex/wmm.c b/drivers/net/wireless/marvell/mwifiex/wmm.c +index 7fba4d940131c..a13b05ec8fc03 100644 +--- a/drivers/net/wireless/marvell/mwifiex/wmm.c ++++ b/drivers/net/wireless/marvell/mwifiex/wmm.c +@@ -976,6 +976,10 @@ int mwifiex_ret_wmm_get_status(struct mwifiex_private *priv, + "WMM Parameter Set Count: %d\n", + wmm_param_ie->qos_info_bitmap & mask); + ++ if (wmm_param_ie->vend_hdr.len + 2 > ++ sizeof(struct ieee_types_wmm_parameter)) ++ break; ++ + memcpy((u8 *) &priv->curr_bss_params.bss_descriptor. + wmm_ie, wmm_param_ie, + wmm_param_ie->vend_hdr.len + 2); +-- +2.20.1 + diff --git a/queue-4.14/series b/queue-4.14/series index 6846d7cdad3..8eb4c681807 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -165,3 +165,7 @@ crypto-artpec6-return-correct-error-code-for-failed-setkey.patch crypto-atmel-sha-fix-error-handling-when-setting-hmac-key.patch media-i2c-adv748x-fix-unsafe-macros.patch pinctrl-sh-pfc-r8a7778-fix-duplicate-sdself_b-and-sd1_clk_b.patch +mwifiex-fix-possible-buffer-overflows-in-mwifiex_ret.patch +mwifiex-fix-possible-buffer-overflows-in-mwifiex_cmd.patch +libertas-don-t-exit-from-lbs_ibss_join_existing-with.patch +libertas-make-lbs_ibss_join_existing-return-error-co.patch -- 2.47.3