sync community patches

This commit is contained in:
hongjinghao 2023-04-23 15:16:14 +08:00
parent a1683a1ef9
commit 5c784bc6e0
5 changed files with 173 additions and 1 deletions

View File

@ -0,0 +1,35 @@
From 73be22c6f245ad86ef33d95bd4ab0a8e9fd121be Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Fri, 3 Feb 2023 18:29:36 +0900
Subject: [PATCH] argv-util: also update program_invocation_short_name
Our logging uses program_invocation_short_name. Without this patch,
logs from forked client may become broken; spuriously truncated or
the short invocation name is not completely shown in the log.
(cherry picked from commit dd15e4cb57129b915e01495e113696bfe0b70214)
(cherry picked from commit ce4726468dc02bd7383cd7d90c8769576c6973e3)
(cherry picked from commit 7a862d9d1a7196a5576720959849f45fc68b041c)
(cherry picked from commit 9fbbd7bf28e5362b786e152a9ce4e8bd40621759)
---
src/basic/process-util.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/basic/process-util.c b/src/basic/process-util.c
index b76ca6f7c5..10651a4564 100644
--- a/src/basic/process-util.c
+++ b/src/basic/process-util.c
@@ -371,6 +371,10 @@ int rename_process(const char name[]) {
strncpy(program_invocation_name, name, k);
if (l > k)
truncated = true;
+
+ /* Also update the short name. */
+ char *p = strrchr(program_invocation_name, '/');
+ program_invocation_short_name = p ? p + 1 : program_invocation_name;
}
/* Third step, completely replace the argv[] array the kernel maintains for us. This requires privileges, but
--
2.27.0

View File

@ -0,0 +1,36 @@
From 28c5859fa30572950a24a7638a3a8191d65daf68 Mon Sep 17 00:00:00 2001
From: licunlong <licunlong1@huawei.com>
Date: Thu, 10 Mar 2022 09:22:29 +0800
Subject: [PATCH] main: drop get_process_cmdline from crash handler
get_process_cmdline calls malloc, which should be avoid in signal handler.
Fixes: #22690
---
src/core/main.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/core/main.c b/src/core/main.c
index 41a4b4225f..7c9265f394 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -274,11 +274,12 @@ _noreturn_ static void crash(int sig, siginfo_t *siginfo, void *context) {
int r;
if (siginfo) {
- _cleanup_free_ char *cmdline = NULL;
- pid_t sender_pid = siginfo->si_pid;
-
- (void) get_process_cmdline(sender_pid, SIZE_MAX, 0, &cmdline);
- log_emergency("Caught <%s> from PID "PID_FMT" (%s)", signal_to_string(sig), sender_pid, strna(cmdline));
+ if (siginfo->si_pid == 0)
+ log_emergency("Caught <%s> from unknown sender process.", signal_to_string(sig));
+ else if (siginfo->si_pid == 1)
+ log_emergency("Caught <%s> from our own process.", signal_to_string(sig));
+ else
+ log_emergency("Caught <%s> from PID "PID_FMT".", signal_to_string(sig), siginfo->si_pid);
}
/* Order things nicely. */
--
2.27.0

View File

@ -0,0 +1,54 @@
From 7347b3db838ea3f02afc6c8a6dccac1ff8e7edbd Mon Sep 17 00:00:00 2001
From: licunlong <licunlong1@huawei.com>
Date: Tue, 8 Mar 2022 19:18:36 +0800
Subject: [PATCH] main: log which process send SIGNAL to PID1 This can help
users to figure out what makes systemd freeze. 1. Someone kills systemd
accidentally, then the sender_pid won't be 1; 2. systemd triggers segfault or
assert, then the sender_pid will be 1;
---
src/core/main.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/core/main.c b/src/core/main.c
index 5009b8d85f..41a4b4225f 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -228,7 +228,7 @@ _noreturn_ static void freeze_or_exit_or_reboot(void) {
freeze();
}
-_noreturn_ static void crash(int sig) {
+_noreturn_ static void crash(int sig, siginfo_t *siginfo, void *context) {
struct sigaction sa;
pid_t pid;
@@ -273,6 +273,14 @@ _noreturn_ static void crash(int sig) {
siginfo_t status;
int r;
+ if (siginfo) {
+ _cleanup_free_ char *cmdline = NULL;
+ pid_t sender_pid = siginfo->si_pid;
+
+ (void) get_process_cmdline(sender_pid, SIZE_MAX, 0, &cmdline);
+ log_emergency("Caught <%s> from PID "PID_FMT" (%s)", signal_to_string(sig), sender_pid, strna(cmdline));
+ }
+
/* Order things nicely. */
r = wait_for_terminate(pid, &status);
if (r < 0)
@@ -330,8 +338,8 @@ _noreturn_ static void crash(int sig) {
static void install_crash_handler(void) {
static const struct sigaction sa = {
- .sa_handler = crash,
- .sa_flags = SA_NODEFER, /* So that we can raise the signal again from the signal handler */
+ .sa_sigaction = crash,
+ .sa_flags = SA_NODEFER | SA_SIGINFO, /* So that we can raise the signal again from the signal handler */
};
int r;
--
2.27.0

View File

@ -0,0 +1,40 @@
From 0aadfe4937045efd5a7a53a176d05db7dc937435 Mon Sep 17 00:00:00 2001
From: Robin Humble <plaguedbypenguins@gmail.com>
Date: Wed, 1 Feb 2023 23:36:48 +1100
Subject: [PATCH] pid1: fix segv triggered by status query (#26279)
If any query makes it to the end of install_info_follow() then I think symlink_target is set to NULL.
If that is followed by -EXDEV from unit_file_load_or_readlink(), then that causes basename(NULL)
which segfaults pid 1.
This is triggered by eg. "systemctl status crond" in RHEL9 if
/etc/systemd/system/crond.service
-> /ram/etc/systemd/system/crond.service
-> /usr/lib/systemd/system/.crond.service.blah.blah
-> /usr/lib/systemd/system/crond.service
(cherry picked from commit 19cfda9fc3c60de21a362ebb56bcb9f4a9855e85)
(cherry picked from commit 015b0ca9286471c05fe88cfa277dd82e20537ba8)
(cherry picked from commit 9a906fae890904284fe91e29b6bdcb64429fecba)
(cherry picked from commit a2dc9e3be9a8895edcba10f4c0d8d703b435c18b)
---
src/shared/install.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/shared/install.c b/src/shared/install.c
index 4bf868f8e9..f038665dea 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -1609,7 +1609,7 @@ static int install_info_traverse(
}
r = install_info_follow(c, i, paths->root_dir, flags, false);
- if (r == -EXDEV) {
+ if (r == -EXDEV && i->symlink_target) {
_cleanup_free_ char *buffer = NULL;
const char *bn;
--
2.27.0

View File

@ -16,7 +16,7 @@
Name: systemd
Url: https://www.freedesktop.org/wiki/Software/systemd
Version: 243
Release: 61
Release: 62
License: MIT and LGPLv2+ and GPLv2+
Summary: System and Service Manager
@ -208,6 +208,10 @@ Patch0160: backport-log-don-t-attempt-to-duplicate-closed-fd.patch
Patch0161: backport-analyze-add-forgotten-return-statement.patch
Patch0162: backport-shared-condition-avoid-nss-lookup-in-PID1.patch
Patch0163: backport-logind-fix-getting-property-OnExternalPower-via-D-Bu.patch
Patch0164: backport-argv-util-also-update-program_invocation_short_name.patch
Patch0165: backport-pid1-fix-segv-triggered-by-status-query.patch
Patch0166: backport-main-log-which-process-send-SIGNAL-to-PID1.patch
Patch0167: backport-main-drop-get_process_cmdline-from-crash-handler.patch
#openEuler
Patch9002: 1509-fix-journal-file-descriptors-leak-problems.patch
@ -1615,6 +1619,9 @@ fi
%exclude /usr/share/man/man3/*
%changelog
* Sun Apr 23 2023 hongjinghao <hongjinghao@huawei.com> - 243-62
- sync community patches
* Thu Mar 16 2023 yangmingtai <yangmingtai@huawei.com> - 243-61
- sync community patches