From a889bff2d4a49fbc847a3de82ab65c63a6011b3a Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Wed, 12 Feb 2020 23:33:42 -0500 Subject: [PATCH] fixes for 5.5 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-5.5/series | 4 ++ 5 files changed, 173 insertions(+) create mode 100644 queue-5.5/libertas-don-t-exit-from-lbs_ibss_join_existing-with.patch create mode 100644 queue-5.5/libertas-make-lbs_ibss_join_existing-return-error-co.patch create mode 100644 queue-5.5/mwifiex-fix-possible-buffer-overflows-in-mwifiex_cmd.patch create mode 100644 queue-5.5/mwifiex-fix-possible-buffer-overflows-in-mwifiex_ret.patch diff --git a/queue-5.5/libertas-don-t-exit-from-lbs_ibss_join_existing-with.patch b/queue-5.5/libertas-don-t-exit-from-lbs_ibss_join_existing-with.patch new file mode 100644 index 00000000000..05ef176f1bf --- /dev/null +++ b/queue-5.5/libertas-don-t-exit-from-lbs_ibss_join_existing-with.patch @@ -0,0 +1,40 @@ +From d2b60097087c53f6f117aa0c2aa51247625c7dac 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 c9401c121a14e..68985d7663491 100644 +--- a/drivers/net/wireless/marvell/libertas/cfg.c ++++ b/drivers/net/wireless/marvell/libertas/cfg.c +@@ -1785,6 +1785,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-5.5/libertas-make-lbs_ibss_join_existing-return-error-co.patch b/queue-5.5/libertas-make-lbs_ibss_join_existing-return-error-co.patch new file mode 100644 index 00000000000..e224be051db --- /dev/null +++ b/queue-5.5/libertas-make-lbs_ibss_join_existing-return-error-co.patch @@ -0,0 +1,44 @@ +From f87fc34b0f7a29b3ef2476e2c1b9d79e5bd98664 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 68985d7663491..4e3de684928bf 100644 +--- a/drivers/net/wireless/marvell/libertas/cfg.c ++++ b/drivers/net/wireless/marvell/libertas/cfg.c +@@ -1786,6 +1786,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-5.5/mwifiex-fix-possible-buffer-overflows-in-mwifiex_cmd.patch b/queue-5.5/mwifiex-fix-possible-buffer-overflows-in-mwifiex_cmd.patch new file mode 100644 index 00000000000..b4b3d3bf4a5 --- /dev/null +++ b/queue-5.5/mwifiex-fix-possible-buffer-overflows-in-mwifiex_cmd.patch @@ -0,0 +1,44 @@ +From 69cd66acf0c78fd0a1dd0d23557c91cb8c4bd04d 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 98f942b797f7b..a7968a84aaf88 100644 +--- a/drivers/net/wireless/marvell/mwifiex/scan.c ++++ b/drivers/net/wireless/marvell/mwifiex/scan.c +@@ -2884,6 +2884,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-5.5/mwifiex-fix-possible-buffer-overflows-in-mwifiex_ret.patch b/queue-5.5/mwifiex-fix-possible-buffer-overflows-in-mwifiex_ret.patch new file mode 100644 index 00000000000..34d196ad5a9 --- /dev/null +++ b/queue-5.5/mwifiex-fix-possible-buffer-overflows-in-mwifiex_ret.patch @@ -0,0 +1,41 @@ +From ad86a100bcb668a7f56c52b36e76e43d7056052d 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 41f0231376c01..132f9e8ed68c1 100644 +--- a/drivers/net/wireless/marvell/mwifiex/wmm.c ++++ b/drivers/net/wireless/marvell/mwifiex/wmm.c +@@ -970,6 +970,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-5.5/series b/queue-5.5/series index 8c2c21d8562..30c2f323579 100644 --- a/queue-5.5/series +++ b/queue-5.5/series @@ -115,3 +115,7 @@ regmap-fix-writes-to-non-incrementing-registers.patch mfd-max77650-select-regmap_irq-in-kconfig.patch clk-meson-g12a-fix-missing-uart2-in-regmap-table.patch dmaengine-axi-dmac-add-a-check-for-devm_regmap_init_mmio.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