From: Łukasz Stelmach Date: Tue, 16 Dec 2014 15:53:08 +0000 (+0100) Subject: smack: introduce a special case for tmpfs in smack_d_instantiate() X-Git-Tag: submit/tizen_common/20151126.162616~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e1223282b3ef67848d616d3b6d39bf8a276a51a6;p=sdk%2Femulator%2Femulator-kernel.git 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. Change-Id: I05c13597e8a26524a7b0c3a3686f64d4ff71deaf Signed-off-by: Łukasz Stelmach --- diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 3f2a50cbdddc..d90a3bccaaa6 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -3037,7 +3037,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 @@ -3045,8 +3046,19 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode) */ sbsp->smk_root = &smack_known_star; sbsp->smk_default = &smack_known_star; + 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; }