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: <20090409221416.9a74f7fa.akpm@linux-foundation.org>
Date:	Thu, 9 Apr 2009 22:14:16 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Andi Kleen <andi@...stfloor.org>
Cc:	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Clean up sys_shutdown

On Wed, 8 Apr 2009 00:36:26 +0200 Andi Kleen <andi@...stfloor.org> wrote:

> Clean up sys_shutdown exit path
> 
> Impact: cleanup, fix
> 
> Clean up sys_shutdown exit path. Factor out common code.

OK.

> Return
> correct error code instead of always 0 on failure.

oh goody, that makes the patch a bugfix.

> --- linux.orig/kernel/sys.c	2009-04-07 16:09:58.000000000 +0200
> +++ linux/kernel/sys.c	2009-04-07 16:43:17.000000000 +0200
> @@ -360,6 +360,7 @@
>  		void __user *, arg)
>  {
>  	char buffer[256];
> +	int ret = 0;
>  
>  	/* We only trust the superuser with rebooting the system. */
>  	if (!capable(CAP_SYS_BOOT))
> @@ -397,7 +398,7 @@
>  		kernel_halt();
>  		unlock_kernel();
>  		do_exit(0);
> -		break;
> +		panic("cannot halt");
>  
>  	case LINUX_REBOOT_CMD_POWER_OFF:
>  		kernel_power_off();
> @@ -417,29 +418,22 @@
>  
>  #ifdef CONFIG_KEXEC
>  	case LINUX_REBOOT_CMD_KEXEC:
> -		{
> -			int ret;
> -			ret = kernel_kexec();
> -			unlock_kernel();
> -			return ret;
> -		}
> +		ret = kernel_kexec();
> +		break;
>  #endif
>  
>  #ifdef CONFIG_HIBERNATION
>  	case LINUX_REBOOT_CMD_SW_SUSPEND:
> -		{
> -			int ret = hibernate();
> -			unlock_kernel();
> -			return ret;
> -		}
> +		ret = hibernate();
> +		break;
>  #endif
>  
>  	default:
> -		unlock_kernel();
> -		return -EINVAL;
> +		ret = -EINVAL;
> +		break;
>  	}
>  	unlock_kernel();
> -	return 0;
> +	return ret;
>  }

I wonder why this code uses lock_kernel().
--
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