fs/tar: Integer overflow leads to heap OOB write
authorLidong Chen <lidong.chen@oracle.com>
Fri, 22 Nov 2024 06:27:58 +0000 (06:27 +0000)
committerFelix Zielcke <fzielcke@z-51.de>
Wed, 11 Jun 2025 15:42:34 +0000 (17:42 +0200)
commit667ae7341e568f6c02c27b4ccd914aeda1319f39
treefb957a9c40395d528678f4c9eaffb1787815867e
parent100412fb9b1994b9052cebadda63cb0ce3b3b82b
fs/tar: Integer overflow leads to heap OOB write

Both namesize and linksize are derived from hd.size, a 12-digit octal
number parsed by read_number(). Later direct arithmetic calculation like
"namesize + 1" and "linksize + 1" may exceed the maximum value of
grub_size_t leading to heap OOB write. This patch fixes the issue by
using grub_add() and checking for an overflow.

Fixes: CVE-2024-45780
Reported-by: Nils Langius <nils@langius.de>
Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Alec Brown <alec.r.brown@oracle.com>
Gbp-Pq: Topic cve-2025-jan
Gbp-Pq: Name fs-tar-Integer-overflow-leads-to-heap-OOB-write.patch
grub-core/fs/tar.c