Two bounds-check fixes in the rtw89 firmware element parser, both found
while auditing drivers/net/wireless/realtek/rtw89/fw.c.
1/2: __rtw89_fw_recognize_elements() checks only the element body
against firmware->size and ignores the 32-byte element header, so an
element whose body ends one byte before the end of the buffer is read up
to 31 bytes past it; for firmware larger than 2 MB those bytes are also
copied into a persistent devm_ buffer. The same loop's start offset is
unvalidated, and on 32-bit "offset + sizeof(*hdr)" wraps.
2/2: rtw89_board_elm_seek() validates the entry with "ofst + size" in
u32, which wraps, so a crafted board element file can set pseudo_fw->data
far outside the buffer.
Both need a crafted firmware or board element file loaded by the driver,
so these are hardening fixes, not remote attack vectors. No reproducer;
compile- and sparse-tested on x86_64.
---
v4: resend as a new thread at the maintainer's request; no code change
since v3.
v3: resend of the series with the correct subjects and version label; no
code change since v2.
v2: 1/2: validate the walk start offset before dereferencing hdr (fixes
the 32-bit wrap) and use size_t remainder arithmetic; 2/2: new,
split out as an independent caller.
drivers/net/wireless/realtek/rtw89/fw.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)