lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20130314152819.7fb1242b493e8bad2d34671b@linux-foundation.org>
Date:	Thu, 14 Mar 2013 15:28:19 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Oleg Nesterov <oleg@...hat.com>
Cc:	Linus Torvalds <torvalds@...ux-foundation.org>,
	Andi Kleen <andi@...stfloor.org>,
	Lucas De Marchi <lucas.de.marchi@...il.com>,
	Benjamin Herrenschmidt <benh@...nel.crashing.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Paul Mackerras <paulus@...ba.org>, david@...son.dropbear.id.au,
	Kees Cook <keescook@...omium.org>,
	Serge Hallyn <serge.hallyn@...onical.com>,
	"Rafael J. Wysocki" <rjw@...k.pl>,
	Feng Hong <hongfeng@...vell.com>,
	Lucas De Marchi <lucas.demarchi@...fusion.mobi>
Subject: Re: [PATCH 1/1] poweroff: change orderly_poweroff() to use
 schedule_work()

On Wed, 13 Mar 2013 18:47:05 +0100 Oleg Nesterov <oleg@...hat.com> wrote:

> 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.
> 
> ...
>
> @@ -2218,21 +2237,9 @@ static int __orderly_poweroff(void)
>   */
>  int orderly_poweroff(bool force)
>  {
> -	int ret = __orderly_poweroff();
> -
> -	if (ret && force) {
> -		printk(KERN_WARNING "Failed to start orderly shutdown: "
> -		       "forcing the issue\n");
> -
> -		/*
> -		 * I guess this should try to kick off some daemon to sync and
> -		 * poweroff asap.  Or not even bother syncing if we're doing an
> -		 * emergency shutdown?
> -		 */
> -		emergency_sync();
> -		kernel_power_off();
> -	}
> -
> -	return ret;
> +	if (force) /* do not override the pending "true" */
> +		poweroff_force = true;
> +	schedule_work(&poweroff_work);
> +	return 0;
>  }

afaict the current version of orderly_poweroff() will never return -
either __orderly_poweroff() will block until the machine shuts down or
kernel_power_off() will do so.

However with this patch there is a path via which orderly_poweroff()
can return to its caller, I think?  If so, the caller might be rather
surprised and we're exercising never-before-used code paths.  In fact
if the surprised caller goes oops, the poweroff might not occur at all.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ