Skip to contentSkip to conversation

wifi: ath9k: don't allow to overwrite ENDPOINT0 attributes

PATCH Superseded Fedor Pchelkin 3 participants 5 messages May 13, 2023 – May 25, 2023

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

PATCH 1/1 wifi: ath9k: don't allow to overwrite ENDPOINT0 attributes

A bad USB device is able to construct a service connection response message with target endpoint being ENDPOINT0 which is reserved for HTC_CTRL_RSVD_SVC and should not be modified to be used for any other services.

Reject such service connection responses.

Found by Linux Verification Center (linuxtesting.org) with Syzkaller.

Fixes fb9987d0f748 ("ath9k_htc: Support for AR9271 chipset.")
Reported-by [email protected]
---
 drivers/net/wireless/ath/ath9k/htc_hst.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/htc_hst.c +1 -1
index fe62ff668f75..a15d8d80df87 100644
@@ -114,7 +114,7 @@ static void htc_process_conn_rsp(struct htc_target *target,
 
 	if (svc_rspmsg->status == HTC_SERVICE_SUCCESS) {
 		epid = svc_rspmsg->endpoint_id;
-		if (epid < 0 || epid >= ENDPOINT_MAX)
+		if (epid <= 0 || epid >= ENDPOINT_MAX)
 			return;
 
 		service_id = be16_to_cpu(svc_rspmsg->service_id);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 21 lines · Fedor Pchelkin

A bad USB device is able to construct a service connection response message with target endpoint being ENDPOINT0 which is reserved for HTC_CTRL_RSVD_SVC and should not be modified to be used for any other services.

Reject such service connection responses.

Found by Linux Verification Center (linuxtesting.org) with Syzkaller.

Fixes fb9987d0f748 ("ath9k_htc: Support for AR9271 chipset.")
Reported-by [email protected]
---
 drivers/net/wireless/ath/ath9k/htc_hst.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/htc_hst.c +0 -0
index fe62ff668f75..a15d8d80df87 100644

drivers/net/wireless/ath/ath9k/htc_hst.c static void htc_process_conn_rsp(struct htc_target *target, · line 118

Quoted 6 lines
drivers/net/wireless/ath/ath9k/htc_hst.c +1 -1
@@ -114,7 +114,7 @@ static void htc_process_conn_rsp(struct htc_target *target,
 
 	if (svc_rspmsg->status == HTC_SERVICE_SUCCESS) {
 		epid = svc_rspmsg->endpoint_id;
-		if (epid < 0 || epid >= ENDPOINT_MAX)
+		if (epid <= 0 || epid >= ENDPOINT_MAX)
 			return;

Hmm, I think we should use the ENDPOINT0 constant here, then, and maybe add a comment above explaining that it's reserved?

-Toke

#2 lore raw

PATCH v2 1/1 wifi: ath9k: don't allow to overwrite ENDPOINT0 attributes

A bad USB device is able to construct a service connection response message with target endpoint being ENDPOINT0 which is reserved for HTC_CTRL_RSVD_SVC and should not be modified to be used for any other services.

Reject such service connection responses.

Found by Linux Verification Center (linuxtesting.org) with Syzkaller.

Fixes fb9987d0f748 ("ath9k_htc: Support for AR9271 chipset.")
Reported-by [email protected]

---
v2: per Toke's remark, use ENDPOINT0 macro and give a comment explaining why it should be checked.

 drivers/net/wireless/ath/ath9k/htc_hst.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/htc_hst.c +7 -1
index fe62ff668f75..99667aba289d 100644
@@ -114,7 +114,13 @@ static void htc_process_conn_rsp(struct htc_target *target,
 
 	if (svc_rspmsg->status == HTC_SERVICE_SUCCESS) {
 		epid = svc_rspmsg->endpoint_id;
-		if (epid < 0 || epid >= ENDPOINT_MAX)
+
+		/* Check that the received epid for the endpoint to attach
+		 * a new service is valid. ENDPOINT0 can't be used here as it
+		 * is already reserved for HTC_CTRL_RSVD_SVC service and thus
+		 * should not be modified.
+		 */
+		if (epid <= ENDPOINT0 || epid >= ENDPOINT_MAX)
 			return;
 
 		service_id = be16_to_cpu(svc_rspmsg->service_id);
Signature · 1 line
2.34.1
maintainer Acked-by on v2 1/1
#3 lore raw
Quoted 5 lines · Fedor Pchelkin

A bad USB device is able to construct a service connection response message with target endpoint being ENDPOINT0 which is reserved for HTC_CTRL_RSVD_SVC and should not be modified to be used for any other services.

Quoted 7 lines

Reject such service connection responses.

Found by Linux Verification Center (linuxtesting.org) with Syzkaller.

Fixes fb9987d0f748 ("ath9k_htc: Support for AR9271 chipset.")
Reported-by [email protected]
#4 lore raw
In reply to Fedor Pchelkin
Quoted 7 lines · Fedor Pchelkin

A bad USB device is able to construct a service connection response message with target endpoint being ENDPOINT0 which is reserved for HTC_CTRL_RSVD_SVC and should not be modified to be used for any other services.

Reject such service connection responses.

Quoted 7 lines

Found by Linux Verification Center (linuxtesting.org) with Syzkaller.

Fixes fb9987d0f748 ("ath9k_htc: Support for AR9271 chipset.")
Reported-by [email protected]

Patch applied to ath-next branch of ath.git, thanks.

061b0cb9327b wifi: ath9k: don't allow to overwrite ENDPOINT0 attributes

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

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