squashfs-tools: fix CVE-2021-41072
PATCH 1/1 squashfs-tools: fix CVE-2021-41072
From: Kai Kang <[email protected]>
Backport patch to fix CVE-2021-41072. And 3 more ancestor commits are backported too, otherwise it fails to compile.
CVE: CVE-2021-41072
Ref:
* https://nvd.nist.gov/vuln/detail/CVE-2021-41072
Signed-off-by Kai Kang <[email protected]>
--- .../CVE-2021-41072-requisite-1.patch | 135 ++++++++ .../CVE-2021-41072-requisite-2.patch | 108 ++++++ .../CVE-2021-41072-requisite-3.patch | 326 ++++++++++++++++++ .../squashfs-tools/CVE-2021-41072.patch | 325 +++++++++++++++++ .../squashfs-tools/squashfs-tools_git.bb | 4 + 5 files changed, 898 insertions(+) create mode 100644 meta/recipes-devtools/squashfs-tools/squashfs-tools/CVE-2021-41072-requisite-1.patch create mode 100644 meta/recipes-devtools/squashfs-tools/squashfs-tools/CVE-2021-41072-requisite-2.patch create mode 100644 meta/recipes-devtools/squashfs-tools/squashfs-tools/CVE-2021-41072-requisite-3.patch create mode 100644 meta/recipes-devtools/squashfs-tools/squashfs-tools/CVE-2021-41072.patch
meta/recipes-devtools/squashfs-tools/squashfs-tools/CVE-2021-41072-requisite-1.patch new file +135 -0
@@ -0,0 +1,135 @@ +The commit is required by the fix for CVE-2021-41072. + +Upstream-Status: Backport [https://github.com/plougher/squashfs-tools/commit/80b8441] + +Signed-off-by: Kai Kang <[email protected]> + +From 80b8441a37fcf8bf07dacf24d9d6c6459a0f6e36 Mon Sep 17 00:00:00 2001 +From: Phillip Lougher <[email protected]> +Date: Sun, 12 Sep 2021 19:58:19 +0100 +Subject: [PATCH] unsquashfs: use squashfs_closedir() to delete directory + +Signed-off-by: Phillip Lougher <[email protected]> +--- + squashfs-tools/unsquash-1.c | 3 +-- + squashfs-tools/unsquash-1234.c | 11 +++++++++-- + squashfs-tools/unsquash-2.c | 3 +-- + squashfs-tools/unsquash-3.c | 3 +-- + squashfs-tools/unsquash-4.c | 3 +-- + squashfs-tools/unsquashfs.c | 7 ------- + squashfs-tools/unsquashfs.h | 1 + + 7 files changed, 14 insertions(+), 17 deletions(-) + +diff --git a/squashfs-tools/unsquash-1.c b/squashfs-tools/unsquash-1.c +index acba821..7598499 100644 +--- a/squashfs-tools/unsquash-1.c ++++ b/squashfs-tools/unsquash-1.c +@@ -373,8 +373,7 @@ static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offse + return dir; + + corrupted: +- free(dir->dirs); +- free(dir); ++ squashfs_closedir(dir); + return NULL; + } + +diff --git a/squashfs-tools/unsquash-1234.c b/squashfs-tools/unsquash-1234.c +index c2d4f42..0c8dfbb 100644 +--- a/squashfs-tools/unsquash-1234.c ++++ b/squashfs-tools/unsquash-1234.c +@@ -25,8 +25,8 @@ + * unsquash-4. + */ + +-#define TRUE 1 +-#define FALSE 0 ++#include "unsquashfs.h" ++ + /* + * Check name for validity, name should not + * - be ".", "./", or +@@ -56,3 +56,10 @@ int check_name(char *name, int size) + + return TRUE; + } ++ ++ ++void squashfs_closedir(struct dir *dir) ++{ ++ free(dir->dirs); ++ free(dir); ++} +diff --git a/squashfs-tools/unsquash-2.c b/squashfs-tools/unsquash-2.c +index 0746b3d..86f62ba 100644 +--- a/squashfs-tools/unsquash-2.c ++++ b/squashfs-tools/unsquash-2.c +@@ -465,8 +465,7 @@ static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offse + return dir; + + corrupted: +- free(dir->dirs); +- free(dir); ++ squashfs_closedir(dir); + return NULL; + } + +diff --git a/squashfs-tools/unsquash-3.c b/squashfs-tools/unsquash-3.c +index 094caaa..c04aa9e 100644 +--- a/squashfs-tools/unsquash-3.c ++++ b/squashfs-tools/unsquash-3.c +@@ -499,8 +499,7 @@ static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offse + return dir; + + corrupted: +- free(dir->dirs); +- free(dir); ++ squashfs_closedir(dir); + return NULL; + } + +diff --git a/squashfs-tools/unsquash-4.c b/squashfs-tools/unsquash-4.c +index 3a1b9e1..ff62dcc 100644 +--- a/squashfs-tools/unsquash-4.c ++++ b/squashfs-tools/unsquash-4.c +@@ -436,8 +436,7 @@ static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offse + return dir; + + corrupted: +- free(dir->dirs); +- free(dir); ++ squashfs_closedir(dir); + return NULL; + } + +diff --git a/squashfs-tools/unsquashfs.c b/squashfs-tools/unsquashfs.c +index 7b590bd..04be53c 100644 +--- a/squashfs-tools/unsquashfs.c ++++ b/squashfs-tools/unsquashfs.c +@@ -1350,13 +1350,6 @@ unsigned int *offset, unsigned int *type) + } + + +-void squashfs_closedir(struct dir *dir) +-{ +- free(dir->dirs); +- free(dir); +-} +- +- + char *get_component(char *target, char **targname) + { + char *start; +diff --git a/squashfs-tools/unsquashfs.h b/squashfs-tools/unsquashfs.h +index 2e9201c..5ecb2ab 100644 +--- a/squashfs-tools/unsquashfs.h ++++ b/squashfs-tools/unsquashfs.h +@@ -291,4 +291,5 @@ extern long long *alloc_index_table(int); + + /* unsquash-1234.c */ + extern int check_name(char *, int); ++extern void squashfs_closedir(struct dir *); + #endif +-- +2.17.1 +
meta/recipes-devtools/squashfs-tools/squashfs-tools/CVE-2021-41072-requisite-2.patch new file +108 -0
108 lines not on this page · raw message
meta/recipes-devtools/squashfs-tools/squashfs-tools/CVE-2021-41072-requisite-3.patch new file +326 -0
326 lines not on this page · raw message
meta/recipes-devtools/squashfs-tools/squashfs-tools/CVE-2021-41072.patch new file +325 -0
325 lines not on this page · raw message
meta/recipes-devtools/squashfs-tools/squashfs-tools_git.bb +4 -0
@@ -11,6 +11,10 @@ PV = "4.5" SRCREV = "0496d7c3de3e09da37ba492081c86159806ebb07" SRC_URI = "git://github.com/plougher/squashfs-tools.git;protocol=https \ file://0001-Avoid-use-of-INSTALL_DIR-for-symlink-targets.patch \ + file://CVE-2021-41072-requisite-1.patch;striplevel=2 \ + file://CVE-2021-41072-requisite-2.patch;striplevel=2 \ + file://CVE-2021-41072-requisite-3.patch;striplevel=2 \ + file://CVE-2021-41072.patch;striplevel=2 \ " S = "${WORKDIR}/git/squashfs-tools"
Signature · 1 line
2.17.1