Re: [PATCH] init: Add handshake to poweroff/reboot for signal handler setup

2018-02-15 Thread Deb McLemore
I suppose the abstract socket solution, which has been tested and closes the window where the orderly poweroff successfully executes reliably, is a solution with minimal impact. On 02/15/2018 05:09 PM, Denys Vlasenko wrote: > On Thu, Feb 15, 2018 at 10:52 PM, Deb McLemore

Re: [PATCH] init: Add handshake to poweroff/reboot for signal handler setup

2018-02-15 Thread Denys Vlasenko
On Thu, Feb 15, 2018 at 10:52 PM, Deb McLemore wrote: > Any logic attempting to guess at the state of startup will give false > confidence that the signaling setup is completed. The case of init not being ready to handle its duties for an extremely early process is in

Re: [PATCH] init: Add handshake to poweroff/reboot for signal handler setup

2018-02-15 Thread Deb McLemore
Any logic attempting to guess at the state of startup will give false confidence that the signaling setup is completed. On 02/15/2018 01:42 PM, Denys Vlasenko wrote: > On Wed, Feb 14, 2018 at 6:53 PM, Deb McLemore > wrote: >> The only reproduction we were able to

Re: [PATCH] init: Add handshake to poweroff/reboot for signal handler setup

2018-02-15 Thread Denys Vlasenko
On Wed, Feb 14, 2018 at 6:53 PM, Deb McLemore wrote: > The only reproduction we were able to perform injected via a BMC soft > poweroff being triggered. > > This then called into kernel/reboot.c (orderly_poweroff where the > schedule_work was performed) utilizing the >

Re: [PATCH] init: Add handshake to poweroff/reboot for signal handler setup

2018-02-15 Thread Deb McLemore
The abstract socket is the indicator that the state of Busybox is ready to accept the signal that triggers the Busybox poweroff sequence, this handshake between the kernel userhelper and Busybox is indicator that Busybox is ready to accept the signal and then process the signal properly is

Re: [PATCH] init: Add handshake to poweroff/reboot for signal handler setup

2018-02-14 Thread Michael Conrad
On 11/24/2017 9:09 PM, Deb McLemore wrote: + while (1) { + fdrc = connect(fdBB2, + (struct sockaddr *)_addr2, + sizeof(sa_family_t) + +

Re: [PATCH] init: Add handshake to poweroff/reboot for signal handler setup

2018-02-14 Thread Michael Conrad
On 2/14/2018 12:53 PM, Deb McLemore wrote: The only reproduction we were able to perform injected via a BMC soft poweroff being triggered. This then called into kernel/reboot.c (orderly_poweroff where the schedule_work was performed) utilizing the usermodehelper during the run_cmd

Re: [PATCH] init: Add handshake to poweroff/reboot for signal handler setup

2018-02-14 Thread Deb McLemore
The only reproduction we were able to perform injected via a BMC soft poweroff being triggered. This then called into kernel/reboot.c (orderly_poweroff where the schedule_work was performed) utilizing the usermodehelper during the run_cmd /sbin/poweroff. On 02/14/2018 09:44 AM, Laurent

Re: [PATCH] init: Add handshake to poweroff/reboot for signal handler setup

2018-02-14 Thread Denys Vlasenko
On Wed, Feb 14, 2018 at 4:44 PM, Laurent Bercot wrote: >> When PID=0 in early kernel_init, PID=1 has a skeleton running, this >> detection is not >> >> the Busybox /sbin/init, but a place holder for when the real Busybox >> /sbin/init is do_execve'd > > > Are you saying

Re: [PATCH] init: Add handshake to poweroff/reboot for signal handler setup

2018-02-14 Thread Laurent Bercot
When PID=0 in early kernel_init, PID=1 has a skeleton running, this detection is not the Busybox /sbin/init, but a place holder for when the real Busybox /sbin/init is do_execve'd Are you saying the kernel could spawn a /sbin/reboot process *before* kernel_init execs into the userspace

Re: [PATCH] init: Add handshake to poweroff/reboot for signal handler setup

2018-02-14 Thread Denys Vlasenko
On Wed, Feb 14, 2018 at 2:49 PM, Deb McLemore wrote: > When PID=0 in early kernel_init, PID=1 has a skeleton running, this detection > is not > > the Busybox /sbin/init, but a place holder for when the real Busybox > /sbin/init is do_execve'd > > and then the kernel

Re: [PATCH] init: Add handshake to poweroff/reboot for signal handler setup

2018-02-14 Thread Deb McLemore
When PID=0 in early kernel_init, PID=1 has a skeleton running, this detection is not the Busybox /sbin/init, but a place holder for when the real Busybox /sbin/init is do_execve'd and then the kernel flushes all the old process table information on the place holder of PID=1, then the real

Re: [PATCH] init: Add handshake to poweroff/reboot for signal handler setup

2018-02-14 Thread Denys Vlasenko
On Wed, Feb 14, 2018 at 4:29 AM, Deb McLemore wrote: > On 02/13/2018 08:32 PM, Laurent Bercot wrote: >>> Even when process=1 is started, it still leaves a window when the >>> signal handler setup has not been completed. >> >> Yes, but you can still use kill(pid, 0) to

Re: [PATCH] init: Add handshake to poweroff/reboot for signal handler setup

2018-02-13 Thread Deb McLemore
>From the original thread, we tried the suggestion, but when the do_execve is >done from kernel_init for Busybox /sbin/init (to start PID=1) all process zombies are flushed (the usermode helper that kicks Busybox /sbin/poweroff started by PID=2, before PID=1 is do_execve'd from kernel init). 

Re: [PATCH] init: Add handshake to poweroff/reboot for signal handler setup

2018-02-13 Thread Laurent Bercot
Even when process=1 is started, it still leaves a window when the signal handler setup has not been completed. Yes, but you can still use kill(pid, 0) to check whether init is ready to receive signals: doublefork a zombie and repeatedly kill it with signal 0. When you get -1 ESRCH, it means

Re: [PATCH] init: Add handshake to poweroff/reboot for signal handler setup

2018-02-13 Thread Laurent Bercot
+ fdrc = connect(fdBB2, + (struct sockaddr *)_addr2, + sizeof(sa_family_t) + + BB_SIGNALS_SOCKET_STR_LEN); +

Re: [PATCH] init: Add handshake to poweroff/reboot for signal handler setup

2018-02-13 Thread Deb McLemore
Even when process=1 is started, it still leaves a window when the signal handler setup has not been completed. bb_signals is for all signal handling setup. On 02/13/2018 02:41 PM, Denys Vlasenko wrote: > On Sat, Nov 25, 2017 at 3:09 AM, Deb McLemore > wrote: >> Add

Re: [PATCH] init: Add handshake to poweroff/reboot for signal handler setup

2018-02-13 Thread Denys Vlasenko
On Sat, Nov 25, 2017 at 3:09 AM, Deb McLemore wrote: > Add an abstract socket to synchronize the readiness of init to receive > the SIGUSR2 to catch poweroff/reboot during an IPL phase (e.g. soft power > off via BMC). > > Signed-off-by: Deb McLemore

[PATCH] init: Add handshake to poweroff/reboot for signal handler setup

2017-11-24 Thread Deb McLemore
Add an abstract socket to synchronize the readiness of init to receive the SIGUSR2 to catch poweroff/reboot during an IPL phase (e.g. soft power off via BMC). Signed-off-by: Deb McLemore --- include/libbb.h | 5 + init/halt.c | 33