]> www.infradead.org Git - users/jedix/linux-maple.git/commit
wifi: rtw89: fw: validate multi-firmware header before getting its size
authorPing-Ke Shih <pkshih@realtek.com>
Mon, 3 Feb 2025 07:29:11 +0000 (15:29 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Mon, 10 Feb 2025 03:02:03 +0000 (11:02 +0800)
commit2b8bdc5237014cc61784b3676cbaca5325959f3d
tree940d9b136b150034854b8cd5581ea791031f39ac
parent1f0efffd597893404aea5c3d4f1bdaa1c61d4434
wifi: rtw89: fw: validate multi-firmware header before getting its size

To access firmware elements appended after multi-firmware, add its size
as offset to get start address of firmware elements.

         +-----+-------+------+---------+--------------+ --
         | sig | fw_nr | rsvd | version | reserved     |   \
         +---------------------------------------------+   |
 fw 0    | cv | type | mp | rsvd | shift | size | rsvd |   |
         +---------------------------------------------+   |
 fw 1    | cv | type | mp | rsvd | shift | size | rsvd |   |
         +---------------------------------------------+   |
 fw N-1  |                  ...                        |   |
         +=============================================+   | mfw size
         |               fw 0 content                  |   |
         +=============================================+   |
         |               fw 1 content                  |   |
         +=============================================+   |
         |                  ...                        |   |
         +=============================================+   |
         |               fw N -1 content               |   |
         +=============================================+ --/
         |             fw element TLV X                |
         +=============================================+
         |             fw element TLV Y                |
         +=============================================+
         |             fw element TLV Z                |
         +=============================================+

To avoid Coverity warning when getting mfw size, validate it header ahead.

Addresses-Coverity-ID: 1544385 ("Untrusted array index read")

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250203072911.47313-5-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/fw.c