diff options
author | Alex Shi <alex.shi@linaro.org> | 2014-04-15 09:57:50 +0800 |
---|---|---|
committer | Alex Shi <alex.shi@linaro.org> | 2014-04-15 09:57:50 +0800 |
commit | dc65fae3f730b6a1888f5559d68e59111f013c4f (patch) | |
tree | 019e33c310553116b5b64042820bfb007b0fa832 /security/selinux/hooks.c | |
parent | 5ad6d9ba813e2a36b624970f7e5beb4e12641bee (diff) | |
parent | f512eefd5cde0ad21bd99bbfe4dc70b62805838e (diff) |
Merge tag 'v3.10.37' into linux-linaro-lsk
This is the 3.10.37 stable release
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r-- | security/selinux/hooks.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index a7096e130c0..70d4a8a7f21 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1361,15 +1361,33 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent isec->sid = sbsec->sid; if ((sbsec->flags & SE_SBPROC) && !S_ISLNK(inode->i_mode)) { - if (opt_dentry) { - isec->sclass = inode_mode_to_security_class(inode->i_mode); - rc = selinux_proc_get_sid(opt_dentry, - isec->sclass, - &sid); - if (rc) - goto out_unlock; - isec->sid = sid; - } + /* We must have a dentry to determine the label on + * procfs inodes */ + if (opt_dentry) + /* Called from d_instantiate or + * d_splice_alias. */ + dentry = dget(opt_dentry); + else + /* Called from selinux_complete_init, try to + * find a dentry. */ + dentry = d_find_alias(inode); + /* + * This can be hit on boot when a file is accessed + * before the policy is loaded. When we load policy we + * may find inodes that have no dentry on the + * sbsec->isec_head list. No reason to complain as + * these will get fixed up the next time we go through + * inode_doinit() with a dentry, before these inodes + * could be used again by userspace. + */ + if (!dentry) + goto out_unlock; + isec->sclass = inode_mode_to_security_class(inode->i_mode); + rc = selinux_proc_get_sid(dentry, isec->sclass, &sid); + dput(dentry); + if (rc) + goto out_unlock; + isec->sid = sid; } break; } |