Skip to contentSkip to conversation

wifi: ath12k: Reserve space for a string terminator

PATCH Applied Jiale Yao 2 participants 3 messages Oct 3 – Oct 5 Qualcomm ATH12K wireless driver

lore
Share & tools
lore

Jiale Yao

author
#0 lore raw

PATCH 1/1 wifi: ath12k: Reserve space for a string terminator

ath12k_write_htt_stats_type() accepts count == size, which fills the zero-initialized buffer without a terminating NUL. sscanf() then reads beyond the buffer.

Reject input that leaves no room for the trailing NUL.

Fixes 8c7a5031a6b0 ("wifi: ath12k: Fix buffer overflow in debugfs")
---
 drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c +1 -1
index b772181a496e..f84f1828275a 100644
@@ -6190,7 +6190,7 @@ static ssize_t ath12k_write_htt_stats_type(struct file *file,
 	const int size = 32;
 	int num_args;
 
-	if (count > size)
+	if (count >= size)
 		return -EINVAL;
 
 	char *buf __free(kfree) = kzalloc(size, GFP_KERNEL);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 11 lines · Jiale Yao

ath12k_write_htt_stats_type() accepts count == size, which fills the zero-initialized buffer without a terminating NUL. sscanf() then reads beyond the buffer.

Reject input that leaves no room for the trailing NUL.

Fixes 8c7a5031a6b0 ("wifi: ath12k: Fix buffer overflow in debugfs")

Documenting that this is actually a REPOST.
The original v1 was part of a 3-patch series:
https://msgid.link/[email protected]

The Reviewed-by tags came from replies to the original posting.

/jeff

Quoted 17 lines
---
 drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c +1 -1
index b772181a496e..f84f1828275a 100644
@@ -6190,7 +6190,7 @@ static ssize_t ath12k_write_htt_stats_type(struct file *file,
 	const int size = 32;
 	int num_args;
 
-	if (count > size)
+	if (count >= size)
 		return -EINVAL;
 
 	char *buf __free(kfree) = kzalloc(size, GFP_KERNEL);
Applied
#2 lore raw
In reply to Jiale Yao
Quoted 8 lines · Jiale Yao

ath12k_write_htt_stats_type() accepts count == size, which fills the zero-initialized buffer without a terminating NUL. sscanf() then reads beyond the buffer.

Reject input that leaves no room for the trailing NUL.

[...]

Applied, thanks!

[1/1] wifi: ath12k: Reserve space for a string terminator

      commit: 13b15eabe2c541b80406166964cdc8ccb5e9c32a

Best regards,

Signature · 1 line
Jeff Johnson <[email protected]>