From: "Eric W. Biederman" <ebiederm@xmission.com>
To: Brian Geffon <bgeffon@google.com>
Cc: Kees Cook <keescook@chromium.org>,
Christian Brauner <brauner@kernel.org>,
"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
Subject: Re: [PATCH] pid: Allow frozen userspace to reboot from non-init pid ns
Date: Wed, 11 Oct 2023 22:53:05 -0500 [thread overview]
Message-ID: <87pm1kbiou.fsf@email.froward.int.ebiederm.org> (raw)
In-Reply-To: <CADyq12xRZfafeu1PVxB1G9zTgThB0W5nok2eXPFLC+T28-b-Bg@mail.gmail.com> (Brian Geffon's message of "Fri, 29 Sep 2023 20:25:42 -0400")
Brian Geffon <bgeffon@google.com> writes:
> On Fri, Sep 29, 2023 at 4:09 PM Kees Cook <keescook@chromium.org> wrote:
>>
>> On Fri, Sep 29, 2023 at 01:44:42PM -0400, Brian Geffon wrote:
>> > 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.
>>
>> I don't know the code flow too well here, but shouldn't init_pid_ns
>> always be doing the reboot regardless of anything else?
>
> I think the point of this is, normally the reaper is runnable and so
> an appropriate signal will be delivered allowing them to also clean up
> [2]. In our case, they won't be runnable and doing this wouldn't make
> sense.
The entire reboot_pid_ns thing is just a polite way of keeping
applications like /sbin/reboot working inside a pid namespace.
Ordinarily the process calling reboot (inside the container) won't
have the privileges to request an entire system reboot. So I don't
see anything making sense to promote that reboot into a system-wide
reboot.
Which leads me to the question. What is actually happening with
hibernation that we want something inside a pid namespace to somehow
have the permissions to reboot the entire machine?
>> Also how is this syscall running if current is frozen? This feels weird
>> to me... shouldn't the frozen test be against pid_ns->child_reaper
>> instead of current?
>
> The task which froze the system won't be frozen to make sure this
> happens it will have the flag PF_SUSPEND_TASK added, so we know if we
> have this flag we're the only running user space task [1].
Someone has a task inside a container that is successfully suspending
the entire system?
I don't see how that makes sense.
But on the level that it somehow does I would put a test in
kernel/reboot.c something like:
/*
* If the caller can't perform a normal reboot call
* reboot_pid_ns
*/
if ((pid_ns != &init_pid_ns) &&
!((current->flags & PF_SUSPEND_TASK) && capable(CAP_SYS_BOOT))) {
return reboot_pid_ns(pid_ns, cmd);
}
Making reboot_pid_ns responsible for the logic that should be bypassing
it is quite confusing.
> I hope my understanding is correct and it makes sense. Thanks for
> taking the time to review.
>
> Brian
>
> 1. https://elixir.bootlin.com/linux/latest/source/kernel/power/process.c#L130
> 2. https://elixir.bootlin.com/linux/latest/source/kernel/pid_namespace.c#L327
I really don't know if allowing PF_SUSPEND_TASK so that hibernation and
the like can work from inside a container makes any sense at all.
But the above is roughly how I would make it work.
Eric
next prev parent reply other threads:[~2023-10-12 3:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-29 17:44 [PATCH] pid: Allow frozen userspace to reboot from non-init pid ns Brian Geffon
2023-09-29 20:09 ` Kees Cook
2023-09-30 0:25 ` Brian Geffon
2023-10-09 20:05 ` Kees Cook
2023-10-12 3:53 ` Eric W. Biederman [this message]
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=87pm1kbiou.fsf@email.froward.int.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=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