diff --git a/0022-append_pathname-check-the-value-returned-by-realloc.patch b/0022-append_pathname-check-the-value-returned-by-realloc.patch new file mode 100644 index 0000000000000000000000000000000000000000..26d740d87e5c748eede78b43c95472aa5da04e48 --- /dev/null +++ b/0022-append_pathname-check-the-value-returned-by-realloc.patch @@ -0,0 +1,46 @@ +From af03924f5b43b325a436d07ee1222f42e3aa96b6 Mon Sep 17 00:00:00 2001 +From: wuguanghao +Date: Wed, 30 Jun 2021 16:27:18 +0800 +Subject: [PATCH] append_pathname: check the value returned by realloc + +In append_pathname(), we need to add a new path to save the value +returned by realloc, otherwise the name->path may be NULL, causing +a segfault. + +Signed-off-by: Wu Guanghao +Signed-off-by: Zhiqiang Liu +Signed-off-by: Theodore Ts'o +--- + contrib/fsstress.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/contrib/fsstress.c b/contrib/fsstress.c +index 2a983482..2136a903 100644 +--- a/contrib/fsstress.c ++++ b/contrib/fsstress.c +@@ -599,6 +599,7 @@ void add_to_flist(int ft, int id, int parent) + void append_pathname(pathname_t * name, char *str) + { + int len; ++ char *path; + + len = strlen(str); + #ifdef DEBUG +@@ -609,7 +610,13 @@ void append_pathname(pathname_t * name, char *str) + + } + #endif +- name->path = realloc(name->path, name->len + 1 + len); ++ path = realloc(name->path, name->len + 1 + len); ++ if (path == NULL) { ++ fprintf(stderr, "fsstress: append_pathname realloc failed\n"); ++ chdir(homedir); ++ abort(); ++ } ++ name->path = path; + strcpy(&name->path[name->len], str); + name->len += len; + } +-- +2.33.0 + diff --git a/0023-argv_parse-check-return-value-of-malloc-in-argv_pars.patch b/0023-argv_parse-check-return-value-of-malloc-in-argv_pars.patch new file mode 100644 index 0000000000000000000000000000000000000000..2c8177298b14c5832f46d94218bcd41846a1cce6 --- /dev/null +++ b/0023-argv_parse-check-return-value-of-malloc-in-argv_pars.patch @@ -0,0 +1,31 @@ +From a61bc9e009b4b829f61f1717753b4ee0882d9aba Mon Sep 17 00:00:00 2001 +From: Zhiqiang Liu +Date: Wed, 30 Jun 2021 16:27:19 +0800 +Subject: [PATCH] argv_parse: check return value of malloc in argv_parse() + +In argv_parse(), return value of malloc should be checked +whether it is NULL, otherwise, it may cause a segfault error. + +Signed-off-by: Zhiqiang Liu +Signed-off-by: Wu Guanghao +Signed-off-by: Theodore Ts'o +--- + lib/support/argv_parse.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/lib/support/argv_parse.c b/lib/support/argv_parse.c +index d22f6344..1f50f9e5 100644 +--- a/lib/support/argv_parse.c ++++ b/lib/support/argv_parse.c +@@ -116,6 +116,8 @@ int argv_parse(char *in_buf, int *ret_argc, char ***ret_argv) + if (argv == 0) { + argv = malloc(sizeof(char *)); + free(buf); ++ if (!argv) ++ return -1; + } + argv[argc] = 0; + if (ret_argc) +-- +2.33.0 + diff --git a/0024-libext2fs-improve-error-handling-in-POSIX-ACL-conver.patch b/0024-libext2fs-improve-error-handling-in-POSIX-ACL-conver.patch new file mode 100644 index 0000000000000000000000000000000000000000..f3d090d821a6b1bd34a1a14c5fbb73bced930a5f --- /dev/null +++ b/0024-libext2fs-improve-error-handling-in-POSIX-ACL-conver.patch @@ -0,0 +1,45 @@ +From ea97af65c5194137cec7bd770b79cd601d2a92a0 Mon Sep 17 00:00:00 2001 +From: Samuel Holland +Date: Fri, 28 May 2021 22:14:04 -0500 +Subject: [PATCH] libext2fs: improve error handling in POSIX ACL conversions + +When encoding a POSIX ACL to the EXT4 ACL format, if an unknown tag +is encountered, that entry is silently ignored. It would be better +to return an error to inform the user that the ACL is incompatible. + +Also fix the mismatched indentation in the opposite function. + +Signed-off-by: Samuel Holland +--- + lib/ext2fs/ext_attr.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/lib/ext2fs/ext_attr.c b/lib/ext2fs/ext_attr.c +index 4f6371de..efe4d29f 100644 +--- a/lib/ext2fs/ext_attr.c ++++ b/lib/ext2fs/ext_attr.c +@@ -573,6 +573,8 @@ static errcode_t convert_posix_acl_to_disk_buffer(const void *value, size_t size + e += sizeof(ext4_acl_entry); + s += sizeof(ext4_acl_entry); + break; ++ default: ++ return EINVAL; + } + } + *size_out = s; +@@ -626,9 +628,9 @@ static errcode_t convert_disk_buffer_to_posix_acl(const void *value, size_t size + cp += sizeof(ext4_acl_entry); + size -= sizeof(ext4_acl_entry); + break; +- default: +- ext2fs_free_mem(&out); +- return EINVAL; ++ default: ++ ext2fs_free_mem(&out); ++ return EINVAL; + } + entry++; + } +-- +2.33.0 + diff --git a/e2fsprogs.spec b/e2fsprogs.spec index d2fed8dd50814d3d38d609f98a3f94db3113136e..24e67dfd00f1ab147aba334d8f04f1d8d89757e9 100644 --- a/e2fsprogs.spec +++ b/e2fsprogs.spec @@ -1,6 +1,6 @@ Name: e2fsprogs Version: 1.46.5 -Release: 4 +Release: 5 Summary: Second extended file system management tools License: GPLv2+ and LGPLv2 and MIT URL: http://e2fsprogs.sourceforge.net/ @@ -28,6 +28,9 @@ Patch18: 0018-misc-fsck.c-Processes-may-kill-other-processes.patch Patch19: 0019-debugfs-fix-repeated-output-problem-with-logdump-O-n.patch Patch20: 0020-tune2fs-check-return-value-of-ext2fs_mmp_update2-in-.patch Patch21: 0021-mmp-fix-wrong-comparison-in-ext2fs_mmp_stop.patch +Patch22: 0022-append_pathname-check-the-value-returned-by-realloc.patch +Patch23: 0023-argv_parse-check-return-value-of-malloc-in-argv_pars.patch +Patch24: 0024-libext2fs-improve-error-handling-in-POSIX-ACL-conver.patch BuildRequires: gcc pkgconfig texinfo @@ -169,6 +172,9 @@ exit 0 %{_mandir}/man8/* %changelog +* Thu Apr 13 2023 tangyuchen - 1.46.5-5 +- Backport e2fsprogs patches + * Thu Feb 9 2023 lihaoxiang - 1.46.5-4 - Upstream patches regress for debugfs, tune2fs and mmp.