lkml.org 
[lkml]   [2010]   [May]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 1/3] sys_personality: validate personality before set_personality()
sys_personality(personality) is obviously wrong. It calls set_personality()
which always sets current->personality = personality and then does

if (current->personality != personality)
return -EINVAL;

If this "u_long" argument doesn't fit into "unsigned int" ->personality,
we return -EINVAL but change the caller's ->personality.

Move this check up to ensure the overflow is not possible, before calling
set_personality() which never fails.

Pointed-out-by: Wenming Zhang <wezhang@redhat.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---

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

--- 34-rc1/kernel/exec_domain.c~1_CK_OVERFLOW_EARLIER 2009-04-06 00:03:42.000000000 +0200
+++ 34-rc1/kernel/exec_domain.c 2010-05-27 15:15:12.000000000 +0200
@@ -193,9 +193,9 @@ SYSCALL_DEFINE1(personality, u_long, per
u_long old = current->personality;

if (personality != 0xffffffff) {
- set_personality(personality);
- if (current->personality != personality)
+ if ((unsigned int)personality != personality)
return -EINVAL;
+ set_personality(personality);
}

return (long)old;


\
 
 \ /
  Last update: 2010-05-27 17:39    [W:0.200 / U:0.372 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site