Re: general protection fault: 0000 [#1] SMP

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jesper Juhl
Date: Saturday, November 20, 2010 - 3:28 pm

On Sat, 20 Nov 2010, Justin Mattock wrote:

[...]

Hmm, ok, I have no idea about the root cause of this problem, but I did 
notice one thing about selinux_cred_free() that's different than most 
other freeing functions in the kernel. It does not accept a NULL value.
Most other freeing functions will just return if passed NULL, but 
selinux_cred_free() will crash.
I wonder if it would make sense to add a NULL 'short circuit' to that 
function? If so, please pick up the patch below.


Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 hooks.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 65fa8bf..d088532 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3193,11 +3193,11 @@ static int selinux_cred_alloc_blank(struct cred *cred, gfp_t gfp)
  */
 static void selinux_cred_free(struct cred *cred)
 {
-	struct task_security_struct *tsec = cred->security;
-
+	if (!cred)
+		return;
 	BUG_ON((unsigned long) cred->security < PAGE_SIZE);
 	cred->security = (void *) 0x7UL;
-	kfree(tsec);
+	kfree(cred->security);
 }
 
 /*


-- 
Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.

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

Messages in current thread:
general protection fault: 0000 [#1] SMP, Justin Mattock, (Sat Nov 20, 9:35 am)
Re: general protection fault: 0000 [#1] SMP, Jesper Juhl, (Sat Nov 20, 3:28 pm)
Re: general protection fault: 0000 [#1] SMP, Jesper Juhl, (Sat Nov 20, 3:32 pm)
Re: general protection fault: 0000 [#1] SMP, Justin P. Mattock, (Sat Nov 20, 4:21 pm)
Re: general protection fault: 0000 [#1] SMP, Justin P. Mattock, (Mon Nov 22, 12:01 pm)
Re: general protection fault: 0000 [#1] SMP, Hugh Dickins, (Mon Nov 22, 1:25 pm)
Re: general protection fault: 0000 [#1] SMP, Justin P. Mattock, (Mon Nov 22, 2:44 pm)