Skip to content

Commit 8b61d8c

Browse files
Dan CarpenterWim Van Sebroeck
authored andcommitted
watchdog: ziirave_wdt: check record length in ziirave_firm_verify()
The "rec->len" value comes from the firmware. We generally do trust firmware, but it's always better to double check. If the length value is too large it would lead to memory corruption when we set "data[i] = ret;" Fixes: 217209d ("watchdog: ziirave_wdt: Add support to upload the firmware.") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/3b58b453f0faa8b968c90523f52c11908b56c346.1748463049.git.dan.carpenter@linaro.org Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent d7b8f8e commit 8b61d8c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/watchdog/ziirave_wdt.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ static int ziirave_firm_verify(struct watchdog_device *wdd,
302302
const u16 len = be16_to_cpu(rec->len);
303303
const u32 addr = be32_to_cpu(rec->addr);
304304

305+
if (len > sizeof(data))
306+
return -EINVAL;
307+
305308
if (ziirave_firm_addr_readonly(addr))
306309
continue;
307310

0 commit comments

Comments
 (0)