!212 [sync] PR-211: sync community patches
From: @openeuler-sync-bot Reviewed-by: @openeuler-basic Signed-off-by: @openeuler-basic
This commit is contained in:
commit
45d167ec05
82
backport-libblkid-Check-offset-in-LUKS2-header.patch
Normal file
82
backport-libblkid-Check-offset-in-LUKS2-header.patch
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
From e49de00f4a22f91ec5af08d97e30a198cd64e00d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Milan Broz <gmazyland@gmail.com>
|
||||||
|
Date: Fri, 16 Feb 2024 16:44:12 +0100
|
||||||
|
Subject: [PATCH] libblkid: Check offset in LUKS2 header
|
||||||
|
|
||||||
|
LUKS2 binary header contains offset field that describes where
|
||||||
|
the header should be located.
|
||||||
|
|
||||||
|
If this offset is not correct, blkid should tread this header
|
||||||
|
as invalid.
|
||||||
|
|
||||||
|
This patch fixes problem when both swap and LUKS headers are
|
||||||
|
present (LUKS header was swapped out) and detected LUKS header
|
||||||
|
is at a wrong offset.
|
||||||
|
As LUKS has higher priority, it confuses detection.
|
||||||
|
|
||||||
|
Signed-off-by: Milan Broz <gmazyland@gmail.com>
|
||||||
|
---
|
||||||
|
libblkid/src/superblocks/luks.c | 20 +++++++++++++++++---
|
||||||
|
1 file changed, 17 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libblkid/src/superblocks/luks.c b/libblkid/src/superblocks/luks.c
|
||||||
|
index 0230b34..4623c98 100644
|
||||||
|
--- a/libblkid/src/superblocks/luks.c
|
||||||
|
+++ b/libblkid/src/superblocks/luks.c
|
||||||
|
@@ -1,6 +1,6 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2008 Karel Zak <kzak@redhat.com>
|
||||||
|
- * Copyright (C) 2018 Milan Broz <gmazyland@gmail.com>
|
||||||
|
+ * Copyright (C) 2018-2024 Milan Broz <gmazyland@gmail.com>
|
||||||
|
*
|
||||||
|
* Inspired by libvolume_id by
|
||||||
|
* Kay Sievers <kay.sievers@vrfy.org>
|
||||||
|
@@ -15,6 +15,7 @@
|
||||||
|
#include <errno.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
+#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "superblocks.h"
|
||||||
|
|
||||||
|
@@ -96,6 +97,19 @@ static int luks_attributes(blkid_probe pr, struct luks2_phdr *header, uint64_t o
|
||||||
|
return BLKID_PROBE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static bool luks_valid(struct luks2_phdr *header, const char *magic, uint64_t offset)
|
||||||
|
+{
|
||||||
|
+ if (memcmp(header->magic, magic, LUKS_MAGIC_L))
|
||||||
|
+ return false;
|
||||||
|
+
|
||||||
|
+ /* LUKS2 header is not at expected offset */
|
||||||
|
+ if (be16_to_cpu(header->version) == 2 &&
|
||||||
|
+ be64_to_cpu(header->hdr_offset) != offset)
|
||||||
|
+ return false;
|
||||||
|
+
|
||||||
|
+ return true;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int probe_luks(blkid_probe pr, const struct blkid_idmag *mag __attribute__((__unused__)))
|
||||||
|
{
|
||||||
|
struct luks2_phdr *header;
|
||||||
|
@@ -105,7 +119,7 @@ static int probe_luks(blkid_probe pr, const struct blkid_idmag *mag __attribute_
|
||||||
|
if (!header)
|
||||||
|
return errno ? -errno : BLKID_PROBE_NONE;
|
||||||
|
|
||||||
|
- if (!memcmp(header->magic, LUKS_MAGIC, LUKS_MAGIC_L)) {
|
||||||
|
+ if (luks_valid(header, LUKS_MAGIC, 0)) {
|
||||||
|
/* LUKS primary header was found. */
|
||||||
|
return luks_attributes(pr, header, 0);
|
||||||
|
}
|
||||||
|
@@ -118,7 +132,7 @@ static int probe_luks(blkid_probe pr, const struct blkid_idmag *mag __attribute_
|
||||||
|
if (!header)
|
||||||
|
return errno ? -errno : BLKID_PROBE_NONE;
|
||||||
|
|
||||||
|
- if (!memcmp(header->magic, LUKS_MAGIC_2, LUKS_MAGIC_L))
|
||||||
|
+ if (luks_valid(header, LUKS_MAGIC_2, secondary_offsets[i]))
|
||||||
|
return luks_attributes(pr, header, secondary_offsets[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
207
backport-more-fix-poll-use.patch
Normal file
207
backport-more-fix-poll-use.patch
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
From fe23722854f651984fad597cbb5b44653f72832a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Karel Zak <kzak@redhat.com>
|
||||||
|
Date: Tue, 20 Feb 2024 12:26:33 +0100
|
||||||
|
Subject: [PATCH] more: fix poll() use
|
||||||
|
|
||||||
|
The more(1) command utilizes signalfd() to monitor signals and reads
|
||||||
|
commands from the user via stderr (as stdin is typically used for
|
||||||
|
piping and not for user interaction).
|
||||||
|
|
||||||
|
However, the current more_poll() implementation ignores stderr. As a result,
|
||||||
|
more(1) waits on read(stderr) while completely ignoring signals. This issue
|
||||||
|
becomes evident when using commands like:
|
||||||
|
|
||||||
|
grep foo /path/file | more
|
||||||
|
|
||||||
|
In such cases, it's only possible to exit 'more' by pressing 'q';
|
||||||
|
CTRL+C does not work.
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Refactor more_poll() code:
|
||||||
|
- Introduce an enum to access pfd[] items instead of using magical constants.
|
||||||
|
- Implement a while() loop to handle EAGAIN or POLLHUP.
|
||||||
|
|
||||||
|
- Ignore stdin after POLLHUP (indicating that the pipe's peer closed).
|
||||||
|
- Ensure stderr is also checked.
|
||||||
|
- Use return codes akin to classic poll().
|
||||||
|
|
||||||
|
Note: I have doubts regarding the usability of stdin in more_poll(),
|
||||||
|
as the function is primarily used to wait for user input (via stderr)
|
||||||
|
and to monitor signals. Nevertheless, it is retained for potential use
|
||||||
|
in detecting when the pipe's peer (or the entire session) has been
|
||||||
|
terminated (see commit 68e14d3d5f4116ad3aca0e392d008645ea90cf70).
|
||||||
|
|
||||||
|
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||||
|
---
|
||||||
|
text-utils/more.c | 126 ++++++++++++++++++++++++++++++----------------
|
||||||
|
1 file changed, 82 insertions(+), 44 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/text-utils/more.c b/text-utils/more.c
|
||||||
|
index c4edbc0..eb58446 100644
|
||||||
|
--- a/text-utils/more.c
|
||||||
|
+++ b/text-utils/more.c
|
||||||
|
@@ -199,6 +199,7 @@ struct more_control {
|
||||||
|
magic_t magic; /* libmagic database entries */
|
||||||
|
#endif
|
||||||
|
unsigned int
|
||||||
|
+ ignore_stdin:1, /* POLLHUP; peer closed pipe */
|
||||||
|
bad_stdout:1, /* true if overwriting does not turn off standout */
|
||||||
|
catch_suspend:1, /* we should catch the SIGTSTP signal */
|
||||||
|
clear_line_ends:1, /* do not scroll, paint each screen from the top */
|
||||||
|
@@ -1341,55 +1342,92 @@ static void read_line(struct more_control *ctl)
|
||||||
|
*p = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
+/* returns: 0 timeout or nothing; <0 error, >0 success */
|
||||||
|
static int more_poll(struct more_control *ctl, int timeout)
|
||||||
|
{
|
||||||
|
- struct pollfd pfd[2];
|
||||||
|
+ enum {
|
||||||
|
+ POLLFD_SIGNAL = 0,
|
||||||
|
+ POLLFD_STDIN,
|
||||||
|
+ POLLFD_STDERR,
|
||||||
|
+ };
|
||||||
|
+ struct pollfd pfd[] = {
|
||||||
|
+ [POLLFD_SIGNAL] = { .fd = ctl->sigfd, .events = POLLIN | POLLERR | POLLHUP },
|
||||||
|
+ [POLLFD_STDIN] = { .fd = STDIN_FILENO, .events = POLLIN | POLLERR | POLLHUP },
|
||||||
|
+ [POLLFD_STDERR] = { .fd = STDERR_FILENO, .events = POLLIN | POLLERR | POLLHUP }
|
||||||
|
+ };
|
||||||
|
+ int has_data = 0;
|
||||||
|
|
||||||
|
- pfd[0].fd = ctl->sigfd;
|
||||||
|
- pfd[0].events = POLLIN | POLLERR | POLLHUP;
|
||||||
|
- pfd[1].fd = STDIN_FILENO;
|
||||||
|
- pfd[1].events = POLLIN;
|
||||||
|
+ while (!has_data) {
|
||||||
|
+ int rc;
|
||||||
|
|
||||||
|
- if (poll(pfd, 2, timeout) < 0) {
|
||||||
|
- if (errno == EAGAIN)
|
||||||
|
- return 1;
|
||||||
|
- more_error(ctl, _("poll failed"));
|
||||||
|
- return 1;
|
||||||
|
- }
|
||||||
|
- if (pfd[0].revents != 0) {
|
||||||
|
- struct signalfd_siginfo info;
|
||||||
|
- ssize_t sz;
|
||||||
|
-
|
||||||
|
- sz = read(pfd[0].fd, &info, sizeof(info));
|
||||||
|
- assert(sz == sizeof(info));
|
||||||
|
- switch (info.ssi_signo) {
|
||||||
|
- case SIGINT:
|
||||||
|
- more_exit(ctl);
|
||||||
|
- break;
|
||||||
|
- case SIGQUIT:
|
||||||
|
- sigquit_handler(ctl);
|
||||||
|
- break;
|
||||||
|
- case SIGTSTP:
|
||||||
|
- sigtstp_handler(ctl);
|
||||||
|
- break;
|
||||||
|
- case SIGCONT:
|
||||||
|
- sigcont_handler(ctl);
|
||||||
|
- break;
|
||||||
|
- case SIGWINCH:
|
||||||
|
- sigwinch_handler(ctl);
|
||||||
|
- break;
|
||||||
|
- default:
|
||||||
|
- abort();
|
||||||
|
+ if (ctl->ignore_stdin)
|
||||||
|
+ pfd[POLLFD_STDIN].fd = -1; /* probably closed, ignore */
|
||||||
|
+
|
||||||
|
+ rc = poll(pfd, ARRAY_SIZE(pfd), timeout);
|
||||||
|
+
|
||||||
|
+ /* error */
|
||||||
|
+ if (rc < 0) {
|
||||||
|
+ if (errno == EAGAIN)
|
||||||
|
+ continue;
|
||||||
|
+
|
||||||
|
+ more_error(ctl, _("poll failed"));
|
||||||
|
+ return rc;
|
||||||
|
}
|
||||||
|
- }
|
||||||
|
|
||||||
|
- /* Check for POLLERR and POLLHUP in stdin revents */
|
||||||
|
- if ((pfd[1].revents & POLLERR) && (pfd[1].revents & POLLHUP))
|
||||||
|
- more_exit(ctl);
|
||||||
|
+ /* timeout */
|
||||||
|
+ if (rc == 0)
|
||||||
|
+ return 0;
|
||||||
|
|
||||||
|
- if (pfd[1].revents == 0)
|
||||||
|
- return 1;
|
||||||
|
- return 0;
|
||||||
|
+ /* event on signal FD */
|
||||||
|
+ if (pfd[POLLFD_SIGNAL].revents) {
|
||||||
|
+ struct signalfd_siginfo info;
|
||||||
|
+ ssize_t sz;
|
||||||
|
+
|
||||||
|
+ sz = read(pfd[POLLFD_SIGNAL].fd, &info, sizeof(info));
|
||||||
|
+ assert(sz == sizeof(info));
|
||||||
|
+ switch (info.ssi_signo) {
|
||||||
|
+ case SIGINT:
|
||||||
|
+ more_exit(ctl);
|
||||||
|
+ break;
|
||||||
|
+ case SIGQUIT:
|
||||||
|
+ sigquit_handler(ctl);
|
||||||
|
+ break;
|
||||||
|
+ case SIGTSTP:
|
||||||
|
+ sigtstp_handler(ctl);
|
||||||
|
+ break;
|
||||||
|
+ case SIGCONT:
|
||||||
|
+ sigcont_handler(ctl);
|
||||||
|
+ break;
|
||||||
|
+ case SIGWINCH:
|
||||||
|
+ sigwinch_handler(ctl);
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ abort();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* event on stdin */
|
||||||
|
+ if (pfd[POLLFD_STDIN].revents) {
|
||||||
|
+ /* Check for POLLERR and POLLHUP in stdin revents */
|
||||||
|
+ if ((pfd[POLLFD_STDIN].revents & POLLERR) &&
|
||||||
|
+ (pfd[POLLFD_STDIN].revents & POLLHUP))
|
||||||
|
+ more_exit(ctl);
|
||||||
|
+
|
||||||
|
+ /* poll() return POLLHUP event after pipe close() and POLLNVAL
|
||||||
|
+ * means that fd is already closed. */
|
||||||
|
+ if ((pfd[POLLFD_STDIN].revents & POLLHUP) ||
|
||||||
|
+ (pfd[POLLFD_STDIN].revents & POLLNVAL))
|
||||||
|
+ ctl->ignore_stdin = 1;
|
||||||
|
+ else
|
||||||
|
+ has_data++;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* event on stderr (we reads user commands from stderr!) */
|
||||||
|
+ if (pfd[POLLFD_STDERR].revents)
|
||||||
|
+ has_data++;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return has_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Search for nth occurrence of regular expression contained in buf in
|
||||||
|
@@ -1457,7 +1495,7 @@ static void search(struct more_control *ctl, char buf[], int n)
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
- more_poll(ctl, 1);
|
||||||
|
+ more_poll(ctl, 0);
|
||||||
|
}
|
||||||
|
/* Move ctrl+c signal handling back to more_key_command(). */
|
||||||
|
signal(SIGINT, SIG_DFL);
|
||||||
|
@@ -1621,7 +1659,7 @@ static int more_key_command(struct more_control *ctl, char *filename)
|
||||||
|
ctl->report_errors = 0;
|
||||||
|
ctl->search_called = 0;
|
||||||
|
for (;;) {
|
||||||
|
- if (more_poll(ctl, -1) != 0)
|
||||||
|
+ if (more_poll(ctl, -1) <= 0)
|
||||||
|
continue;
|
||||||
|
cmd = read_command(ctl);
|
||||||
|
if (cmd.key == more_kc_unknown_command)
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
From 5533e237c8047ff941bb3720237c58413441e35c Mon Sep 17 00:00:00 2001
|
||||||
|
From: WanBingjiang <wanbingjiang@webray.com.cn>
|
||||||
|
Date: Fri, 2 Feb 2024 10:43:08 +0800
|
||||||
|
Subject: [PATCH] sys-utils/lscpu: Unblock SIGSEGV before vmware_bdoor
|
||||||
|
|
||||||
|
---
|
||||||
|
sys-utils/lscpu-virt.c | 16 +++++++++++++++-
|
||||||
|
1 file changed, 15 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/sys-utils/lscpu-virt.c b/sys-utils/lscpu-virt.c
|
||||||
|
index 4d301271a..6ba7c02dc 100644
|
||||||
|
--- a/sys-utils/lscpu-virt.c
|
||||||
|
+++ b/sys-utils/lscpu-virt.c
|
||||||
|
@@ -17,6 +17,7 @@
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
+#include <signal.h>
|
||||||
|
|
||||||
|
#include "lscpu.h"
|
||||||
|
|
||||||
|
@@ -454,6 +455,7 @@ void vmware_bdoor(uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
|
||||||
|
}
|
||||||
|
|
||||||
|
static jmp_buf segv_handler_env;
|
||||||
|
+static sigset_t oset;
|
||||||
|
|
||||||
|
static void
|
||||||
|
segv_handler(__attribute__((__unused__)) int sig,
|
||||||
|
@@ -467,6 +469,7 @@ static int is_vmware_platform(void)
|
||||||
|
{
|
||||||
|
uint32_t eax, ebx, ecx, edx;
|
||||||
|
struct sigaction act, oact;
|
||||||
|
+ sigset_t set;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FIXME: Not reliable for non-root users. Note it works as expected if
|
||||||
|
@@ -485,8 +488,16 @@ static int is_vmware_platform(void)
|
||||||
|
* the signal. All this magic is needed because lscpu
|
||||||
|
* isn't supposed to require root privileges.
|
||||||
|
*/
|
||||||
|
- if (sigsetjmp(segv_handler_env, 1))
|
||||||
|
+ if (sigsetjmp(segv_handler_env, 1)) {
|
||||||
|
+ if (sigprocmask(SIG_SETMASK, &oset, NULL))
|
||||||
|
+ err(EXIT_FAILURE, _("cannot restore signal mask"));
|
||||||
|
return 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ sigemptyset(&set);
|
||||||
|
+ sigaddset(&set, SIGSEGV);
|
||||||
|
+ if (sigprocmask(SIG_UNBLOCK, &set, &oset))
|
||||||
|
+ err(EXIT_FAILURE, _("cannot unblock signal"));
|
||||||
|
|
||||||
|
memset(&act, 0, sizeof(act));
|
||||||
|
act.sa_sigaction = segv_handler;
|
||||||
|
@@ -500,6 +511,9 @@ static int is_vmware_platform(void)
|
||||||
|
if (sigaction(SIGSEGV, &oact, NULL))
|
||||||
|
err(EXIT_FAILURE, _("cannot restore signal handler"));
|
||||||
|
|
||||||
|
+ if (sigprocmask(SIG_SETMASK, &oset, NULL))
|
||||||
|
+ err(EXIT_FAILURE, _("cannot restore signal mask"));
|
||||||
|
+
|
||||||
|
return eax != (uint32_t)-1 && ebx == VMWARE_BDOOR_MAGIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
Name: util-linux
|
Name: util-linux
|
||||||
Version: 2.37.2
|
Version: 2.37.2
|
||||||
Release: 26
|
Release: 27
|
||||||
Summary: A random collection of Linux utilities
|
Summary: A random collection of Linux utilities
|
||||||
License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain
|
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
|
URL: https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git
|
||||||
@ -140,6 +140,9 @@ Patch6118: backport-libblkid-hfsplus-reduce-false-positive.patch
|
|||||||
Patch6119: backport-wall-fix-calloc-cal-Werror-calloc-transposed-args.patch
|
Patch6119: backport-wall-fix-calloc-cal-Werror-calloc-transposed-args.patch
|
||||||
Patch6120: backport-libblkid-drbd-reduce-false-positive.patch
|
Patch6120: backport-libblkid-drbd-reduce-false-positive.patch
|
||||||
Patch6121: backport-lib-cpuset-exit-early-from-cpulist_parse.patch
|
Patch6121: backport-lib-cpuset-exit-early-from-cpulist_parse.patch
|
||||||
|
Patch6122: backport-sys-utils-lscpu-Unblock-SIGSEGV-before-vmware_bdoor.patch
|
||||||
|
Patch6123: backport-libblkid-Check-offset-in-LUKS2-header.patch
|
||||||
|
Patch6124: backport-more-fix-poll-use.patch
|
||||||
|
|
||||||
Patch9000: Add-check-to-resolve-uname26-version-test-failed.patch
|
Patch9000: Add-check-to-resolve-uname26-version-test-failed.patch
|
||||||
Patch9001: SKIPPED-no-root-permissions-test.patch
|
Patch9001: SKIPPED-no-root-permissions-test.patch
|
||||||
@ -511,6 +514,15 @@ fi
|
|||||||
%{_mandir}/man8/{swapoff.8*,swapon.8*,switch_root.8*,umount.8*,wdctl.8.gz,wipefs.8*,zramctl.8*}
|
%{_mandir}/man8/{swapoff.8*,swapon.8*,switch_root.8*,umount.8*,wdctl.8.gz,wipefs.8*,zramctl.8*}
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Mar 11 2024 zhangyao <zhangyao108@huawei.com> - 2.37.2-27
|
||||||
|
- Type:bugfix
|
||||||
|
- CVE:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC:sync community patches
|
||||||
|
backport-sys-utils-lscpu-Unblock-SIGSEGV-before-vmware_bdoor.patch
|
||||||
|
backport-libblkid-Check-offset-in-LUKS2-header.patch
|
||||||
|
backport-more-fix-poll-use.patch
|
||||||
|
|
||||||
* Fri Mar 8 2024 zhangyao <zhangyao108@huawei.com> - 2.37.2-26
|
* Fri Mar 8 2024 zhangyao <zhangyao108@huawei.com> - 2.37.2-26
|
||||||
- Type:bugfix
|
- Type:bugfix
|
||||||
- CVE:NA
|
- CVE:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user