|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 3/4] xen/manage: Guard against user-space initiated poweroff and XenBus.
On 11/08/2013 12:38 PM, Konrad Rzeszutek Wilk wrote: There is a race case where the user does 'poweroff' and at the same time the system admin does 'xl shutdown'. Depending on the race, the system_state will be SYSTEM_RUNNING or SYSTEM_POWER_OFF. If SYSTEM_RUNNING we just end up making a duplicate call to 'poweroff' (while it is running). That will fail or execute (And if executed then it will be stuck in the reboot_mutex mutex). But nobody will care b/c the machine is in poweroff sequence. If the system_state is SYSTEM_POWER_OFF then we end up making a duplicate call to kernel_power_off. There is no locking there so we walk in the same steps as what 'poweroff' has been doing. The code in kernel/reboot.c has a mutex guarding against multiple 'poweroff' operations. But not against the kernel 'orderly_poweroff'. As such, lets detect this so that we don't invoke orderly_poweroff if the user had initiated a poweroff. This is code by changing the 'shutting_down' to an atomic and having a reboot notifier. If the 'shutting_down' is set to anything but SHUTDOWN_INVALID the XenBus handler will not run. That is exactly what we do in the reboot notifier - we set the 'shutting_down' to SHUTDOWN_POWEROFF. The reason we change the 'shutting_down' to an atomic is that the changes to said variable were normally guarded by the XenBus mutex - "xenwatch_mutex" - guarantting only one caller changing shutting_down. Since we have now the reboot notifier we have another user of this variable. Surfacing the 'xenwatch_mutex' out of XenBus is not a nice way of doing it. Having the variable however be atomic solves the problem easily. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> [v2: Don't expose xenwatch_mutex, add comments] Reviewed-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
_______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |