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: <20130531155802.5d0b24958e11783553e5cd00@linux-foundation.org>
Date:	Fri, 31 May 2013 15:58:02 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	liguang <lig.fnst@...fujitsu.com>
Cc:	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
	David Howells <dhowells@...hat.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Michael Kerrisk <mtk.manpages@...il.com>,
	Dave Jones <davej@...hat.com>,
	Kees Cook <keescook@...omium.org>,
	Cyrill Gorcunov <gorcunov@...nvz.org>,
	Al Viro <viro@...iv.linux.org.uk>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/4] sys: remove kernel_shutdown_prepare's parameter

On Thu, 30 May 2013 15:58:04 +0800 liguang <lig.fnst@...fujitsu.com> wrote:

> kernel_shutdown_prepare's parameter can be removed
> by checking global 'system_state', so, maybe we
> can save a register to be used :-).
> 
> --- a/kernel/sys.c
> +++ b/kernel/sys.c
> @@ -382,11 +382,10 @@ void kernel_restart(char *cmd)
>  }
>  EXPORT_SYMBOL_GPL(kernel_restart);
>  
> -static void kernel_shutdown_prepare(enum system_states state)
> +static void kernel_shutdown_prepare(void)
>  {
>  	blocking_notifier_call_chain(&reboot_notifier_list,
> -		(state == SYSTEM_HALT)?SYS_HALT:SYS_POWER_OFF, NULL);
> -	system_state = state;
> +		(system_state == SYSTEM_HALT)?SYS_HALT:SYS_POWER_OFF, NULL);
>  	usermodehelper_disable();
>  	device_shutdown();
>  }
> @@ -397,7 +396,7 @@ static void kernel_shutdown_prepare(enum system_states state)
>   */
>  void kernel_halt(void)
>  {
> -	kernel_shutdown_prepare(SYSTEM_HALT);
> +	kernel_shutdown_prepare();
>  	disable_nonboot_cpus();
>  	syscore_shutdown();
>  	printk(KERN_EMERG "System halted.\n");
> @@ -414,7 +413,7 @@ EXPORT_SYMBOL_GPL(kernel_halt);
>   */
>  void kernel_power_off(void)
>  {
> -	kernel_shutdown_prepare(SYSTEM_POWER_OFF);
> +	kernel_shutdown_prepare();
>  	if (pm_power_off_prepare)
>  		pm_power_off_prepare();
>  	disable_nonboot_cpus();
> @@ -484,11 +483,13 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
>  		break;
>  
>  	case LINUX_REBOOT_CMD_HALT:
> +		system_state = SYSTEM_HALT;
>  		kernel_halt();
>  		do_exit(0);
>  		panic("cannot halt");
>  
>  	case LINUX_REBOOT_CMD_POWER_OFF:
> +		system_state = SYSTEM_POWER_OFF;
>  		kernel_power_off();
>  		do_exit(0);
>  		break;

No, this changes behavior for all other callers of kernel_halt() and
kernel_power_off(): system_state will no longer be updated for those
callers.

And passing an argument via a global variable is not nice :(
--
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