Revision 2ca067efd82939dfd87827d29d36a265823a4c2f authored by Oleg Nesterov on 22 March 2013, 22:04:41 UTC, committed by Linus Torvalds on 22 March 2013, 23:41:20 UTC
David said:

    Commit 6c0c0d4d1080 ("poweroff: fix bug in orderly_poweroff()")
    apparently fixes one bug in orderly_poweroff(), but introduces
    another.  The comments on orderly_poweroff() claim it can be called
    from any context - and indeed we call it from interrupt context in
    arch/powerpc/platforms/pseries/ras.c for example.  But since that
    commit this is no longer safe, since call_usermodehelper_fns() is not
    safe in interrupt context without the UMH_NO_WAIT option.

orderly_poweroff() can be used from any context but UMH_WAIT_EXEC is
sleepable.  Move the "force" logic into __orderly_poweroff() and change
orderly_poweroff() to use the global poweroff_work which simply calls
__orderly_poweroff().

While at it, remove the unneeded "int argc" and change argv_split() to
use GFP_KERNEL.

We use the global "bool poweroff_force" to pass the argument, this can
obviously affect the previous request if it is pending/running.  So we
only allow the "false => true" transition assuming that the pending
"true" should succeed anyway.  If schedule_work() fails after that we
know that work->func() was not called yet, it must see the new value.

This means that orderly_poweroff() becomes async even if we do not run
the command and always succeeds, schedule_work() can only fail if the
work is already pending.  We can export __orderly_poweroff() and change
the non-atomic callers which want the old semantics.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Reported-by: David Gibson <david@gibson.dropbear.id.au>
Cc: Lucas De Marchi <lucas.demarchi@profusion.mobi>
Cc: Feng Hong <hongfeng@marvell.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Serge Hallyn <serge.hallyn@canonical.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent d002858
History
File Mode Size
Kconfig -rw-r--r-- 4.8 KB
Makefile -rw-r--r-- 392 bytes
TODO -rw-r--r-- 772 bytes
af_ax25.c -rw-r--r-- 43.8 KB
ax25_addr.c -rw-r--r-- 6.0 KB
ax25_dev.c -rw-r--r-- 4.7 KB
ax25_ds_in.c -rw-r--r-- 7.1 KB
ax25_ds_subr.c -rw-r--r-- 5.0 KB
ax25_ds_timer.c -rw-r--r-- 5.8 KB
ax25_iface.c -rw-r--r-- 4.9 KB
ax25_in.c -rw-r--r-- 10.5 KB
ax25_ip.c -rw-r--r-- 5.3 KB
ax25_out.c -rw-r--r-- 8.9 KB
ax25_route.c -rw-r--r-- 11.2 KB
ax25_std_in.c -rw-r--r-- 11.1 KB
ax25_std_subr.c -rw-r--r-- 2.3 KB
ax25_std_timer.c -rw-r--r-- 4.2 KB
ax25_subr.c -rw-r--r-- 6.9 KB
ax25_timer.c -rw-r--r-- 5.1 KB
ax25_uid.c -rw-r--r-- 4.8 KB
sysctl_net_ax25.c -rw-r--r-- 4.5 KB

back to top