2006-05-17 22:19:09

by Chris Wright

[permalink] [raw]
Subject: [PATCH 11/22] [PATCH] selinux: check for failed kmalloc in security_sid_to_context()

-stable review patch. If anyone has any objections, please let us know.
------------------

Check for NULL kmalloc return value before writing to it.

Signed-off-by: "Serge E. Hallyn" <[email protected]>
Acked-by: James Morris <[email protected]>
Cc: Stephen Smalley <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Signed-off-by: Chris Wright <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---

security/selinux/ss/services.c | 4 ++++
1 file changed, 4 insertions(+)

--- linux-2.6.16.16.orig/security/selinux/ss/services.c
+++ linux-2.6.16.16/security/selinux/ss/services.c
@@ -592,6 +592,10 @@ int security_sid_to_context(u32 sid, cha

*scontext_len = strlen(initial_sid_to_string[sid]) + 1;
scontextp = kmalloc(*scontext_len,GFP_ATOMIC);
+ if (!scontextp) {
+ rc = -ENOMEM;
+ goto out;
+ }
strcpy(scontextp, initial_sid_to_string[sid]);
*scontext = scontextp;
goto out;

--