diff options
| author | Eric Paris <[email protected]> | 2009-02-12 19:50:05 +0000 |
|---|---|---|
| committer | James Morris <[email protected]> | 2009-02-13 22:22:30 +0000 |
| commit | 4cb912f1d1447077160ace9ce3b3a10696dd74e5 (patch) | |
| tree | 916f112de07ca626b0f398a0fc85943f15306146 /security/selinux/hooks.c | |
| parent | SELinux: better printk when file with invalid label found (diff) | |
| download | kernel-4cb912f1d1447077160ace9ce3b3a10696dd74e5.tar.gz kernel-4cb912f1d1447077160ace9ce3b3a10696dd74e5.zip | |
SELinux: NULL terminate al contexts from disk
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 <[email protected]>
Acked-by: Stephen Smalley <[email protected]>
Signed-off-by: James Morris <[email protected]>
Diffstat (limited to 'security/selinux/hooks.c')
| -rw-r--r-- | 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 aebcfad5613f..309648c573d8 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1270,12 +1270,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) { @@ -1288,12 +1289,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); |
