diff options
| -rw-r--r-- | meta/recipes-bsp/u-boot/files/CVE-2024-57255.patch | 53 | ||||
| -rw-r--r-- | meta/recipes-bsp/u-boot/u-boot-common.inc | 1 |
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 @@ | |||
| 1 | From 5d7ca74388544bf8c95e104517a9120e94bfe40d Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Richard Weinberger <richard@nod.at> | ||
| 3 | Date: Fri, 2 Aug 2024 18:36:44 +0200 | ||
| 4 | Subject: [PATCH 2/8] squashfs: Fix integer overflow in sqfs_resolve_symlink() | ||
| 5 | |||
| 6 | A carefully crafted squashfs filesystem can exhibit an inode size of 0xffffffff, | ||
| 7 | as a consequence malloc() will do a zero allocation. | ||
| 8 | Later in the function the inode size is again used for copying data. | ||
| 9 | So an attacker can overwrite memory. | ||
| 10 | Avoid the overflow by using the __builtin_add_overflow() helper. | ||
| 11 | |||
| 12 | Signed-off-by: Richard Weinberger <richard@nod.at> | ||
| 13 | Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> | ||
| 14 | |||
| 15 | CVE: CVE-2024-57255 | ||
| 16 | Upstream-Status: Backport [https://source.denx.de/u-boot/u-boot/-/commit/233945eba63e24061dffeeaeb7cd6fe985278356] | ||
| 17 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> | ||
| 18 | --- | ||
| 19 | fs/squashfs/sqfs.c | 10 ++++++---- | ||
| 20 | 1 file changed, 6 insertions(+), 4 deletions(-) | ||
| 21 | |||
| 22 | diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c | ||
| 23 | index 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 | -- | ||
| 52 | 2.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 | ||
| 17 | SRC_URI = "git://source.denx.de/u-boot/u-boot.git;protocol=https;branch=master \ | 17 | SRC_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 | ||
| 21 | S = "${WORKDIR}/git" | 22 | S = "${WORKDIR}/git" |
