Skip to contentSkip to conversation

mwifiex: pcie: tighten a check in mwifiex_pcie_process_event_ready()

PATCH In review Dan Carpenter 2 participants 2 messages Apr 5, 2018 – Apr 25, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mwifiex: pcie: tighten a check in mwifiex_pcie_process_event_ready()

If "evt_len" is 1 then we try to memcpy() negative 3 bytes and it would cause memory corruption.

Fixes d930faee141b ("mwifiex: add support for Marvell pcie8766 chipset")
drivers/net/wireless/marvell/mwifiex/pcie.c +2 -1
index 97a6199692ab..7538543d46fa 100644
@@ -1881,7 +1881,8 @@ static int mwifiex_pcie_process_event_ready(struct mwifiex_adapter *adapter)
 		mwifiex_dbg(adapter, EVENT,
 			    "info: Event length: %d\n", evt_len);
 
-		if ((evt_len > 0) && (evt_len  < MAX_EVENT_SIZE))
+		if (evt_len > MWIFIEX_EVENT_HEADER_LEN &&
+		    evt_len < MAX_EVENT_SIZE)
 			memcpy(adapter->event_body, skb_cmd->data +
 			       MWIFIEX_EVENT_HEADER_LEN, evt_len -
 			       MWIFIEX_EVENT_HEADER_LEN);
#1 lore raw
Quoted 11 lines · Dan Carpenter

If "evt_len" is 1 then we try to memcpy() negative 3 bytes and it would cause memory corruption.

Fixes d930faee141b ("mwifiex: add support for Marvell pcie8766 chipset")
drivers/net/wireless/marvell/mwifiex/pcie.c +0 -0
index 97a6199692ab..7538543d46fa 100644

drivers/net/wireless/marvell/mwifiex/pcie.c static int mwifiex_pcie_process_event_ready(struct mwifiex_adapter *adapter) · line 1888

Quoted 9 lines
drivers/net/wireless/marvell/mwifiex/pcie.c +2 -1
@@ -1881,7 +1881,8 @@ static int mwifiex_pcie_process_event_ready(struct mwifiex_adapter *adapter)
 		mwifiex_dbg(adapter, EVENT,
 			    "info: Event length: %d\n", evt_len);
 
-		if ((evt_len > 0) && (evt_len  < MAX_EVENT_SIZE))
+		if (evt_len > MWIFIEX_EVENT_HEADER_LEN &&
+		    evt_len < MAX_EVENT_SIZE)
 			memcpy(adapter->event_body, skb_cmd->data +
 			       MWIFIEX_EVENT_HEADER_LEN, evt_len -
 			       MWIFIEX_EVENT_HEADER_LEN);

Patch applied to wireless-drivers-next.git, thanks.

01eca2842874 mwifiex: pcie: tighten a check in mwifiex_pcie_process_event_ready()

Signature · 3 lines
https://patchwork.kernel.org/patch/10324435/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches