summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorŁukasz Stelmach <l.stelmach@samsung.com>2014-12-10 07:29:46 +0100
committerMaciej Wereski <m.wereski@partner.samsung.com>2014-12-22 09:16:36 +0100
commit788eed54f7d6095424b31113d81c1e141aadb88e (patch)
treee9a63cb76556358fc5c708d0c7dfbc34b6f0ddbc
parentf099ada53bfdb89e6c4806832e5bce9add524d6b (diff)
downloadlinux-3.10-788eed54f7d6095424b31113d81c1e141aadb88e.tar.gz
linux-3.10-788eed54f7d6095424b31113d81c1e141aadb88e.tar.bz2
linux-3.10-788eed54f7d6095424b31113d81c1e141aadb88e.zip
smack: introduce a special case for tmpfs in smack_d_instantiate()
Files created with __shmem_file_stup() appear to have somewhat fake dentries which make them look like root directories and not get the label the current process or ("*") star meant for tmpfs files. Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
-rw-r--r--security/smack/smack_lsm.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 0d1d09f5173..f9f89327896 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -2724,7 +2724,8 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode)
* of the superblock.
*/
if (opt_dentry->d_parent == opt_dentry) {
- if (sbp->s_magic == CGROUP_SUPER_MAGIC) {
+ switch (sbp->s_magic) {
+ case CGROUP_SUPER_MAGIC:
/*
* The cgroup filesystem is never mounted,
* so there's no opportunity to set the mount
@@ -2732,8 +2733,19 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode)
*/
sbsp->smk_root = smack_known_star.smk_known;
sbsp->smk_default = smack_known_star.smk_known;
+ isp->smk_inode = sbsp->smk_root;
+ break;
+ case TMPFS_MAGIC:
+ /*
+ * What about shmem/tmpfs anonymous files with dentry
+ * obtained from d_alloc_pseudo()?
+ */
+ isp->smk_inode = smk_of_current();
+ break;
+ default:
+ isp->smk_inode = sbsp->smk_root;
+ break;
}
- isp->smk_inode = sbsp->smk_root;
isp->smk_flags |= SMK_INODE_INSTANT;
goto unlockandout;
}