summaryrefslogtreecommitdiffstats
path: root/meta/recipes-bsp
diff options
context:
space:
mode:
authorHongxu Jia <hongxu.jia@windriver.com>2025-02-19 15:04:34 +0800
committerSteve Sakoman <steve@sakoman.com>2025-02-28 06:45:14 -0800
commit618c5fdb1461891a812bce5131339873a96b12fe (patch)
tree2ab1f8b4d3e4ff64f64327e652b96290348d69a1 /meta/recipes-bsp
parentec0e90ce423f8cba7b52a4452f5c32a50dce230d (diff)
downloadpoky-618c5fdb1461891a812bce5131339873a96b12fe.tar.gz
u-boot: fix CVE-2024-57255
An integer overflow in sqfs_resolve_symlink in Das U-Boot before 2025.01-rc1 occurs via a crafted squashfs filesystem with an inode size of 0xffffffff, resulting in a malloc of zero and resultant memory overwrite. https://nvd.nist.gov/vuln/detail/CVE-2024-57255 (From OE-Core rev: c3784c108f003c6663ca969585414e4a90f06606) Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta/recipes-bsp')
-rw-r--r--meta/recipes-bsp/u-boot/files/CVE-2024-57255.patch53
-rw-r--r--meta/recipes-bsp/u-boot/u-boot-common.inc1
2 files changed, 54 insertions, 0 deletions
diff --git a/meta/recipes-bsp/u-boot/files/CVE-2024-57255.patch b/meta/recipes-bsp/u-boot/files/CVE-2024-57255.patch
new file mode 100644
index 0000000000..4ca72da554
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/files/CVE-2024-57255.patch
@@ -0,0 +1,53 @@
1From 5d7ca74388544bf8c95e104517a9120e94bfe40d Mon Sep 17 00:00:00 2001
2From: Richard Weinberger <richard@nod.at>
3Date: Fri, 2 Aug 2024 18:36:44 +0200
4Subject: [PATCH 2/8] squashfs: Fix integer overflow in sqfs_resolve_symlink()
5
6A carefully crafted squashfs filesystem can exhibit an inode size of 0xffffffff,
7as a consequence malloc() will do a zero allocation.
8Later in the function the inode size is again used for copying data.
9So an attacker can overwrite memory.
10Avoid the overflow by using the __builtin_add_overflow() helper.
11
12Signed-off-by: Richard Weinberger <richard@nod.at>
13Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
14
15CVE: CVE-2024-57255
16Upstream-Status: Backport [https://source.denx.de/u-boot/u-boot/-/commit/233945eba63e24061dffeeaeb7cd6fe985278356]
17Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
18---
19 fs/squashfs/sqfs.c | 10 ++++++----
20 1 file changed, 6 insertions(+), 4 deletions(-)
21
22diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c
23index 1430e671..16a07c06 100644
24--- a/fs/squashfs/sqfs.c
25+++ b/fs/squashfs/sqfs.c
26@@ -422,8 +422,10 @@ static char *sqfs_resolve_symlink(struct squashfs_symlink_inode *sym,
27 char *resolved, *target;
28 u32 sz;
29
30- sz = get_unaligned_le32(&sym->symlink_size);
31- target = malloc(sz + 1);
32+ if (__builtin_add_overflow(get_unaligned_le32(&sym->symlink_size), 1, &sz))
33+ return NULL;
34+
35+ target = malloc(sz);
36 if (!target)
37 return NULL;
38
39@@ -431,9 +433,9 @@ static char *sqfs_resolve_symlink(struct squashfs_symlink_inode *sym,
40 * There is no trailling null byte in the symlink's target path, so a
41 * copy is made and a '\0' is added at its end.
42 */
43- target[sz] = '\0';
44+ target[sz - 1] = '\0';
45 /* Get target name (relative path) */
46- strncpy(target, sym->symlink, sz);
47+ strncpy(target, sym->symlink, sz - 1);
48
49 /* Relative -> absolute path conversion */
50 resolved = sqfs_get_abs_path(base_path, target);
51--
522.34.1
53
diff --git a/meta/recipes-bsp/u-boot/u-boot-common.inc b/meta/recipes-bsp/u-boot/u-boot-common.inc
index 9ce42e829f..e907edd2eb 100644
--- a/meta/recipes-bsp/u-boot/u-boot-common.inc
+++ b/meta/recipes-bsp/u-boot/u-boot-common.inc
@@ -16,6 +16,7 @@ SRCREV = "866ca972d6c3cabeaf6dbac431e8e08bb30b3c8e"
16 16
17SRC_URI = "git://source.denx.de/u-boot/u-boot.git;protocol=https;branch=master \ 17SRC_URI = "git://source.denx.de/u-boot/u-boot.git;protocol=https;branch=master \
18 file://CVE-2024-57254.patch \ 18 file://CVE-2024-57254.patch \
19 file://CVE-2024-57255.patch \
19" 20"
20 21
21S = "${WORKDIR}/git" 22S = "${WORKDIR}/git"