All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] SELinux: NULL terminate al contexts from disk
@ 2009-02-12 19:50 Eric Paris
  2009-02-12 19:50 ` [PATCH 2/2] SELinux: check seqno when updating an avc_node Eric Paris
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Eric Paris @ 2009-02-12 19:50 UTC (permalink / raw)
  To: selinux; +Cc: sds, jmorris, paul.moore

When a context is pulled in from disk we don't know that it is null
terminated.  This patch forecebly null terminates contexts when we pull
them from disk.

Signed-off-by: Eric Paris <eparis@redhat.com>
---

 security/selinux/hooks.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 45e286c..4afaeac 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -1290,12 +1290,13 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
 		}
 
 		len = INITCONTEXTLEN;
-		context = kmalloc(len, GFP_NOFS);
+		context = kmalloc(len+1, GFP_NOFS);
 		if (!context) {
 			rc = -ENOMEM;
 			dput(dentry);
 			goto out_unlock;
 		}
+		context[len] = '\0';
 		rc = inode->i_op->getxattr(dentry, XATTR_NAME_SELINUX,
 					   context, len);
 		if (rc == -ERANGE) {
@@ -1308,12 +1309,13 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
 			}
 			kfree(context);
 			len = rc;
-			context = kmalloc(len, GFP_NOFS);
+			context = kmalloc(len+1, GFP_NOFS);
 			if (!context) {
 				rc = -ENOMEM;
 				dput(dentry);
 				goto out_unlock;
 			}
+			context[len] = '\0';
 			rc = inode->i_op->getxattr(dentry,
 						   XATTR_NAME_SELINUX,
 						   context, len);


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-02-13 22:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-12 19:50 [PATCH 1/2] SELinux: NULL terminate al contexts from disk Eric Paris
2009-02-12 19:50 ` [PATCH 2/2] SELinux: check seqno when updating an avc_node Eric Paris
2009-02-13 14:07   ` Stephen Smalley
2009-02-13 15:06     ` Eric Paris
2009-02-13 20:19       ` Stephen Smalley
2009-02-13 20:19   ` Stephen Smalley
2009-02-13 22:44   ` James Morris
2009-02-12 20:46 ` [PATCH 1/2] SELinux: NULL terminate al contexts from disk Paul Moore
2009-02-13 13:50 ` Stephen Smalley
2009-02-13 22:43 ` James Morris

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.