]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
watchdog: ziirave_wdt: check record length in ziirave_firm_verify()
authorDan Carpenter <dan.carpenter@linaro.org>
Wed, 28 May 2025 20:22:19 +0000 (23:22 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:22:34 +0000 (16:22 +0200)
[ Upstream commit 8b61d8ca751bc15875b50e0ff6ac3ba0cf95a529 ]

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: 217209db0204 ("watchdog: ziirave_wdt: Add support to upload the firmware.")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/3b58b453f0faa8b968c90523f52c11908b56c346.1748463049.git.dan.carpenter@linaro.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/watchdog/ziirave_wdt.c

index cab86a08456bcd3c13bb3e2663ae2facd2221d85..3cfab859e5074d43c585bb6d143cafb78df3c656 100644 (file)
@@ -306,6 +306,9 @@ static int ziirave_firm_verify(struct watchdog_device *wdd,
                const u16 len = be16_to_cpu(rec->len);
                const u32 addr = be32_to_cpu(rec->addr);
 
+               if (len > sizeof(data))
+                       return -EINVAL;
+
                if (ziirave_firm_addr_readonly(addr))
                        continue;