Race in reboot/poweroff path at init?

Tito farmatito at tiscali.it
Tue Oct 10 15:33:15 UTC 2017



On October 10, 2017 4:52:17 PM GMT+08:00, Jeremy Kerr <jk at ozlabs.org> wrote:
>Hi all,
>
>I've been debugging an issue where we can't reboot or poweroff a
>machine
>in the early stages of busybox init. Using the poweroff case as an
>example:
>
> - kernel starts /sbin/init
>
> - kernel receives a poweroff event, so calls __orderly_poweroff.
>   Effectively, these will just call out to the /sbin/poweroff usermode
>   helper.
>
> - /sbin/poweroff just does a:
>
>     kill(1, SIGUSR2);
>
> - However, /sbin/init has not yet installed a signal handler for
>   SIGUSR2. Because we're PID 1, this means the signal is ignored, and
>   so the command to poweroff the machine is dropped.
>
> - init keeps booting rather than powering off.
>
>In our particular case, the "poweroff event" is an IPMI soft shutdown
>message. However, the same would apply for any other path that involves
>orderly_poweroff or orderly_reboot.
>
>Even though the signal handlers are installed fairly early in init, we
>can still hit the race between this and the SIGUSR2 being sent fairly
>reliably.
>
>I see a couple of options for resolving this:
>
> - installing the signal handlers even earlier in init_main(). However,
>   this will only reduce the window for lost events, rather than
>   eliminating it; or
>
> - using a synchronous channel to send the shutdown/reboot message
>   between the poweroff/reboot helpers, rather than an asynchronous
>   signal. Say, have init listening on a socket, allowing the poweroff
>   binary to wait and/or retry.
>
>However, before I go down the wrong path here: does anyone have other
>ideas that might help eliminating dropped poweroff/reboot events?
>
>Regards,
>
>
>Jeremy
>_______________________________________________
>busybox mailing list
>busybox at busybox.net
>http://lists.busybox.net/mailman/listinfo/busybox
Hi, just a silly idea: would running the poweroff or reboot signal in a loop do any harm or eventually be somehow an improvement?
Just my 0,2 cents from vacation after a couple of beers.
Ciao, Tito


More information about the busybox mailing list