From: Brian Geffon <bgeffon@google.com>
To: Christian Brauner <brauner@kernel.org>,
Kees Cook <keescook@chromium.org>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
Matthias Kaehlcke <mka@chromium.org>,
Luis Chamberlain <mcgrof@kernel.org>,
Frederic Weisbecker <frederic@kernel.org>,
linux-kernel@vger.kernel.org, Brian Geffon <bgeffon@google.com>
Subject: [PATCH] pid: Allow frozen userspace to reboot from non-init pid ns
Date: Fri, 29 Sep 2023 13:44:42 -0400 [thread overview]
Message-ID: <20230929174442.1635558-1-bgeffon@google.com> (raw)
When the system has a frozen userspace, for example, during hibernation
the child reaper task will also be frozen. Attmepting to deliver a
signal to it to handle the reboot(2) will ultimately lead to the system
hanging unless userspace is thawed.
This change checks if the current task is the suspending task and if so
it will allow it to proceed with a reboot from the non-init pid ns.
Signed-off-by: Brian Geffon <bgeffon@google.com>
Reported-by: Matthias Kaehlcke <mka@chromium.org>
Tested-by: Matthias Kaehlcke <mka@chromium.org>
---
kernel/pid_namespace.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index 0bf44afe04dd..4a93a5063eda 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -321,6 +321,15 @@ int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd)
if (pid_ns == &init_pid_ns)
return 0;
+ if (current->flags & PF_SUSPEND_TASK) {
+ /*
+ * Attempting to signal the child_reaper won't work if it's
+ * frozen. In this case we shutdown the system as if we were in
+ * the init_pid_ns.
+ */
+ return 0;
+ }
+
switch (cmd) {
case LINUX_REBOOT_CMD_RESTART2:
case LINUX_REBOOT_CMD_RESTART:
--
2.42.0.582.g8ccd20d70d-goog
next reply other threads:[~2023-09-29 17:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-29 17:44 Brian Geffon [this message]
2023-09-29 20:09 ` [PATCH] pid: Allow frozen userspace to reboot from non-init pid ns Kees Cook
2023-09-30 0:25 ` Brian Geffon
2023-10-09 20:05 ` Kees Cook
2023-10-12 3:53 ` Eric W. Biederman
2023-10-12 9:48 ` Rafael J. Wysocki
2023-10-17 19:00 ` Brian Geffon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230929174442.1635558-1-bgeffon@google.com \
--to=bgeffon@google.com \
--cc=brauner@kernel.org \
--cc=frederic@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=mka@chromium.org \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox