[systemd-devel] [PATCH] Fix systemd crash (on assert) during shutdown/reboot in unprivileged container

Lennart Poettering lennart at poettering.net
Fri Jan 23 04:52:51 PST 2015


On Thu, 15.01.15 19:24, Stéphane Graber (stgraber at ubuntu.com) wrote:

> On Thu, Jan 15, 2015 at 07:20:55PM +0100, Lennart Poettering wrote:
> diff --git a/src/core/mount.c b/src/core/mount.c
> index 612d150..4de878e 100644
> --- a/src/core/mount.c
> +++ b/src/core/mount.c
> @@ -871,6 +871,14 @@ static void mount_enter_unmounting(Mount *m) {
>          m->control_command_id = MOUNT_EXEC_UNMOUNT;
>          m->control_command = m->exec_command + MOUNT_EXEC_UNMOUNT;
>  
> +        /* Ignore any mounts under /dev, /proc or /sys */
> +        if (path_startswith(m->where, "/dev/") ||
> +            path_startswith(m->where, "/proc/") ||
> +            path_startswith(m->where, "/sys/")) {
> +                mount_set_state(m, MOUNT_DEAD);
> +                return;
> +        }
> +
>          r = exec_command_set(m->control_command, "/bin/umount", m->where, NULL);
>          if (r >= 0 && UNIT(m)->manager->running_as == SYSTEMD_SYSTEM)
>                  r = exec_command_append(m->control_command, "-n", NULL);

Ah, nah, that patch wouldn't work, the state would be restored later
when we read from /proc/self/mountinfo again...

Anyway, I kinda missed that this is already an issue witht the
shutdown logic of the main unit engine. I assumed this was only about
the final unmount spree in systemd-shutdown.

I now made this change:

http://cgit.freedesktop.org/systemd/systemd/commit/?id=874d3404cbf2363604106c8f86683db4082691ea

This does two things:

- Exempts all file systems below /dev, /proc, /sys from getting a
  Conflicts= dependency with umount.target. THis means during
  shutdown, where umount.target is pulled in these mount units will
  not be stopped.

- In the final umount loop in systemd-shutdown we simply won't bother
  anymore with these file systems too.

Hope this makes things work for you. Please test!

Thanks,

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list