Re: [PATCH v2] smack: introduce a special case for tmpfs in smack_d_instantiate()

From: Casey Schaufler
Date: Tue Dec 16 2014 - 11:38:45 EST


On 12/16/2014 7:53 AM, Åukasz Stelmach wrote:
> 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@xxxxxxxxxxx>

Applied to git://git.gitorious.org/smack-next/kernel.git#smack-for-3.20

> ---
> security/smack/smack_lsm.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index e8bed86..b774029 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -3036,18 +3036,30 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode)
> * If that is the case use the root value out
> * 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
> * options.
> */
> 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;
> }
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/