diff options
| author | Łukasz Stelmach <l.stelmach@samsung.com> | 2014-12-16 10:53:08 -0500 |
|---|---|---|
| committer | Casey Schaufler <casey@schaufler-ca.com> | 2015-01-19 12:58:02 -0500 |
| commit | 1d8c2326a4a2a4d942f9165b5702fe6f869ccf48 (patch) | |
| tree | 73feff9476c237bb3bb5df51f7529217fa2768ab | |
| parent | 68390ccf8b0a3470032f053d50379cfd49fbe952 (diff) | |
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.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 048d92e81a34..2160e88a2e4e 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c | |||
| @@ -3036,7 +3036,8 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode) | |||
| 3036 | * of the superblock. | 3036 | * of the superblock. |
| 3037 | */ | 3037 | */ |
| 3038 | if (opt_dentry->d_parent == opt_dentry) { | 3038 | if (opt_dentry->d_parent == opt_dentry) { |
| 3039 | if (sbp->s_magic == CGROUP_SUPER_MAGIC) { | 3039 | switch (sbp->s_magic) { |
| 3040 | case CGROUP_SUPER_MAGIC: | ||
| 3040 | /* | 3041 | /* |
| 3041 | * The cgroup filesystem is never mounted, | 3042 | * The cgroup filesystem is never mounted, |
| 3042 | * so there's no opportunity to set the mount | 3043 | * 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) | |||
| 3044 | */ | 3045 | */ |
| 3045 | sbsp->smk_root = &smack_known_star; | 3046 | sbsp->smk_root = &smack_known_star; |
| 3046 | sbsp->smk_default = &smack_known_star; | 3047 | sbsp->smk_default = &smack_known_star; |
| 3048 | isp->smk_inode = sbsp->smk_root; | ||
| 3049 | break; | ||
| 3050 | case TMPFS_MAGIC: | ||
| 3051 | /* | ||
| 3052 | * What about shmem/tmpfs anonymous files with dentry | ||
| 3053 | * obtained from d_alloc_pseudo()? | ||
| 3054 | */ | ||
| 3055 | isp->smk_inode = smk_of_current(); | ||
| 3056 | break; | ||
| 3057 | default: | ||
| 3058 | isp->smk_inode = sbsp->smk_root; | ||
| 3059 | break; | ||
| 3047 | } | 3060 | } |
| 3048 | isp->smk_inode = sbsp->smk_root; | ||
| 3049 | isp->smk_flags |= SMK_INODE_INSTANT; | 3061 | isp->smk_flags |= SMK_INODE_INSTANT; |
| 3050 | goto unlockandout; | 3062 | goto unlockandout; |
| 3051 | } | 3063 | } |
