diff --git a/backport-fdisk-fix-output-option-parsing.patch b/backport-fdisk-fix-output-option-parsing.patch new file mode 100644 index 0000000000000000000000000000000000000000..ba38c595e338264093c749dc52b1ce642eafcc36 --- /dev/null +++ b/backport-fdisk-fix-output-option-parsing.patch @@ -0,0 +1,28 @@ +From 55ef593842d94d657c8209042491c7590ea3bdf0 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 24 Oct 2022 09:57:07 +0200 +Subject: [PATCH] fdisk: fix --output option parsing + +Fixes: https://github.com/util-linux/util-linux/issues/1859 +Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1022249 +Signed-off-by: Karel Zak +--- + disk-utils/fdisk.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c +index 2bd2ef41b..79b904f25 100644 +--- a/disk-utils/fdisk.c ++++ b/disk-utils/fdisk.c +@@ -928,7 +928,7 @@ int main(int argc, char **argv) + { "type", required_argument, NULL, 't' }, + { "units", optional_argument, NULL, 'u' }, + { "version", no_argument, NULL, 'V' }, +- { "output", no_argument, NULL, 'o' }, ++ { "output", required_argument, NULL, 'o' }, + { "protect-boot", no_argument, NULL, 'B' }, + { "wipe", required_argument, NULL, 'w' }, + { "wipe-partitions",required_argument, NULL, 'W' }, +-- +2.27.0 + diff --git a/backport-fsck-Processes-may-kill-other-processes.patch b/backport-fsck-Processes-may-kill-other-processes.patch new file mode 100644 index 0000000000000000000000000000000000000000..72efa9f1febe4e456a4db5d56b7679264747184d --- /dev/null +++ b/backport-fsck-Processes-may-kill-other-processes.patch @@ -0,0 +1,35 @@ +From 240f2ea95724a2045afebef703f9a7e62326b603 Mon Sep 17 00:00:00 2001 +From: zhanchengbin +Date: Mon, 10 Oct 2022 17:23:24 +0800 +Subject: [PATCH] fsck: Processes may kill other processes. + +A error in disk-utils/fsck.c, if run the fsck -N command, processes +don't execute, just show what would be done. However, the pid whose +value is -1 is added to the instance_list list in the execute +function,if the kill_all function is called later, kill(-1, signum) +is executed, Signals are sent to all processes except the number one +process and itself. Other processes will be killed if they use the +default signal processing function. + +Signed-off-by: zhanchengbin +Reviewed-by: Lukas Czerner +--- + disk-utils/fsck.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c +index 505952c81..800d3ce08 100644 +--- a/disk-utils/fsck.c ++++ b/disk-utils/fsck.c +@@ -730,6 +730,8 @@ static int kill_all(int signum) + for (inst = instance_list; inst; inst = inst->next) { + if (inst->flags & FLAG_DONE) + continue; ++ if (inst->pid <= 0) ++ continue; + kill(inst->pid, signum); + n++; + } +-- +2.27.0 + diff --git a/backport-libblkid-exfat-fix-divide-by-zero-coverity-scan.patch b/backport-libblkid-exfat-fix-divide-by-zero-coverity-scan.patch new file mode 100644 index 0000000000000000000000000000000000000000..61d8a898f190ead95a0ac46f94f19dcff43d6d55 --- /dev/null +++ b/backport-libblkid-exfat-fix-divide-by-zero-coverity-scan.patch @@ -0,0 +1,26 @@ +From 48229f8e7f19c1b61a089fc9ede18d417a895454 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Mon, 24 Oct 2022 10:54:24 +0200 +Subject: [PATCH] libblkid: (exfat) fix divide by zero [coverity scan] + +Signed-off-by: Karel Zak +--- + libblkid/src/superblocks/exfat.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libblkid/src/superblocks/exfat.c b/libblkid/src/superblocks/exfat.c +index 9d1309425..398619477 100644 +--- a/libblkid/src/superblocks/exfat.c ++++ b/libblkid/src/superblocks/exfat.c +@@ -101,7 +101,7 @@ static struct exfat_entry_label *find_label(blkid_probe pr, + return (struct exfat_entry_label *) entry; + + offset += EXFAT_ENTRY_SIZE; +- if (offset % CLUSTER_SIZE(sb) == 0) { ++ if (CLUSTER_SIZE(sb) && (offset % CLUSTER_SIZE(sb)) == 0) { + cluster = next_cluster(pr, sb, cluster); + if (cluster < EXFAT_FIRST_DATA_CLUSTER) + return NULL; +-- +2.27.0 + diff --git a/backport-llib-pty-session-split-PTY-and-signalfd-setup.patch b/backport-llib-pty-session-split-PTY-and-signalfd-setup.patch new file mode 100644 index 0000000000000000000000000000000000000000..d72e64db795ac64b0f9641006f5f94504cdf89f1 --- /dev/null +++ b/backport-llib-pty-session-split-PTY-and-signalfd-setup.patch @@ -0,0 +1,121 @@ +From 4681d88ba1034d488814bbbb6e7d06d17e33322d Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 16 Nov 2022 09:17:52 +0100 +Subject: [PATCH] llib/pty-session: split PTY and signalfd setup + +In some cases applications need to use PTY before signalfd is enabled. + +Signed-off-by: Karel Zak +--- + include/pty-session.h | 1 + + lib/pty-session.c | 29 +++++++++++++++++++++++++---- + login-utils/su-common.c | 2 ++ + term-utils/scriptlive.c | 2 ++ + 4 files changed, 30 insertions(+), 4 deletions(-) + +diff --git a/include/pty-session.h b/include/pty-session.h +index 09eff43..3242992 100644 +--- a/include/pty-session.h ++++ b/include/pty-session.h +@@ -98,6 +98,7 @@ void ul_pty_set_child(struct ul_pty *pty, pid_t child); + struct ul_pty_callbacks *ul_pty_get_callbacks(struct ul_pty *pty); + int ul_pty_is_running(struct ul_pty *pty); + int ul_pty_setup(struct ul_pty *pty); ++int ul_pty_signals_setup(struct ul_pty *pty); + void ul_pty_cleanup(struct ul_pty *pty); + int ul_pty_chownmod_slave(struct ul_pty *pty, uid_t uid, gid_t gid, mode_t mode); + void ul_pty_init_slave(struct ul_pty *pty); +diff --git a/lib/pty-session.c b/lib/pty-session.c +index 6f038e1..d89dfbb 100644 +--- a/lib/pty-session.c ++++ b/lib/pty-session.c +@@ -149,12 +149,12 @@ static void pty_signals_cleanup(struct ul_pty *pty) + int ul_pty_setup(struct ul_pty *pty) + { + struct termios attrs; +- sigset_t ourset; + int rc = 0; + + assert(pty->sigfd == -1); + +- /* save the current signals setting */ ++ /* save the current signals setting (to make ul_pty_cleanup() usable, ++ * otherwise see ul_pty_signals_setup() */ + sigprocmask(0, NULL, &pty->orgsig); + + if (pty->isterm) { +@@ -198,6 +198,26 @@ int ul_pty_setup(struct ul_pty *pty) + tcsetattr(pty->slave, TCSANOW, &attrs); + } + ++done: ++ if (rc) ++ ul_pty_cleanup(pty); ++ ++ DBG(SETUP, ul_debugobj(pty, "pty setup done [master=%d, slave=%d, rc=%d]", ++ pty->master, pty->slave, rc)); ++ return rc; ++} ++ ++/* call me before fork() */ ++int ul_pty_signals_setup(struct ul_pty *pty) ++{ ++ sigset_t ourset; ++ int rc = 0; ++ ++ assert(pty->sigfd == -1); ++ ++ /* save the current signals setting */ ++ sigprocmask(0, NULL, &pty->orgsig); ++ + sigfillset(&ourset); + if (sigprocmask(SIG_BLOCK, &ourset, NULL)) { + rc = -errno; +@@ -221,8 +241,7 @@ done: + if (rc) + ul_pty_cleanup(pty); + +- DBG(SETUP, ul_debugobj(pty, "pty setup done [master=%d, slave=%d, rc=%d]", +- pty->master, pty->slave, rc)); ++ DBG(SETUP, ul_debugobj(pty, "pty signals setup done [rc=%d]", rc)); + return rc; + } + +@@ -692,6 +711,8 @@ int main(int argc, char *argv[]) + + if (ul_pty_setup(pty)) + err(EXIT_FAILURE, "failed to create pseudo-terminal"); ++ if (ul_pty_signals_setup(pty)) ++ err(EXIT_FAILURE, "failed to initialize signals handler"); + + fflush(stdout); /* ??? */ + +diff --git a/login-utils/su-common.c b/login-utils/su-common.c +index afd0ea8..46dc116 100644 +--- a/login-utils/su-common.c ++++ b/login-utils/su-common.c +@@ -536,6 +536,8 @@ static void create_watching_parent(struct su_context *su) + /* create pty */ + if (ul_pty_setup(su->pty)) + err(EXIT_FAILURE, _("failed to create pseudo-terminal")); ++ if (ul_pty_signals_setup(su->pty)) ++ err(EXIT_FAILURE, _("failed to initialize signals handler")); + } + #endif + fflush(stdout); /* ??? */ +diff --git a/term-utils/scriptlive.c b/term-utils/scriptlive.c +index d81712d..3e68f3c 100644 +--- a/term-utils/scriptlive.c ++++ b/term-utils/scriptlive.c +@@ -294,6 +294,8 @@ main(int argc, char *argv[]) + + if (ul_pty_setup(ss.pty)) + err(EXIT_FAILURE, _("failed to create pseudo-terminal")); ++ if (ul_pty_signals_setup(ss.pty)) ++ err(EXIT_FAILURE, _("failed to initialize signals handler")); + + fflush(stdout); /* ??? */ + +-- +2.27.0 + diff --git a/backport-logger-always-update-header-when-read-from-stdin.patch b/backport-logger-always-update-header-when-read-from-stdin.patch new file mode 100644 index 0000000000000000000000000000000000000000..d0571e864329467c64d8a08a0fd979ecdec66513 --- /dev/null +++ b/backport-logger-always-update-header-when-read-from-stdin.patch @@ -0,0 +1,98 @@ +From 96ccdc00e1fcf1684f9734a189baf90e00ff0c9a Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Tue, 1 Nov 2022 10:30:06 +0100 +Subject: [PATCH] logger: always update header when read from stdin + +The current code updates the header only when the priority has been +changed. It's incorrect because wanted is a valid header or each entry +(don't forget that logger for stdin use-case is used in pipe to log +long-time running processes). + +This patch also fixes the initial timestamp; it was originally generated +on logger startup, it now generates the header on the first message. + +$ (sleep 2; date; sleep 2; date; sleep 2; date) | logger --stderr --no-act + +old: +<13>Nov 1 10:42:14 kzak: Tue Nov 1 10:42:16 AM CET 2022 +<13>Nov 1 10:42:14 kzak: Tue Nov 1 10:42:18 AM CET 2022 +<13>Nov 1 10:42:14 kzak: Tue Nov 1 10:42:20 AM CET 2022 + +new: +<13>Nov 1 10:19:02 kzak: Tue Nov 1 10:19:02 AM CET 2022 +<13>Nov 1 10:19:04 kzak: Tue Nov 1 10:19:04 AM CET 2022 +<13>Nov 1 10:19:06 kzak: Tue Nov 1 10:19:06 AM CET 2022 + +Fixes: https://github.com/util-linux/util-linux/issues/1866 +Signed-off-by: Karel Zak +--- + misc-utils/logger.c | 18 +++++++----------- + 1 file changed, 7 insertions(+), 11 deletions(-) + +diff --git a/misc-utils/logger.c b/misc-utils/logger.c +index a29b9e4..0f2a849 100644 +--- a/misc-utils/logger.c ++++ b/misc-utils/logger.c +@@ -920,8 +920,6 @@ static void logger_open(struct logger_ctl *ctl) + ctl->tag = xgetlogin(); + if (!ctl->tag) + ctl->tag = ""; +- +- generate_syslog_header(ctl); + } + + /* re-open; usually after failed connection */ +@@ -971,10 +969,8 @@ static void logger_stdin(struct logger_ctl *ctl) + { + /* note: we re-generate the syslog header for each log message to + * update header timestamps and to reflect possible priority changes. +- * The initial header is generated by logger_open(). + */ + int default_priority = ctl->pri; +- int last_pri = default_priority; + char *buf = xmalloc(ctl->max_message_size + 2 + 2); + int pri; + int c; +@@ -1001,10 +997,6 @@ static void logger_stdin(struct logger_ctl *ctl) + } else + ctl->pri = default_priority; + +- if (ctl->pri != last_pri) { +- generate_syslog_header(ctl); +- last_pri = ctl->pri; +- } + if (c != EOF && c != '\n') + c = getchar(); + } +@@ -1015,8 +1007,10 @@ static void logger_stdin(struct logger_ctl *ctl) + } + buf[i] = '\0'; + +- if (i > 0 || !ctl->skip_empty_lines) ++ if (i > 0 || !ctl->skip_empty_lines) { ++ generate_syslog_header(ctl); + write_output(ctl, buf); ++ } + + if (c == '\n') /* discard line terminator */ + c = getchar(); +@@ -1291,12 +1285,14 @@ int main(int argc, char **argv) + abort(); + } + logger_open(&ctl); +- if (0 < argc) ++ if (0 < argc) { ++ generate_syslog_header(&ctl); + logger_command_line(&ctl, argv); +- else ++ } else + /* Note. --file reopens stdin making the below + * function to be used for file inputs. */ + logger_stdin(&ctl); ++ + logger_close(&ctl); + return EXIT_SUCCESS; + } +-- +2.27.0 + diff --git a/backport-script-fix-use-of-utempter.patch b/backport-script-fix-use-of-utempter.patch new file mode 100644 index 0000000000000000000000000000000000000000..51f5a4075c5691749e6cc4f44766581d5d25cb31 --- /dev/null +++ b/backport-script-fix-use-of-utempter.patch @@ -0,0 +1,43 @@ +From 6ed644fbf4869a7e042826900eff531cf6660cfb Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Wed, 16 Nov 2022 09:19:18 +0100 +Subject: [PATCH] script: fix use of utempter + +libutempter uses SIGCHLD, but script(1) pty implementation completely +control all signals by signalfd and utempter does not work. + +The solution is to setup signalfd later (after libutempter use). + +Fixes: https://github.com/util-linux/util-linux/issues/1904 +Signed-off-by: Karel Zak +--- + term-utils/script.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/term-utils/script.c b/term-utils/script.c +index c918ecd6e..516a6cf93 100644 +--- a/term-utils/script.c ++++ b/term-utils/script.c +@@ -947,13 +947,16 @@ int main(int argc, char **argv) + printf(_(".\n")); + } + +-#ifdef HAVE_LIBUTEMPTER +- utempter_add_record(ul_pty_get_childfd(ctl.pty), NULL); +-#endif + + if (ul_pty_setup(ctl.pty)) + err(EXIT_FAILURE, _("failed to create pseudo-terminal")); + ++#ifdef HAVE_LIBUTEMPTER ++ utempter_add_record(ul_pty_get_childfd(ctl.pty), NULL); ++#endif ++ ++ if (ul_pty_signals_setup(ctl.pty)) ++ err(EXIT_FAILURE, _("failed to initialize signals handler")); + fflush(stdout); + + /* +-- +2.27.0 + diff --git a/util-linux.spec b/util-linux.spec index 76335c12f1d72633a581854b42cc524717a75586..30453d5b93ce6b6be71f03a644754ef956589bd3 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -3,7 +3,7 @@ Name: util-linux Version: 2.37.2 -Release: 12 +Release: 13 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 @@ -53,6 +53,12 @@ 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 Patch9000: Add-check-to-resolve-uname26-version-test-failed.patch Patch9001: SKIPPED-no-root-permissions-test.patch @@ -424,6 +430,18 @@ fi %{_mandir}/man8/{swapoff.8*,swapon.8*,switch_root.8*,umount.8*,wdctl.8.gz,wipefs.8*,zramctl.8*} %changelog +* Sat Sep 17 2022 zhangyao - 2.37.2-13 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:sync community patches + [add]backport-fsck-Processes-may-kill-other-processes.patch + backport-fdisk-fix-output-option-parsing.patch + backport-libblkid-exfat-fix-divide-by-zero-coverity-scan.patch + backport-llib-pty-session-split-PTY-and-signalfd-setup.patch + backport-script-fix-use-of-utempter.patch + backport-logger-always-update-header-when-read-from-stdin.patch + * Mon Nov 14 2022 zhangyao - 2.37.2-12 - Type:bugfix - ID:NA