Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1d8c2326 authored by Łukasz Stelmach's avatar Łukasz Stelmach Committed by Casey Schaufler
Browse files

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: default avatarŁukasz Stelmach <l.stelmach@samsung.com>
parent 68390ccf
Loading
Loading
Loading
Loading
+14 −2
Original line number Original line Diff line number Diff line
@@ -3036,7 +3036,8 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode)
	 * of the superblock.
	 * of the superblock.
	 */
	 */
	if (opt_dentry->d_parent == opt_dentry) {
	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,
			 * The cgroup filesystem is never mounted,
			 * so there's no opportunity to set the mount
			 * so there's no opportunity to set the mount
@@ -3044,8 +3045,19 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode)
			 */
			 */
			sbsp->smk_root = &smack_known_star;
			sbsp->smk_root = &smack_known_star;
			sbsp->smk_default = &smack_known_star;
			sbsp->smk_default = &smack_known_star;
		}
			isp->smk_inode = sbsp->smk_root;
			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_flags |= SMK_INODE_INSTANT;
		isp->smk_flags |= SMK_INODE_INSTANT;
		goto unlockandout;
		goto unlockandout;
	}
	}