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

From: Andrew G. Morgan
Date: Thu May 22 2008 - 01:01:31 EST

Hash: SHA1

Looks like I goofed here. :*(

Andrew Morton wrote:
| Oh dear, there are so many things wrong with this...
| - if security_task_prctl() is returning "fail" then why on earth
| isn't it setting the error code?

Its not failing, as Shi points out in their patch preamble, its simply
passing-through - security_task_prctl() doesn't implement the requested
PR_* code, so it expects something else (sys_prctl() proper) to set this

| - cap_task_prctl() _does_ set `error' is if returns non-zero, so it
| must be one of the other myriad backend implementations of
| security_task_prctl() which is busted. Which one is it?

None of them. In this case, none of the security modules implement the
requested PRCTL.

| - With the above patch applied, sys_prctl() will return zero (ie:
| "success") even though it just failed.

Not sure what you mean here. The switch statement only sets a non-zero
value for error on a failing path. It assumes that the error value is
initially zero.

| - Can't we remove the sixth argument to security_task_prctl() and
| just return the result code like a sane function would do?

A bunch of capability related prctl()s will cease to work.

I'd prefer the attached patch, but I don't object to Shi's. In which case:

~ Acked-by: Andrew G. Morgan <morgan@xxxxxxxxxx>



Version: GnuPG v1.2.6 (GNU/Linux)

From 5064e50b4a10cef2fe48a5716ffb3845488f0a14 Mon Sep 17 00:00:00 2001
From: Andrew G. Morgan <morgan@xxxxxxxxxx>
Date: Wed, 21 May 2008 21:46:35 -0700
Subject: [PATCH] Bug fix: default error to success

this is the default expected by the subsequent switch ().

Signed-off-by: Andrew G. Morgan <morgan@xxxxxxxxxx>
kernel/sys.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/kernel/sys.c b/kernel/sys.c
index 895d2d4..cb25a64 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1657,6 +1657,8 @@ asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3,
if (security_task_prctl(option, arg2, arg3, arg4, arg5, &error))
return error;

+ error = 0;
switch (option) {
if (!valid_signal(arg2)) {