squashfs: Fix integer overflow in sqfs_resolve_symlink()
authorRichard Weinberger <richard@nod.at>
Fri, 2 Aug 2024 16:36:44 +0000 (18:36 +0200)
committerDaniel Leidert <dleidert@debian.org>
Sun, 29 Jun 2025 00:33:57 +0000 (02:33 +0200)
commit965effba5a096f7eea7850cdfe1cad161df1eeb7
tree579449c6f846d8341f1a239692c6397e127b1207
parent688305d15eaccae7dcd2f952d9e976fc3a764e52
squashfs: Fix integer overflow in sqfs_resolve_symlink()

A carefully crafted squashfs filesystem can exhibit an inode size of 0xffffffff,
as a consequence malloc() will do a zero allocation.
Later in the function the inode size is again used for copying data.
So an attacker can overwrite memory.
Avoid the overflow by using the __builtin_add_overflow() helper.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-By: Daniel Leidert <dleidert@debian.org>
Origin: https://source.denx.de/u-boot/u-boot/-/commit/233945eba63e24061dffeeaeb7cd6fe985278356
Bug: https://www.openwall.com/lists/oss-security/2025/02/17/2
Bug-Debian: https://bugs.debian.org/1098254
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2024-57255
Bug-Freexian-Security: https://deb.freexian.com/extended-lts/tracker/CVE-2024-57255

Gbp-Pq: Name CVE-2024-57255.patch
fs/squashfs/sqfs.c