mirror of
https://github.com/torvalds/linux.git
synced 2024-11-01 09:41:44 +00:00
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 <eparis@redhat.com> Acked-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: James Morris <jmorris@namei.org>
This commit is contained in:
parent
4ba0a8ad63
commit
4cb912f1d1
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user