mt7925e: fix buffer overflow in mt76_connac2_load_patch() - #1024
l33tm4st3r wants to merge 1 commit into
Conversation
Signed-off-by: l33tm4st3r <fransm@gmail.com>
06fa38e to
a787afa
Compare
|
This PR is ready for review. It fixes a critical buffer overflow in mt76_connac2_load_patch() affecting MT7925 on kernel 6.19.0-rc1. The fix is a single line change consistent with similar code patterns in the same file. Please review when available. |
Thanks for pointing this out. I see there's already a more comprehensive fix in the kernel mailing list by Bert Karwatzki. That approach using strscpy() and strim() is more robust. We can wait for that to be merged in the kernel first, or I can update this PR to match that solution. |
|
PRs in this repo are not merged. |
|
Thanks for the guidance. I wasn't aware that patches for this project go through the Linux wireless mailing list rather than GitHub PRs. I'll close this PR and submit the patch to linux-wireless@vger.kernel.org using the proper mailing list process. Appreciate the clarification! |
|
you could also comment under the existing mail threads instead. |
Fix strnlen buffer overflow in
mt76_connac2_load_patch()function when loading firmware for MediaTek MT7925 WiFi chipset on kernel 6.19.0-rc1.The issue occurs at line 3128 where
dev_info()uses format specifier%.16son a 16-byte buffer (mt76_connac2_patch_hdr.build_date[16]). Without a guaranteed null-terminator within the buffer bounds, the fortifiedstrnlenfunction detects a read beyond buffer boundaries.Error Message
Root Cause
The format specifier
%.16sspecifies the maximum number of characters to read as 16, but the bufferbuild_date[16]only has 16 bytes total. If the string is not null-terminated within those 16 bytes,strnlenwill attempt to read byte 17, causing buffer overflow detection on kernels with_FORTIFY_SOURCEenabled.Solution
Change the format specifier from
%.16sto%.15s. This ensures we never read beyond the 16-byte buffer bounds.This approach is consistent with the similar structure
mt76_connac2_fw_trailerwhich has a 15-bytebuild_datefield and uses%.15sformat specifier in themt76_connac2_load_ram()function (line 3051).Testing
Files Changed
mt76_connac_mcu.c: Line 3127, format specifier%.16s→%.15s