Re: [PATCH] fix sys_prctl() returned uninitialized value

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Andrew G. Morgan <morgan@...>
Cc: Shi Weihua <shiwh@...>, Serge E. Hallyn <serue@...>, <linux-security-module@...>, LKML <linux-kernel@...>, <jmorris@...>, <ltp-list@...>
Date: Thursday, May 22, 2008 - 1:25 am

On Wed, 21 May 2008 22:01:17 -0700 "Andrew G. Morgan" <morgan@kernel.org> wrote:


Looking at it some more there are two cases which don't initialise
`error': PR_SET_PDEATHSIG and PR_SET_DUMPABLE.  (let's set aside the
silliness of having sys_prctl() perform set_dumpable()'s argument
checking for it).

So I would propose this fix, mainly because it removes that nasty
uninitialized_var().  Please review carefully.



From: Shi Weihua <shiwh@cn.fujitsu.com> 

If none of the switch cases match, the PR_SET_PDEATHSIG and
PR_SET_DUMPABLE cases of the switch statement will never write to local
variable `error'.

Signed-off-by: Shi Weihua <shiwh@cn.fujitsu.com> 
Cc: Andrew G. Morgan <morgan@kernel.org>
Cc: "Serge E. Hallyn" <serue@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 kernel/sys.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff -puN kernel/sys.c~sys_prctl-fix-return-of-uninitialized-value kernel/sys.c
--- a/kernel/sys.c~sys_prctl-fix-return-of-uninitialized-value
+++ a/kernel/sys.c
@@ -1652,7 +1652,7 @@ asmlinkage long sys_umask(int mask)
 asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3,
 			  unsigned long arg4, unsigned long arg5)
 {
-	long uninitialized_var(error);
+	long error = 0;
 
 	if (security_task_prctl(option, arg2, arg3, arg4, arg5, &error))
 		return error;
@@ -1701,9 +1701,7 @@ asmlinkage long sys_prctl(int option, un
 			error = PR_TIMING_STATISTICAL;
 			break;
 		case PR_SET_TIMING:
-			if (arg2 == PR_TIMING_STATISTICAL)
-				error = 0;
-			else
+			if (arg2 != PR_TIMING_STATISTICAL)
 				error = -EINVAL;
 			break;
 
_

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] fix sys_prctl() returned uninitialized value, Shi Weihua, (Wed May 21, 11:19 pm)
Re: [PATCH] fix sys_prctl() returned uninitialized value, Andrew Morton, (Wed May 21, 11:32 pm)
Re: [PATCH] fix sys_prctl() returned uninitialized value, Andrew G. Morgan, (Thu May 22, 1:01 am)
Re: [PATCH] fix sys_prctl() returned uninitialized value, Andrew Morton, (Thu May 22, 1:25 am)
Re: [PATCH] fix sys_prctl() returned uninitialized value, Serge E. Hallyn, (Thu May 22, 3:17 pm)
Re: [PATCH] fix sys_prctl() returned uninitialized value, Andrew G. Morgan, (Thu May 22, 9:07 am)
Re: [PATCH] fix sys_prctl() returned uninitialized value, Andrew Morton, (Thu May 22, 1:15 am)