From e4b266fdf22f0addc703c668b9835bda4b2ea1f0 Mon Sep 17 00:00:00 2001 From: zhangyao Date: Fri, 12 May 2023 11:40:52 +0800 Subject: [PATCH] sync community patches (cherry picked from commit 6dd51158f697e8922904bf11109bd894487a9419) --- backport-CVE-2022-0563.patch | 169 ++++++++++++++++++ ...nteger-overflow-for-alpha-like-linux.patch | 22 +++ ...n-don-t-require-column-name-for-JSON.patch | 103 +++++++++++ backport-dmesg-fix-since-and-until.patch | 30 ++++ ...ush-stdout-before-reading-from-stdin.patch | 28 +++ ...stdin-and-fix-uninitialized-variable.patch | 38 ++++ ...-don-t-assume-zero-terminate-strings.patch | 35 ++++ ...fe_getenv-to-work-for-non-root-users.patch | 30 ++++ ...e-path-use-more-robust-coverity-scan.patch | 57 ++++++ ...-strtoul_or_err-for-negative-numbers.patch | 90 ++++++++++ ...cache-as-probed-if-sys-not-available.patch | 140 +++++++++++++++ ...fix-make-sure-buffer-is-large-enough.patch | 24 +++ ...id-make-blkid_free_probe-more-robust.patch | 22 +++ ...ontinue-although-proc-is-not-mounted.patch | 113 ++++++++++++ ...block_size-when-using-LOOP_CONFIGURE.patch | 46 +++++ backport-lslocks-fix-maj-min-scanf.patch | 28 +++ ...rt-lslogins-fix-free-invalid-pointer.patch | 33 ++++ ...rt-script-fix-passing-args-to-execlp.patch | 34 ++++ ...ort-scriptlive-fix-argv-0-for-execlp.patch | 26 +++ ...partitions-not-including-parent-name.patch | 45 +++++ util-linux.spec | 147 +++++++++------ 21 files changed, 1210 insertions(+), 50 deletions(-) create mode 100644 backport-CVE-2022-0563.patch create mode 100644 backport-Fix-integer-overflow-for-alpha-like-linux.patch create mode 100644 backport-column-don-t-require-column-name-for-JSON.patch create mode 100644 backport-dmesg-fix-since-and-until.patch create mode 100644 backport-fflush-stdout-before-reading-from-stdin.patch create mode 100644 backport-flush-stdout-before-reading-stdin-and-fix-uninitialized-variable.patch create mode 100644 backport-last-don-t-assume-zero-terminate-strings.patch create mode 100644 backport-lib-allow-safe_getenv-to-work-for-non-root-users.patch create mode 100644 backport-lib-path-make-path-use-more-robust-coverity-scan.patch create mode 100644 backport-lib-strutils-improve-strtoul_or_err-for-negative-numbers.patch create mode 100644 backport-libblkid-don-t-mark-cache-as-probed-if-sys-not-available.patch create mode 100644 backport-libblkid-hfs-fix-make-sure-buffer-is-large-enough.patch create mode 100644 backport-libblkid-make-blkid_free_probe-more-robust.patch create mode 100644 backport-libmount-all-continue-although-proc-is-not-mounted.patch create mode 100644 backport-loopdev-set-block_size-when-using-LOOP_CONFIGURE.patch create mode 100644 backport-lslocks-fix-maj-min-scanf.patch create mode 100644 backport-lslogins-fix-free-invalid-pointer.patch create mode 100644 backport-script-fix-passing-args-to-execlp.patch create mode 100644 backport-scriptlive-fix-argv-0-for-execlp.patch create mode 100644 backport-sysfs-fallback-for-partitions-not-including-parent-name.patch diff --git a/backport-CVE-2022-0563.patch b/backport-CVE-2022-0563.patch new file mode 100644 index 0000000..63143f6 --- /dev/null +++ b/backport-CVE-2022-0563.patch @@ -0,0 +1,169 @@ +From faa5a3a83ad0cb5e2c303edbfd8cd823c9d94c17 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 10 Feb 2022 12:03:17 +0100 +Subject: [PATCH] chsh, chfn: remove readline support [CVE-2022-0563] + +The readline library uses INPUTRC= environment variable to get a path +to the library config file. When the library cannot parse the +specified file, it prints an error message containing data from the +file. + +Unfortunately, the library does not use secure_getenv() (or a similar +concept) to avoid vulnerabilities that could occur if set-user-ID or +set-group-ID programs. + +Reported-by: Rory Mackie +Signed-off-by: Karel Zak + +--- + login-utils/Makemodule.am | 2 +- + login-utils/chfn.c | 16 ++++---------- + login-utils/chsh.c | 45 ++++----------------------------------- + 3 files changed, 9 insertions(+), 54 deletions(-) + +diff --git a/login-utils/Makemodule.am b/login-utils/Makemodule.am +index 75c0a67..2d0547a 100644 +--- a/login-utils/Makemodule.am ++++ b/login-utils/Makemodule.am +@@ -109,7 +109,7 @@ chfn_chsh_sources = \ + login-utils/ch-common.c + chfn_chsh_cflags = $(SUID_CFLAGS) $(AM_CFLAGS) + chfn_chsh_ldflags = $(SUID_LDFLAGS) $(AM_LDFLAGS) +-chfn_chsh_ldadd = libcommon.la $(READLINE_LIBS) ++chfn_chsh_ldadd = libcommon.la + + if CHFN_CHSH_PASSWORD + chfn_chsh_ldadd += -lpam +diff --git a/login-utils/chfn.c b/login-utils/chfn.c +index ece5cdc..8f00d15 100644 +--- a/login-utils/chfn.c ++++ b/login-utils/chfn.c +@@ -56,11 +56,6 @@ + # include "auth.h" + #endif + +-#ifdef HAVE_LIBREADLINE +-# define _FUNCTION_DEF +-# include +-#endif +- + struct finfo { + char *full_name; + char *office; +@@ -228,24 +223,21 @@ static char *ask_new_field(struct chfn_control *ctl, const char *question, + { + int len; + char *buf = NULL; /* leave initialized to NULL or getline segfaults */ +-#ifndef HAVE_LIBREADLINE + size_t dummy = 0; +-#endif + + if (!def_val) + def_val = ""; ++ + while (true) { + printf("%s [%s]:", question, def_val); + __fpurge(stdin); +-#ifdef HAVE_LIBREADLINE +- rl_bind_key('\t', rl_insert); +- if ((buf = readline(" ")) == NULL) +-#else ++ + putchar(' '); + fflush(stdout); ++ + if (getline(&buf, &dummy, stdin) < 0) +-#endif + errx(EXIT_FAILURE, _("Aborted.")); ++ + /* remove white spaces from string end */ + ltrim_whitespace((unsigned char *) buf); + len = rtrim_whitespace((unsigned char *) buf); +diff --git a/login-utils/chsh.c b/login-utils/chsh.c +index 3b446be..b7e7017 100644 +--- a/login-utils/chsh.c ++++ b/login-utils/chsh.c +@@ -50,7 +50,6 @@ + # include "selinux-utils.h" + #endif + +- + #ifdef HAVE_LIBUSER + # include + # include "libuser.h" +@@ -58,11 +57,6 @@ + # include "auth.h" + #endif + +-#ifdef HAVE_LIBREADLINE +-# define _FUNCTION_DEF +-# include +-#endif +- + struct sinfo { + char *username; + char *shell; +@@ -121,33 +115,6 @@ static void print_shells(void) + endusershell(); + } + +-#ifdef HAVE_LIBREADLINE +-static char *shell_name_generator(const char *text, int state) +-{ +- static size_t len; +- char *s; +- +- if (!state) { +- setusershell(); +- len = strlen(text); +- } +- +- while ((s = getusershell())) { +- if (strncmp(s, text, len) == 0) +- return xstrdup(s); +- } +- return NULL; +-} +- +-static char **shell_name_completion(const char *text, +- int start __attribute__((__unused__)), +- int end __attribute__((__unused__))) +-{ +- rl_attempted_completion_over = 1; +- return rl_completion_matches(text, shell_name_generator); +-} +-#endif +- + /* + * parse_argv () -- + * parse the command line arguments, and fill in "pinfo" with any +@@ -198,22 +165,18 @@ static char *ask_new_shell(char *question, char *oldshell) + { + int len; + char *ans = NULL; +-#ifdef HAVE_LIBREADLINE +- rl_attempted_completion_function = shell_name_completion; +-#else + size_t dummy = 0; +-#endif ++ + if (!oldshell) + oldshell = ""; + printf("%s [%s]:", question, oldshell); +-#ifdef HAVE_LIBREADLINE +- if ((ans = readline(" ")) == NULL) +-#else ++ + putchar(' '); + fflush(stdout); ++ + if (getline(&ans, &dummy, stdin) < 0) +-#endif + return NULL; ++ + /* remove the newline at the end of ans. */ + ltrim_whitespace((unsigned char *) ans); + len = rtrim_whitespace((unsigned char *) ans); +-- +2.27.0 + diff --git a/backport-Fix-integer-overflow-for-alpha-like-linux.patch b/backport-Fix-integer-overflow-for-alpha-like-linux.patch new file mode 100644 index 0000000..d2c76b7 --- /dev/null +++ b/backport-Fix-integer-overflow-for-alpha-like-linux.patch @@ -0,0 +1,22 @@ +From db5aa5e5d8932c73f1b9f01fe567fa343898b825 Mon Sep 17 00:00:00 2001 +From: chanthmiao +Date: Sun, 5 Dec 2021 16:58:17 +0800 +Subject: [PATCH] Fix integer overflow for alpha like linux + +--- + sys-utils/swapon.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c +index ed6be244ec..76c5cac51b 100644 +--- a/sys-utils/swapon.c ++++ b/sys-utils/swapon.c +@@ -543,7 +543,7 @@ static int swapon_checks(const struct swapon_ctl *ctl, struct swap_device *dev) + + /* test for holes by LBT */ + if (S_ISREG(st.st_mode)) { +- if (st.st_blocks * 512 < st.st_size) { ++ if (st.st_blocks * 512L < st.st_size) { + warnx(_("%s: skipping - it appears to have holes."), + dev->path); + goto err; diff --git a/backport-column-don-t-require-column-name-for-JSON.patch b/backport-column-don-t-require-column-name-for-JSON.patch new file mode 100644 index 0000000..4a1a62f --- /dev/null +++ b/backport-column-don-t-require-column-name-for-JSON.patch @@ -0,0 +1,103 @@ +From fd75b96898c455c35c045bc59a2a4a546e79f223 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 23 Mar 2022 12:50:07 +0100 +Subject: [PATCH] column: don't require column name for JSON + +The "--table-hide -" hides all unnamed columns, but this does not work +for JSON output. This patch fixes this issue. + +Signed-off-by: Karel Zak +--- + text-utils/column.c | 37 +++++++++++++++++++++++++++++++++---- + 1 file changed, 33 insertions(+), 4 deletions(-) + +diff --git a/text-utils/column.c b/text-utils/column.c +index f9878e4..0fc4708 100644 +--- a/text-utils/column.c ++++ b/text-utils/column.c +@@ -96,6 +96,7 @@ struct column_control { + unsigned int greedy :1, + json :1, + header_repeat :1, ++ hide_unnamed :1, + keep_empty_lines :1, /* --keep-empty-lines */ + tab_noheadings :1; + }; +@@ -196,7 +197,10 @@ static char **split_or_error(const char *str, const char *errmsg) + if (!res) { + if (errno == ENOMEM) + err_oom(); +- errx(EXIT_FAILURE, "%s: '%s'", errmsg, str); ++ if (errmsg) ++ errx(EXIT_FAILURE, "%s: '%s'", errmsg, str); ++ else ++ return NULL; + } + return res; + } +@@ -275,6 +279,29 @@ static int column_set_flag(struct libscols_column *cl, int fl) + return scols_column_set_flags(cl, cur | fl); + } + ++static int has_unnamed(const char *list) ++{ ++ char **all, **one; ++ ++ if (!list) ++ return 0; ++ if (strcmp(list, "-") == 0) ++ return 1; ++ if (!strchr(list, ',')) ++ return 0; ++ ++ all = split_or_error(list, NULL); ++ if (all) { ++ STRV_FOREACH(one, all) { ++ if (strcmp(*one, "-") == 0) ++ return 1; ++ } ++ strv_free(all); ++ } ++ ++ return 0; ++} ++ + static void apply_columnflag_from_list(struct column_control *ctl, const char *list, + int flag, const char *errmsg) + { +@@ -300,7 +327,7 @@ static void apply_columnflag_from_list(struct column_control *ctl, const char *l + + /* apply to columns specified by name */ + STRV_FOREACH(one, all) { +- if (flag == SCOLS_FL_HIDDEN && strcmp(*one, "-") == 0) { ++ if (strcmp(*one, "-") == 0) { + unnamed = 1; + continue; + } +@@ -461,12 +488,13 @@ static int add_line_to_table(struct column_control *ctl, wchar_t *wcs0) + if (!wcdata) + break; + if (scols_table_get_ncols(ctl->tab) < n + 1) { +- if (scols_table_is_json(ctl->tab)) ++ if (scols_table_is_json(ctl->tab) && !ctl->hide_unnamed) + errx(EXIT_FAILURE, _("line %zu: for JSON the name of the " + "column %zu is required"), + scols_table_get_nlines(ctl->tab) + 1, + n + 1); +- scols_table_new_column(ctl->tab, NULL, 0, 0); ++ scols_table_new_column(ctl->tab, NULL, 0, ++ ctl->hide_unnamed ? SCOLS_FL_HIDDEN : 0); + } + if (!ln) { + ln = scols_table_new_line(ctl->tab, NULL); +@@ -774,6 +802,7 @@ int main(int argc, char **argv) + break; + case 'H': + ctl.tab_colhide = optarg; ++ ctl.hide_unnamed = has_unnamed(ctl.tab_colhide); + break; + case 'i': + ctl.tree_id = optarg; +-- +2.27.0 + diff --git a/backport-dmesg-fix-since-and-until.patch b/backport-dmesg-fix-since-and-until.patch new file mode 100644 index 0000000..d5fbca3 --- /dev/null +++ b/backport-dmesg-fix-since-and-until.patch @@ -0,0 +1,30 @@ +From c9667633f1f6b7a84116f2af067d1d15c72e6382 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 20 Apr 2022 14:42:32 +0200 +Subject: [PATCH] dmesg: fix --since and --until + +Now --since and --until requires any time field in the output (e.g. +--ctime,-T), it means "dmesg --since '1 day ago'" doesn't work, but +"dmesg -T --since '1 day ago'" works as expected. + +Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2076829 +Signed-off-by: Karel Zak +--- + sys-utils/dmesg.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c +index 7cca88f2bb..017936255f 100644 +--- a/sys-utils/dmesg.c ++++ b/sys-utils/dmesg.c +@@ -1592,7 +1592,9 @@ int main(int argc, char *argv[]) + + if ((is_timefmt(&ctl, RELTIME) || + is_timefmt(&ctl, CTIME) || +- is_timefmt(&ctl, ISO8601))) { ++ is_timefmt(&ctl, ISO8601)) || ++ ctl.since || ++ ctl.until) { + if (dmesg_get_boot_time(&ctl.boot_time) != 0) + ctl.time_fmt = DMESG_TIMEFTM_NONE; + else diff --git a/backport-fflush-stdout-before-reading-from-stdin.patch b/backport-fflush-stdout-before-reading-from-stdin.patch new file mode 100644 index 0000000..a0edc46 --- /dev/null +++ b/backport-fflush-stdout-before-reading-from-stdin.patch @@ -0,0 +1,28 @@ +From 0a08200bd5664d1849e477f7f776ab4d13bb8422 Mon Sep 17 00:00:00 2001 +From: Lorenzo Beretta +Date: Mon, 25 Oct 2021 15:28:02 +0200 +Subject: [PATCH] chsh: fflush stdout before reading from stdin + +Same problem as described in https://github.com/karelzak/util-linux/pull/1481 + +Signed-off-by: Lorenzo Beretta + +--- + login-utils/chsh.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/login-utils/chsh.c b/login-utils/chsh.c +index 3497120..3b446be 100644 +--- a/login-utils/chsh.c ++++ b/login-utils/chsh.c +@@ -210,6 +210,7 @@ static char *ask_new_shell(char *question, char *oldshell) + if ((ans = readline(" ")) == NULL) + #else + putchar(' '); ++ fflush(stdout); + if (getline(&ans, &dummy, stdin) < 0) + #endif + return NULL; +-- +2.27.0 + diff --git a/backport-flush-stdout-before-reading-stdin-and-fix-uninitialized-variable.patch b/backport-flush-stdout-before-reading-stdin-and-fix-uninitialized-variable.patch new file mode 100644 index 0000000..b246599 --- /dev/null +++ b/backport-flush-stdout-before-reading-stdin-and-fix-uninitialized-variable.patch @@ -0,0 +1,38 @@ +From 05907d0d9e7c85f33e168feab1eb36b464425054 Mon Sep 17 00:00:00 2001 +From: Lorenzo Beretta +Date: Mon, 25 Oct 2021 14:06:00 +0200 +Subject: [PATCH] chfn: flush stdout before reading stdin and fix uninitialized + variable + +Same problem as described in https://github.com/karelzak/util-linux/pull/1481 + +Signed-off-by: Lorenzo Beretta + +--- + login-utils/chfn.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/login-utils/chfn.c b/login-utils/chfn.c +index 2508e14..ece5cdc 100644 +--- a/login-utils/chfn.c ++++ b/login-utils/chfn.c +@@ -227,7 +227,7 @@ static char *ask_new_field(struct chfn_control *ctl, const char *question, + char *def_val) + { + int len; +- char *buf; ++ char *buf = NULL; /* leave initialized to NULL or getline segfaults */ + #ifndef HAVE_LIBREADLINE + size_t dummy = 0; + #endif +@@ -242,6 +242,7 @@ static char *ask_new_field(struct chfn_control *ctl, const char *question, + if ((buf = readline(" ")) == NULL) + #else + putchar(' '); ++ fflush(stdout); + if (getline(&buf, &dummy, stdin) < 0) + #endif + errx(EXIT_FAILURE, _("Aborted.")); +-- +2.27.0 + diff --git a/backport-last-don-t-assume-zero-terminate-strings.patch b/backport-last-don-t-assume-zero-terminate-strings.patch new file mode 100644 index 0000000..323aa59 --- /dev/null +++ b/backport-last-don-t-assume-zero-terminate-strings.patch @@ -0,0 +1,35 @@ +From 6cd0043221b31a344db8f5dcb82822a2519a2e74 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 7 Feb 2022 13:34:43 +0100 +Subject: [PATCH] last: don't assume zero terminate strings + +Detected by fuzzer and AddressSanitizer. The utmp strings do not +have to be zero terminated. + +Signed-off-by: Karel Zak +--- + login-utils/last.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/login-utils/last.c b/login-utils/last.c +index c7aec4c116..84629278e5 100644 +--- a/login-utils/last.c ++++ b/login-utils/last.c +@@ -757,7 +757,7 @@ static void process_wtmp_file(const struct last_control *ctl, + else { + if (ut.ut_type != DEAD_PROCESS && + ut.ut_user[0] && ut.ut_line[0] && +- strcmp(ut.ut_user, "LOGIN") != 0) ++ strncmp(ut.ut_user, "LOGIN", 5) != 0) + ut.ut_type = USER_PROCESS; + /* + * Even worse, applications that write ghost +@@ -770,7 +770,7 @@ static void process_wtmp_file(const struct last_control *ctl, + /* + * Clock changes. + */ +- if (strcmp(ut.ut_user, "date") == 0) { ++ if (strncmp(ut.ut_user, "date", 4) == 0) { + if (ut.ut_line[0] == '|') + ut.ut_type = OLD_TIME; + if (ut.ut_line[0] == '{') diff --git a/backport-lib-allow-safe_getenv-to-work-for-non-root-users.patch b/backport-lib-allow-safe_getenv-to-work-for-non-root-users.patch new file mode 100644 index 0000000..051cd51 --- /dev/null +++ b/backport-lib-allow-safe_getenv-to-work-for-non-root-users.patch @@ -0,0 +1,30 @@ +From 16a2e0603f15c4a8f4517264930c7bdea5885bae Mon Sep 17 00:00:00 2001 +From: Mike Gilbert +Date: Tue, 26 Apr 2022 13:58:12 -0400 +Subject: [PATCH] lib: allow safe_getenv to work for non-root users + +This allows users to override settings like BLKID_FILE, as is done in +the e2fsprogs test suite. + +Bug: https://bugs.gentoo.org/839825 +Fixes: 035507c84b53bceb143d0923e65916cbf90979c7 +Signed-off-by: Mike Gilbert +--- + lib/env.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/lib/env.c b/lib/env.c +index a3dd335bfe..37125f4d5a 100644 +--- a/lib/env.c ++++ b/lib/env.c +@@ -161,9 +161,7 @@ void sanitize_env(void) + + char *safe_getenv(const char *arg) + { +- uid_t ruid = getuid(); +- +- if (ruid != 0 || (ruid != geteuid()) || (getgid() != getegid())) ++ if ((getuid() != geteuid()) || (getgid() != getegid())) + return NULL; + #ifdef HAVE_PRCTL + if (prctl(PR_GET_DUMPABLE, 0, 0, 0, 0) == 0) diff --git a/backport-lib-path-make-path-use-more-robust-coverity-scan.patch b/backport-lib-path-make-path-use-more-robust-coverity-scan.patch new file mode 100644 index 0000000..1f651e8 --- /dev/null +++ b/backport-lib-path-make-path-use-more-robust-coverity-scan.patch @@ -0,0 +1,57 @@ +From 41a27709e9028940578a5cdae17292e432fa23fa Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 29 Nov 2021 13:25:16 +0100 +Subject: [PATCH] lib/path: make path use more robust [coverity scan] + +*** CID 374365: Null pointer dereferences (FORWARD_NULL) +/lib/path.c: 364 in ul_path_stat() + +Signed-off-by: Karel Zak +--- + lib/path.c | 5 ++++- + lib/sysfs.c | 2 +- + 2 files changed, 5 insertions(+), 2 deletions(-) + +diff --git a/lib/path.c b/lib/path.c +index 0d357966f3..8a2b882fe4 100644 +--- a/lib/path.c ++++ b/lib/path.c +@@ -344,7 +344,7 @@ int ul_path_stat(struct path_cxt *pc, struct stat *sb, int flags, const char *pa + int rc; + + if (!pc) { +- rc = stat(path, sb); ++ rc = path ? stat(path, sb) : -EINVAL; + DBG(CXT, ul_debug("stat '%s' [no context, rc=%d]", path, rc)); + } else { + int dir = ul_path_get_dirfd(pc); +@@ -359,6 +359,7 @@ int ul_path_stat(struct path_cxt *pc, struct stat *sb, int flags, const char *pa + rc = fstat(dir, sb); /* dir itself */ + + if (rc && errno == ENOENT ++ && path + && pc->redirect_on_enoent + && pc->redirect_on_enoent(pc, path, &dir) == 0) + rc = fstatat(dir, path, sb, 0); +@@ -372,6 +373,8 @@ int ul_path_open(struct path_cxt *pc, int flags, const char *path) + { + int fd; + ++ if (!path) ++ return -EINVAL; + if (!pc) { + fd = open(path, flags); + DBG(CXT, ul_debug("opening '%s' [no context]", path)); +diff --git a/lib/sysfs.c b/lib/sysfs.c +index d8206be7ab..84af4fe3cb 100644 +--- a/lib/sysfs.c ++++ b/lib/sysfs.c +@@ -165,7 +165,7 @@ static int sysfs_blkdev_enoent_redirect(struct path_cxt *pc, const char *path, i + { + struct sysfs_blkdev *blk = ul_path_get_dialect(pc); + +- if (blk && blk->parent && strncmp(path, "queue/", 6) == 0) { ++ if (blk && blk->parent && path && strncmp(path, "queue/", 6) == 0) { + *dirfd = ul_path_get_dirfd(blk->parent); + if (*dirfd >= 0) { + DBG(CXT, ul_debugobj(pc, "%s redirected to parent", path)); diff --git a/backport-lib-strutils-improve-strtoul_or_err-for-negative-numbers.patch b/backport-lib-strutils-improve-strtoul_or_err-for-negative-numbers.patch new file mode 100644 index 0000000..e0c65ce --- /dev/null +++ b/backport-lib-strutils-improve-strtoul_or_err-for-negative-numbers.patch @@ -0,0 +1,90 @@ +From 3b888573661d43ea069e98a083bd10e33a2ece69 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 19 Apr 2022 11:38:57 +0200 +Subject: [PATCH] lib/strutils: improve strtoul_or_err() for negative numbers + +Let's use the same code for strtoul_or_err() and strtol_or_err() as we +already use for strtoxXX_or_err() functions. It resolves issue with +negative numbers. + +This problem has been discovered by "./eject -x -1 -v" where -x is +based on strtoul_or_err(), but accepts negative number (-1). + +Reported-by: Enze Li +Signed-off-by: Karel Zak +--- + include/strutils.h | 4 ++-- + lib/strutils.c | 42 ------------------------------------------ + 2 files changed, 2 insertions(+), 44 deletions(-) + +diff --git a/include/strutils.h b/include/strutils.h +index a84d295..2849ef3 100644 +--- a/include/strutils.h ++++ b/include/strutils.h +@@ -42,8 +42,8 @@ extern uint64_t str2unum_or_err(const char *str, int base, const char *errmesg, + extern double strtod_or_err(const char *str, const char *errmesg); + extern long double strtold_or_err(const char *str, const char *errmesg); + +-extern long strtol_or_err(const char *str, const char *errmesg); +-extern unsigned long strtoul_or_err(const char *str, const char *errmesg); ++#define strtol_or_err(_s, _e) (long) str2num_or_err(_s, 10, _e, LONG_MIN, LONG_MAX) ++#define strtoul_or_err(_s, _e) (unsigned long) str2unum_or_err(_s, 10, _e, ULONG_MAX) + + extern void strtotimeval_or_err(const char *str, struct timeval *tv, + const char *errmesg); +diff --git a/lib/strutils.c b/lib/strutils.c +index 096aaf5..4117e03 100644 +--- a/lib/strutils.c ++++ b/lib/strutils.c +@@ -471,48 +471,6 @@ err: + errx(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str); + } + +-long strtol_or_err(const char *str, const char *errmesg) +-{ +- long num; +- char *end = NULL; +- +- errno = 0; +- if (str == NULL || *str == '\0') +- goto err; +- num = strtol(str, &end, 10); +- +- if (errno || str == end || (end && *end)) +- goto err; +- +- return num; +-err: +- if (errno == ERANGE) +- err(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str); +- +- errx(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str); +-} +- +-unsigned long strtoul_or_err(const char *str, const char *errmesg) +-{ +- unsigned long num; +- char *end = NULL; +- +- errno = 0; +- if (str == NULL || *str == '\0') +- goto err; +- num = strtoul(str, &end, 10); +- +- if (errno || str == end || (end && *end)) +- goto err; +- +- return num; +-err: +- if (errno == ERANGE) +- err(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str); +- +- errx(STRTOXX_EXIT_CODE, "%s: '%s'", errmesg, str); +-} +- + uintmax_t strtosize_or_err(const char *str, const char *errmesg) + { + uintmax_t num; +-- +2.27.0 + diff --git a/backport-libblkid-don-t-mark-cache-as-probed-if-sys-not-available.patch b/backport-libblkid-don-t-mark-cache-as-probed-if-sys-not-available.patch new file mode 100644 index 0000000..18757c5 --- /dev/null +++ b/backport-libblkid-don-t-mark-cache-as-probed-if-sys-not-available.patch @@ -0,0 +1,140 @@ +From 84d38ae3eca523ef990cb848563cc63de25266e6 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Fri, 19 Nov 2021 14:19:03 +0100 +Subject: [PATCH] libblkid: don't mark cache as "probed" if /sys not available + +For "mount --all" we need to read the cache more than once in a short +time. The library checks the delay between probes, and if the delay is +too short, it does not read devices. This is a problem on boot when there +are no /sys, and the cache is empty. In this case, we need to check +for /sys until it's available constantly. + +https://github.com/util-linux/util-linux/issues/1492 +Signed-off-by: Karel Zak +--- + libblkid/src/devname.c | 26 +++++++++++++++++--------- + libblkid/src/resolve.c | 2 +- + libblkid/src/tag.c | 8 +++++--- + 3 files changed, 23 insertions(+), 13 deletions(-) + +diff --git a/libblkid/src/devname.c b/libblkid/src/devname.c +index c541d30..80574f3 100644 +--- a/libblkid/src/devname.c ++++ b/libblkid/src/devname.c +@@ -456,6 +456,8 @@ sysfs_probe_all(blkid_cache cache, int only_if_new, int only_removable) + if (!sysfs) + return -BLKID_ERR_SYSFS; + ++ DBG(DEVNAME, ul_debug(" probe /sys/block")); ++ + /* scan /sys/block */ + while ((dev = xreaddir(sysfs))) { + DIR *dir = NULL; +@@ -560,14 +562,18 @@ sysfs_probe_all(blkid_cache cache, int only_if_new, int only_removable) + /* + * Read the device data for all available block devices in the system. + */ +-static int probe_all(blkid_cache cache, int only_if_new) ++static int probe_all(blkid_cache cache, int only_if_new, int update_interval) + { ++ int rc; ++ + if (!cache) + return -BLKID_ERR_PARAM; + + if (cache->bic_flags & BLKID_BIC_FL_PROBED && +- time(NULL) - cache->bic_time < BLKID_PROBE_INTERVAL) ++ time(NULL) - cache->bic_time < BLKID_PROBE_INTERVAL) { ++ DBG(PROBE, ul_debug("don't re-probe [delay < %d]", BLKID_PROBE_INTERVAL)); + return 0; ++ } + + blkid_read_cache(cache); + +@@ -577,7 +583,13 @@ static int probe_all(blkid_cache cache, int only_if_new) + #endif + ubi_probe_all(cache, only_if_new); + +- sysfs_probe_all(cache, only_if_new, 0); ++ rc = sysfs_probe_all(cache, only_if_new, 0); ++ ++ /* Don't mark the change as "probed" if /sys not avalable */ ++ if (update_interval && rc == 0) { ++ cache->bic_time = time(NULL); ++ cache->bic_flags |= BLKID_BIC_FL_PROBED; ++ } + + blkid_flush_cache(cache); + return 0; +@@ -596,11 +608,7 @@ int blkid_probe_all(blkid_cache cache) + int ret; + + DBG(PROBE, ul_debug("Begin blkid_probe_all()")); +- ret = probe_all(cache, 0); +- if (ret == 0) { +- cache->bic_time = time(NULL); +- cache->bic_flags |= BLKID_BIC_FL_PROBED; +- } ++ ret = probe_all(cache, 0, 1); + DBG(PROBE, ul_debug("End blkid_probe_all() [rc=%d]", ret)); + return ret; + } +@@ -618,7 +626,7 @@ int blkid_probe_all_new(blkid_cache cache) + int ret; + + DBG(PROBE, ul_debug("Begin blkid_probe_all_new()")); +- ret = probe_all(cache, 1); ++ ret = probe_all(cache, 1, 0); + DBG(PROBE, ul_debug("End blkid_probe_all_new() [rc=%d]", ret)); + return ret; + } +diff --git a/libblkid/src/resolve.c b/libblkid/src/resolve.c +index 641b022..16653fa 100644 +--- a/libblkid/src/resolve.c ++++ b/libblkid/src/resolve.c +@@ -32,7 +32,7 @@ char *blkid_get_tag_value(blkid_cache cache, const char *tagname, + blkid_cache c = cache; + char *ret = NULL; + +- DBG(TAG, ul_debug("looking for %s on %s", tagname, devname)); ++ DBG(TAG, ul_debug("looking for tag %s on %s device", tagname, devname)); + + if (!devname) + return NULL; +diff --git a/libblkid/src/tag.c b/libblkid/src/tag.c +index 390a648..1783365 100644 +--- a/libblkid/src/tag.c ++++ b/libblkid/src/tag.c +@@ -326,14 +326,14 @@ blkid_dev blkid_find_dev_with_tag(blkid_cache cache, + blkid_dev dev; + int pri; + struct list_head *p; +- int probe_new = 0; ++ int probe_new = 0, probe_all = 0; + + if (!cache || !type || !value) + return NULL; + + blkid_read_cache(cache); + +- DBG(TAG, ul_debug("looking for %s=%s in cache", type, value)); ++ DBG(TAG, ul_debug("looking for tag %s=%s in cache", type, value)); + + try_again: + pri = -1; +@@ -366,9 +366,11 @@ try_again: + goto try_again; + } + +- if (!dev && !(cache->bic_flags & BLKID_BIC_FL_PROBED)) { ++ if (!dev && !probe_all ++ && !(cache->bic_flags & BLKID_BIC_FL_PROBED)) { + if (blkid_probe_all(cache) < 0) + return NULL; ++ probe_all++; + goto try_again; + } + return dev; +-- +2.27.0 + diff --git a/backport-libblkid-hfs-fix-make-sure-buffer-is-large-enough.patch b/backport-libblkid-hfs-fix-make-sure-buffer-is-large-enough.patch new file mode 100644 index 0000000..fa07ef8 --- /dev/null +++ b/backport-libblkid-hfs-fix-make-sure-buffer-is-large-enough.patch @@ -0,0 +1,24 @@ +From 7ebfe9b411c12223a2500ca62d6be37c48e2d83d Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 2 Jun 2022 16:02:54 +0200 +Subject: [PATCH] libblkid: (hfs) fix make sure buffer is large enough + +Signed-off-by: Karel Zak +--- + libblkid/src/superblocks/ntfs.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/libblkid/src/superblocks/ntfs.c b/libblkid/src/superblocks/ntfs.c +index 9f1927cf74..b5799c3e33 100644 +--- a/libblkid/src/superblocks/ntfs.c ++++ b/libblkid/src/superblocks/ntfs.c +@@ -158,6 +158,9 @@ static int __probe_ntfs(blkid_probe pr, const struct blkid_idmag *mag, int save_ + sectors_per_cluster, nr_clusters, + off)); + ++ if (mft_record_size < 4) ++ return 1; ++ + buf_mft = blkid_probe_get_buffer(pr, off, mft_record_size); + if (!buf_mft) + return errno ? -errno : 1; diff --git a/backport-libblkid-make-blkid_free_probe-more-robust.patch b/backport-libblkid-make-blkid_free_probe-more-robust.patch new file mode 100644 index 0000000..77daf12 --- /dev/null +++ b/backport-libblkid-make-blkid_free_probe-more-robust.patch @@ -0,0 +1,22 @@ +From 5caa4117b40ea9babf4aee6e8786fb70507ee1b8 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 17 Mar 2022 12:41:48 +0100 +Subject: [PATCH] libblkid: make blkid_free_probe() more robust + +Signed-off-by: Karel Zak +--- + libblkid/src/probe.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c +index 2e0e08ac1d..31706240fc 100644 +--- a/libblkid/src/probe.c ++++ b/libblkid/src/probe.c +@@ -251,6 +251,7 @@ void blkid_free_probe(blkid_probe pr) + if (ch->driver->free_data) + ch->driver->free_data(pr, ch->data); + free(ch->fltr); ++ ch->fltr = NULL; + } + + if ((pr->flags & BLKID_FL_PRIVATE_FD) && pr->fd >= 0) diff --git a/backport-libmount-all-continue-although-proc-is-not-mounted.patch b/backport-libmount-all-continue-although-proc-is-not-mounted.patch new file mode 100644 index 0000000..501681e --- /dev/null +++ b/backport-libmount-all-continue-although-proc-is-not-mounted.patch @@ -0,0 +1,113 @@ +From b8f2fce2a20944cd8b1a7e91dfa04f9725ec3eb8 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 18 Nov 2021 11:47:08 +0100 +Subject: [PATCH] libmount: (--all) continue although /proc is not mounted + +Now 'mount --all' ends with error if /proc is not mounted and there is +some other entry before /proc in fstab. This commit improves this +situation and ignores all mount table related errors if the table is +empty. + +This is important for situation when there is for example "/" as the +first line in fstab. + +Addresses: https://github.com/util-linux/util-linux/issues/1492 +Signed-off-by: Karel Zak +--- + libmount/src/context.c | 25 +++++++++++++++++-------- + libmount/src/context_mount.c | 9 ++++++++- + sys-utils/mount.8.adoc | 2 ++ + 3 files changed, 27 insertions(+), 9 deletions(-) + +diff --git a/libmount/src/context.c b/libmount/src/context.c +index 3b32224..bd215c0 100644 +--- a/libmount/src/context.c ++++ b/libmount/src/context.c +@@ -1298,6 +1298,16 @@ int mnt_context_get_mtab(struct libmnt_context *cxt, struct libmnt_table **tb) + cxt->table_fltrcb_data); + + mnt_table_set_cache(cxt->mtab, mnt_context_get_cache(cxt)); ++ } ++ ++ /* Read the table; it's empty, because this first mnt_context_get_mtab() ++ * call, or because /proc was not accessible in previous calls */ ++ if (mnt_table_is_empty(cxt->mtab)) { ++ if (!ns_old) { ++ ns_old = mnt_context_switch_target_ns(cxt); ++ if (!ns_old) ++ return -MNT_ERR_NAMESPACE; ++ } + + /* + * Note that mtab_path is NULL if mtab is useless or unsupported +@@ -2874,7 +2884,7 @@ int mnt_context_is_fs_mounted(struct libmnt_context *cxt, + struct libmnt_fs *fs, int *mounted) + { + struct libmnt_table *mtab, *orig; +- int rc; ++ int rc = 0; + struct libmnt_ns *ns_old; + + if (!cxt || !fs || !mounted) +@@ -2893,18 +2903,17 @@ int mnt_context_is_fs_mounted(struct libmnt_context *cxt, + cxt->mtab = NULL; + } + *mounted = 0; +- return 0; /* /proc not mounted */ +- } ++ rc = 0; /* /proc not mounted */ + +- if (rc) +- return rc; +- +- *mounted = __mnt_table_is_fs_mounted(mtab, fs, ++ } else if (rc == 0) { ++ *mounted = __mnt_table_is_fs_mounted(mtab, fs, + mnt_context_get_target_prefix(cxt)); + ++ } ++ + if (!mnt_context_switch_ns(cxt, ns_old)) + return -MNT_ERR_NAMESPACE; +- return 0; ++ return rc; + } + + static int mnt_context_add_child(struct libmnt_context *cxt, pid_t pid) +diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c +index 55ebf79..f9bedd2 100644 +--- a/libmount/src/context_mount.c ++++ b/libmount/src/context_mount.c +@@ -1397,8 +1397,15 @@ int mnt_context_next_mount(struct libmnt_context *cxt, + + /* ignore already mounted filesystems */ + rc = mnt_context_is_fs_mounted(cxt, *fs, &mounted); +- if (rc) ++ if (rc) { ++ if (mnt_table_is_empty(cxt->mtab)) { ++ DBG(CXT, ul_debugobj(cxt, "next-mount: no mount table [rc=%d], ignore", rc)); ++ rc = 0; ++ if (ignored) ++ *ignored = 1; ++ } + return rc; ++ } + if (mounted) { + if (ignored) + *ignored = 2; +diff --git a/sys-utils/mount.8.adoc b/sys-utils/mount.8.adoc +index 6e72d48..e8f0c36 100644 +--- a/sys-utils/mount.8.adoc ++++ b/sys-utils/mount.8.adoc +@@ -301,6 +301,8 @@ Command-line options available for the *mount* command are: + *-a*, *--all*:: + Mount all filesystems (of the given types) mentioned in _fstab_ (except for those whose line contains the *noauto* keyword). The filesystems are mounted following their order in _fstab_. The *mount* command compares filesystem source, target (and fs root for bind mount or btrfs) to detect already mounted filesystems. The kernel table with already mounted filesystems is cached during *mount --all*. This means that all duplicated _fstab_ entries will be mounted. + + ++The correct functionality depends on /proc (to detect already mounted filesystems) and on /sys (to evaluate filesystem tags like UUID= or LABEL=). It's strongly recommended to mount /proc and /sys filesystems before *mount -a* is executed, or keep /proc and /sys at the beginning of fstab. +++ + The option *--all* is possible to use for remount operation too. In this case all filters (*-t* and *-O*) are applied to the table of already mounted filesystems. + + + Since version 2.35 is possible to use the command line option *-o* to alter mount options from _fstab_ (see also *--options-mode*). +-- +2.27.0 + diff --git a/backport-loopdev-set-block_size-when-using-LOOP_CONFIGURE.patch b/backport-loopdev-set-block_size-when-using-LOOP_CONFIGURE.patch new file mode 100644 index 0000000..16ca38c --- /dev/null +++ b/backport-loopdev-set-block_size-when-using-LOOP_CONFIGURE.patch @@ -0,0 +1,46 @@ +From 854abba0dd9b45b4f40a9c934694b3f14052eceb Mon Sep 17 00:00:00 2001 +From: Hideki EIRAKU +Date: Wed, 25 May 2022 12:23:16 +0900 +Subject: [PATCH] loopdev: set block_size when using LOOP_CONFIGURE + +LOOP_CONFIGURE ioctl was introduced by commit +d5fd456c88aba4fcf77d35fe38024a8d5c814686. Since the previous +implementation set partscan flag but did not set block_size with the +LOOP_CONFIGURE ioctl, an issue fixed by commit +422f0e9f206a145c59a71333dad20d38cbbfc0c4 was reappeared. Setting +block_size in the LOOP_CONFIGURE ioctl parameter fixes the issue. + +Signed-off-by: Hideki EIRAKU +--- + lib/loopdev.c | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +diff --git a/lib/loopdev.c b/lib/loopdev.c +index d9ea1d4..0afe300 100644 +--- a/lib/loopdev.c ++++ b/lib/loopdev.c +@@ -1357,6 +1357,9 @@ int loopcxt_setup_device(struct loopdev_cxt *lc) + * -- since Linux v5.8-rc1, commit 3448914e8cc550ba792d4ccc74471d1ca4293aae + */ + lc->config.fd = file_fd; ++ if (lc->blocksize > 0) ++ lc->config.block_size = lc->blocksize; ++ + if (ioctl(dev_fd, LOOP_CONFIGURE, &lc->config) < 0) { + rc = -errno; + errsv = errno; +@@ -1366,11 +1369,6 @@ int loopcxt_setup_device(struct loopdev_cxt *lc) + } + fallback = 1; + } else { +- if (lc->blocksize > 0 +- && (rc = loopcxt_ioctl_blocksize(lc, lc->blocksize)) < 0) { +- errsv = -rc; +- goto err; +- } + DBG(SETUP, ul_debugobj(lc, "LOOP_CONFIGURE: OK")); + } + +-- +2.27.0 + diff --git a/backport-lslocks-fix-maj-min-scanf.patch b/backport-lslocks-fix-maj-min-scanf.patch new file mode 100644 index 0000000..53d3814 --- /dev/null +++ b/backport-lslocks-fix-maj-min-scanf.patch @@ -0,0 +1,28 @@ +From 9b725af7028163bd29d39da3b910dffc903107ee Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 28 Mar 2022 11:39:27 +0200 +Subject: [PATCH] lslocks: fix maj:min scanf + +Fixes: https://github.com/util-linux/util-linux/issues/1633 +Signed-off-by: Karel Zak +--- + misc-utils/lslocks.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/misc-utils/lslocks.c b/misc-utils/lslocks.c +index 941ef7f..6427318 100644 +--- a/misc-utils/lslocks.c ++++ b/misc-utils/lslocks.c +@@ -224,7 +224,8 @@ static ino_t get_dev_inode(char *str, dev_t *dev) + unsigned int maj = 0, min = 0; + ino_t inum = 0; + +- sscanf(str, "%02x:%02x:%ju", &maj, &min, &inum); ++ if (sscanf(str, "%x:%x:%ju", &maj, &min, &inum) != 3) ++ errx(EXIT_FAILURE, _("failed to parse '%s'"), str); + + *dev = (dev_t) makedev(maj, min); + return inum; +-- +2.27.0 + diff --git a/backport-lslogins-fix-free-invalid-pointer.patch b/backport-lslogins-fix-free-invalid-pointer.patch new file mode 100644 index 0000000..c91dff3 --- /dev/null +++ b/backport-lslogins-fix-free-invalid-pointer.patch @@ -0,0 +1,33 @@ +From 890d4d3f236e2d28db35ea9bc9dc3e5e35db975c Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 7 Jun 2022 09:46:54 +0200 +Subject: [PATCH] lslogins: fix free(): invalid pointer + +Signed-off-by: Karel Zak +--- + login-utils/lslogins.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c +index 3646883e0e..3cb30b74e2 100644 +--- a/login-utils/lslogins.c ++++ b/login-utils/lslogins.c +@@ -490,7 +490,7 @@ static int parse_utmpx(const char *path, size_t *nrecords, struct utmpx **record + + /* optimize allocation according to file size, the realloc() below is + * just fallback only */ +- if (stat(path, &st) == 0 && (size_t) st.st_size > sizeof(struct utmpx)) { ++ if (stat(path, &st) == 0 && (size_t) st.st_size >= sizeof(struct utmpx)) { + imax = st.st_size / sizeof(struct utmpx); + ary = xmalloc(imax * sizeof(struct utmpx)); + } +@@ -1013,6 +1013,9 @@ static void free_ctl(struct lslogins_control *ctl) + { + size_t n = 0; + ++ if (!ctl) ++ return; ++ + free(ctl->wtmp); + free(ctl->btmp); + diff --git a/backport-script-fix-passing-args-to-execlp.patch b/backport-script-fix-passing-args-to-execlp.patch new file mode 100644 index 0000000..ab1dfd6 --- /dev/null +++ b/backport-script-fix-passing-args-to-execlp.patch @@ -0,0 +1,34 @@ +From 521eb0571eef9352c99d8e401fc8d73d626014cf Mon Sep 17 00:00:00 2001 +From: Jakub Wilk +Date: Tue, 1 Mar 2022 17:15:45 +0100 +Subject: [PATCH] script: fix passing args to execlp() + +Fixes: + + $ SHELL=bash script -q -c 'echo Hello world' + -c: echo Hello world: No such file or directory + +Signed-off-by: Jakub Wilk +--- + term-utils/script.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/term-utils/script.c b/term-utils/script.c +index c8b55c8..89bd0ed 100644 +--- a/term-utils/script.c ++++ b/term-utils/script.c +@@ -975,9 +975,9 @@ int main(int argc, char **argv) + execl(shell, shname, "-i", (char *)NULL); + } else { + if (command) +- execlp(shname, "-c", command, (char *)NULL); ++ execlp(shname, shname, "-c", command, (char *)NULL); + else +- execlp(shname, "-i", (char *)NULL); ++ execlp(shname, shname, "-i", (char *)NULL); + } + + err(EXIT_FAILURE, "failed to execute %s", shell); +-- +2.27.0 + diff --git a/backport-scriptlive-fix-argv-0-for-execlp.patch b/backport-scriptlive-fix-argv-0-for-execlp.patch new file mode 100644 index 0000000..b31ecee --- /dev/null +++ b/backport-scriptlive-fix-argv-0-for-execlp.patch @@ -0,0 +1,26 @@ +From 65856a0deb7200b78f858ba7dc66077f3469e924 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 2 Mar 2022 10:00:46 +0100 +Subject: [PATCH] scriptlive: fix argv[0] for execlp() + +Signed-off-by: Karel Zak +--- + term-utils/scriptlive.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/term-utils/scriptlive.c b/term-utils/scriptlive.c +index 37f092c1ff..d81712d36f 100644 +--- a/term-utils/scriptlive.c ++++ b/term-utils/scriptlive.c +@@ -321,9 +321,9 @@ main(int argc, char *argv[]) + execl(shell, shname, "-i", (char *)NULL); + } else { + if (command) +- execlp(shname, "-c", command, (char *)NULL); ++ execlp(shname, shname, "-c", command, (char *)NULL); + else +- execlp(shname, "-i", (char *)NULL); ++ execlp(shname, shname, "-i", (char *)NULL); + } + err(EXIT_FAILURE, "failed to execute %s", shell); + break; diff --git a/backport-sysfs-fallback-for-partitions-not-including-parent-name.patch b/backport-sysfs-fallback-for-partitions-not-including-parent-name.patch new file mode 100644 index 0000000..adb123a --- /dev/null +++ b/backport-sysfs-fallback-for-partitions-not-including-parent-name.patch @@ -0,0 +1,45 @@ +From 9b59641bcec3df9c451eea4c7057751a153a3fcb Mon Sep 17 00:00:00 2001 +From: Portisch +Date: Mon, 8 Nov 2021 12:31:39 +0100 +Subject: [PATCH] sysfs: fallback for partitions not including parent name + +--- + lib/sysfs.c | 12 +++++++----- + 1 file changed, 7 insertions(+), 5 deletions(-) + +diff --git a/lib/sysfs.c b/lib/sysfs.c +index bb71833193..191d870f66 100644 +--- a/lib/sysfs.c ++++ b/lib/sysfs.c +@@ -210,9 +210,10 @@ int sysfs_blkdev_is_partition_dirent(DIR *dir, struct dirent *d, const char *par + d->d_type != DT_UNKNOWN) + return 0; + #endif ++ size_t len = 0; ++ + if (parent_name) { + const char *p = parent_name; +- size_t len; + + /* /dev/sda --> "sda" */ + if (*parent_name == '/') { +@@ -223,14 +224,15 @@ int sysfs_blkdev_is_partition_dirent(DIR *dir, struct dirent *d, const char *par + } + + len = strlen(p); +- if (strlen(d->d_name) <= len) +- return 0; ++ if ((strlen(d->d_name) <= len) || (strncmp(p, d->d_name, len) != 0)) ++ len = 0; ++ } + ++ if (len > 0) { + /* partitions subdir name is + * "[:digit:]" or "p[:digit:]" + */ +- return strncmp(p, d->d_name, len) == 0 && +- ((*(d->d_name + len) == 'p' && isdigit(*(d->d_name + len + 1))) ++ return ((*(d->d_name + len) == 'p' && isdigit(*(d->d_name + len + 1))) + || isdigit(*(d->d_name + len))); + } + diff --git a/util-linux.spec b/util-linux.spec index d033fbb..a8a0c3d 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -3,7 +3,7 @@ Name: util-linux Version: 2.37.2 -Release: 17 +Release: 18 Summary: A random collection of Linux utilities License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain URL: https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git @@ -25,54 +25,74 @@ Patch6003: realloc-buffer-when-header-size-changed.patch Patch6004: fix-size-use-for-stdin.patch Patch6005: segmentation-fault-on-invalid-unicode-input-passed-to-s-option.patch Patch6006: backport-fix-by-ignoring-EINVAL-on-remount-of-proc.patch -Patch6007: backport-su-bash-completion-offer-usernames-rather-than-files.patch -Patch6008: backport-Fix-memory-leaks-in-the-chcpu.patch -Patch6009: backport-logger-fix-prio-prefix-doesn-t-use-priority-default.patch -Patch6010: backport-vipw-flush-stdout-before-getting-answer.patch -Patch6011: backport-login-Restore-tty-size-after-calling-vhangup.patch -Patch6012: backport-Forward-value-of-sector_size-instead-of-its-address.patch -Patch6013: backport-libfdisk-dereference-of-possibly-NULL-gcc-analyzer.patch -Patch6014: backport-libfdisk-check-calloc-return-gcc-analyzer.patch -Patch6015: backport-mcookie-fix-infinite-loop-when-use-f.patch -Patch6016: backport-sfdisk-write-empty-label-also-when-only-ignored-part.patch -Patch6017: backport-fstat-dir-itself.patch -Patch6018: backport-libblkid-src-topology-dm-close-redundant-write-file-.patch -Patch6019: backport-libblkid-topology-init-variables-for-DM.patch -Patch6020: backport-sfdisk-fix-typo-in-move-data-when-check-partition-size.patch -Patch6021: backport-losetup-fix-memory-leak-asan.patch -Patch6022: backport-partx-remove-memory-leak-to-make-scanners-happy-coverity-scan.patch -Patch6023: backport-lib-path-make-ul_path_read_buffer-more-robust-coverity-scan.patch -Patch6024: backport-libmount-fix-possible-memory-leak-in-mnt_optstr_fix_secontext-coverity-scan.patch -Patch6025: backport-libblkid-probe-fix-size-and-offset-overflows-fuzzing.patch -Patch6026: backport-lslogins-improve-prefixes-interpretation.patch -Patch6027: backport-lsns-fix-the-memory-leak.patch -Patch6028: backport-libblkid-check-fsync-return-code.patch -Patch6029: backport-libblkid-mac-make-sure-block-size-is-large-enough-fuzzing.patch -Patch6030: backport-libblkid-bsd-fix-buffer-pointer-use-fuzzing.patch -Patch6031: backport-libblkid-hfs-fix-label-use-fuzzing.patch -Patch6032: backport-Maybe-there-is-a-little-mistake-in-do_taskset-functi.patch -Patch6033: backport-lsblk-fix-endless-loop-if-device-specified-more-than-once.patch -Patch6034: backport-libblkid-avoid-buffer-overflow-in-ocfs-superblock-parsing.patch -Patch6035: backport-fsck-Processes-may-kill-other-processes.patch -Patch6036: backport-fdisk-fix-output-option-parsing.patch -Patch6037: backport-libblkid-exfat-fix-divide-by-zero-coverity-scan.patch -Patch6038: backport-llib-pty-session-split-PTY-and-signalfd-setup.patch -Patch6039: backport-script-fix-use-of-utempter.patch -Patch6040: backport-logger-always-update-header-when-read-from-stdin.patch -Patch6041: backport-libblkid-use-checksum-for-jmicron.patch -Patch6042: backport-libblkid-cleanup-indentation.patch -Patch6043: backport-libblkid-fix-jmicron-checksum-and-LE-to-CPU.patch -Patch6044: backport-libblkid-fix-misaligned-address-in-probe_exfat.patch -Patch6045: backport-ldattach-fix-intro-command-and-pause.patch -Patch6046: backport-iso9660.h-use-more-correct-function-types.patch -Patch6047: backport-iso9660.h-avoid-undefined-signed-integer-shift.patch -Patch6048: backport-ipc_msg_get_limits-always-initialize-memory.patch -Patch6049: backport-wdctl-mark-flags-field-as-unsigned-long.patch -Patch6050: backport-login-never-send-signals-to-init.patch -Patch6051: backport-mkswap-do-not-use-uninitialized-stack-value.patch -Patch6052: backport-lib-pager-fix-signal-safety-issues.patch -Patch6053: backport-libblkid-nvidia_raid-verify-superblock-size.patch -Patch6054: backport-libblkid-nvidia_raid-validate-checksum.patch +Patch6007: backport-flush-stdout-before-reading-stdin-and-fix-uninitialized-variable.patch +Patch6008: backport-fflush-stdout-before-reading-from-stdin.patch +Patch6009: backport-CVE-2022-0563.patch +Patch6010: backport-su-bash-completion-offer-usernames-rather-than-files.patch +Patch6011: backport-Fix-memory-leaks-in-the-chcpu.patch +Patch6012: backport-logger-fix-prio-prefix-doesn-t-use-priority-default.patch +Patch6013: backport-vipw-flush-stdout-before-getting-answer.patch +Patch6014: backport-login-Restore-tty-size-after-calling-vhangup.patch +Patch6015: backport-Forward-value-of-sector_size-instead-of-its-address.patch +Patch6016: backport-libfdisk-dereference-of-possibly-NULL-gcc-analyzer.patch +Patch6017: backport-libfdisk-check-calloc-return-gcc-analyzer.patch +Patch6018: backport-mcookie-fix-infinite-loop-when-use-f.patch +Patch6019: backport-sfdisk-write-empty-label-also-when-only-ignored-part.patch +Patch6020: backport-fstat-dir-itself.patch +Patch6021: backport-sfdisk-fix-typo-in-move-data-when-check-partition-size.patch +Patch6022: backport-sysfs-fallback-for-partitions-not-including-parent-name.patch +Patch6023: backport-libmount-all-continue-although-proc-is-not-mounted.patch +Patch6024: backport-libblkid-don-t-mark-cache-as-probed-if-sys-not-available.patch +Patch6025: backport-lib-path-make-path-use-more-robust-coverity-scan.patch +Patch6026: backport-Fix-integer-overflow-for-alpha-like-linux.patch +Patch6027: backport-last-don-t-assume-zero-terminate-strings.patch +Patch6028: backport-script-fix-passing-args-to-execlp.patch +Patch6029: backport-scriptlive-fix-argv-0-for-execlp.patch +Patch6030: backport-losetup-fix-memory-leak-asan.patch +Patch6031: backport-partx-remove-memory-leak-to-make-scanners-happy-coverity-scan.patch +Patch6032: backport-lib-path-make-ul_path_read_buffer-more-robust-coverity-scan.patch +Patch6033: backport-libblkid-make-blkid_free_probe-more-robust.patch +Patch6034: backport-libmount-fix-possible-memory-leak-in-mnt_optstr_fix_secontext-coverity-scan.patch +Patch6035: backport-lslocks-fix-maj-min-scanf.patch +Patch6036: backport-column-don-t-require-column-name-for-JSON.patch +Patch6037: backport-libblkid-check-fsync-return-code.patch +Patch6038: backport-lib-strutils-improve-strtoul_or_err-for-negative-numbers.patch +Patch6039: backport-dmesg-fix-since-and-until.patch +Patch6040: backport-lib-allow-safe_getenv-to-work-for-non-root-users.patch +Patch6041: backport-Maybe-there-is-a-little-mistake-in-do_taskset-functi.patch +Patch6042: backport-loopdev-set-block_size-when-using-LOOP_CONFIGURE.patch +Patch6043: backport-libblkid-probe-fix-size-and-offset-overflows-fuzzing.patch +Patch6044: backport-libblkid-bsd-fix-buffer-pointer-use-fuzzing.patch +Patch6045: backport-libblkid-mac-make-sure-block-size-is-large-enough-fuzzing.patch +Patch6046: backport-libblkid-hfs-fix-label-use-fuzzing.patch +Patch6047: backport-libblkid-hfs-fix-make-sure-buffer-is-large-enough.patch +Patch6048: backport-lslogins-fix-free-invalid-pointer.patch +Patch6049: backport-lsns-fix-the-memory-leak.patch +Patch6050: backport-libblkid-src-topology-dm-close-redundant-write-file-.patch +Patch6051: backport-libblkid-topology-init-variables-for-DM.patch +Patch6052: backport-lslogins-improve-prefixes-interpretation.patch +Patch6053: backport-lsblk-fix-endless-loop-if-device-specified-more-than-once.patch +Patch6054: backport-libblkid-avoid-buffer-overflow-in-ocfs-superblock-parsing.patch +Patch6055: backport-fsck-Processes-may-kill-other-processes.patch +Patch6056: backport-fdisk-fix-output-option-parsing.patch +Patch6057: backport-libblkid-exfat-fix-divide-by-zero-coverity-scan.patch +Patch6058: backport-llib-pty-session-split-PTY-and-signalfd-setup.patch +Patch6059: backport-script-fix-use-of-utempter.patch +Patch6060: backport-logger-always-update-header-when-read-from-stdin.patch +Patch6061: backport-libblkid-use-checksum-for-jmicron.patch +Patch6062: backport-libblkid-cleanup-indentation.patch +Patch6063: backport-libblkid-fix-jmicron-checksum-and-LE-to-CPU.patch +Patch6064: backport-libblkid-fix-misaligned-address-in-probe_exfat.patch +Patch6065: backport-ldattach-fix-intro-command-and-pause.patch +Patch6066: backport-iso9660.h-use-more-correct-function-types.patch +Patch6067: backport-iso9660.h-avoid-undefined-signed-integer-shift.patch +Patch6068: backport-ipc_msg_get_limits-always-initialize-memory.patch +Patch6069: backport-wdctl-mark-flags-field-as-unsigned-long.patch +Patch6070: backport-login-never-send-signals-to-init.patch +Patch6071: backport-mkswap-do-not-use-uninitialized-stack-value.patch +Patch6072: backport-lib-pager-fix-signal-safety-issues.patch +Patch6073: backport-libblkid-nvidia_raid-verify-superblock-size.patch +Patch6074: backport-libblkid-nvidia_raid-validate-checksum.patch Patch9000: Add-check-to-resolve-uname26-version-test-failed.patch Patch9001: SKIPPED-no-root-permissions-test.patch @@ -81,7 +101,7 @@ Patch9002: util-linux-Add-sw64-architecture.patch %endif BuildRequires: audit-libs-devel >= 1.0.6 gettext-devel libselinux-devel ncurses-devel pam-devel zlib-devel popt-devel -BuildRequires: libutempter-devel systemd-devel systemd libuser-devel libcap-ng-devel python3-devel gcc +BuildRequires: libutempter-devel systemd-devel systemd libuser-devel libcap-ng-devel python3-devel gcc autoconf automake Requires(post): coreutils Requires: pam >= 1.1.3-7, /etc/pam.d/system-auth audit-libs >= 1.0.6 @@ -202,6 +222,7 @@ This package contains some doc and man help files for %{name}. %build %define _build_arg0__ CFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 $RPM_OPT_FLAGS" SUID_CFLAGS="-fpie" %define _build_arg1__ SUID_LDFLAGS="-pie -Wl,-z,relro -Wl,-z,now" DAEMON_CFLAGS="$SUID_CFLAGS" DAEMON_LDFLAGS="$SUID_LDFLAGS" +autoreconf unset LINGUAS || : # del support enable-raw https://github.com/torvalds/linux/commit/603e4922f1c81fc2ed3a87b4f91a8d3aafc7e093 @@ -443,6 +464,32 @@ fi %{_mandir}/man8/{swapoff.8*,swapon.8*,switch_root.8*,umount.8*,wdctl.8.gz,wipefs.8*,zramctl.8*} %changelog +* Fri May 12 2023 zhangyao - 2.37.2-18 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:Sync community patches + [add]backport-CVE-2022-0563.patch + backport-Fix-integer-overflow-for-alpha-like-linux.patch + backport-column-don-t-require-column-name-for-JSON.patch + backport-dmesg-fix-since-and-until.patch + backport-fflush-stdout-before-reading-from-stdin.patch + backport-flush-stdout-before-reading-stdin-and-fix-uninitialized-variable.patch + backport-last-don-t-assume-zero-terminate-strings.patch + backport-lib-allow-safe_getenv-to-work-for-non-root-users.patch + backport-lib-path-make-path-use-more-robust-coverity-scan.patch + backport-lib-strutils-improve-strtoul_or_err-for-negative-numbers.patch + backport-libblkid-don-t-mark-cache-as-probed-if-sys-not-available.patch + backport-libblkid-hfs-fix-make-sure-buffer-is-large-enough.patch + backport-libblkid-make-blkid_free_probe-more-robust.patch + backport-libmount-all-continue-although-proc-is-not-mounted.patch + backport-loopdev-set-block_size-when-using-LOOP_CONFIGURE.patch + backport-lslocks-fix-maj-min-scanf.patch + backport-lslogins-fix-free-invalid-pointer.patch + backport-script-fix-passing-args-to-execlp.patch + backport-scriptlive-fix-argv-0-for-execlp.patch + backport-sysfs-fallback-for-partitions-not-including-parent-name.patch + * Thu Mar 16 2023 zhangyao - 2.37.2-17 - Type:bugfix - CVE:NA -- Gitee