wifi: ath12k: Reserve space for a string terminator
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.
--- 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
@@ -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
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")Reviewed-by Dan Carpenter <[email protected]>Reviewed-by Rameshkumar Sundaram <[email protected]>Reviewed-by Baochen Qiang <[email protected]>Signed-off-by Jiale Yao <[email protected]>
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@@ -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);
Jeff Johnson
AppliedQuoted 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]>