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>
Thu, 3 Jul 2025 16:35:51 +0000 (18:35 +0200)
commitde4e52ec1cc757f2a6c75bd0c482faa6c9221f7f
treeb403211572568674bc4b9d97b93e771a2b4e508d
parent290d25741bc8d692a5bd363b5adc9e07187a3fd6
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