* [PATCH v2] smack: introduce a special case for tmpfs in smack_d_instantiate()
@ 2014-12-16 15:53 Łukasz Stelmach
2014-12-16 16:38 ` Casey Schaufler
0 siblings, 1 reply; 2+ messages in thread
From: Łukasz Stelmach @ 2014-12-16 15:53 UTC (permalink / raw)
To: Casey Schaufler, James Morris, Serge E. Hallyn,
linux-security-module, linux-kernel
Cc: Karol Lewandowski, l.skalski, m.wereski, r.krypa,
Łukasz Stelmach
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>
---
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;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] smack: introduce a special case for tmpfs in smack_d_instantiate()
2014-12-16 15:53 [PATCH v2] smack: introduce a special case for tmpfs in smack_d_instantiate() Łukasz Stelmach
@ 2014-12-16 16:38 ` Casey Schaufler
0 siblings, 0 replies; 2+ messages in thread
From: Casey Schaufler @ 2014-12-16 16:38 UTC (permalink / raw)
To: Łukasz Stelmach, James Morris, Serge E. Hallyn,
linux-security-module, linux-kernel
Cc: Karol Lewandowski, l.skalski, m.wereski, r.krypa, Casey Schaufler
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@samsung.com>
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;
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-12-16 16:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-16 15:53 [PATCH v2] smack: introduce a special case for tmpfs in smack_d_instantiate() Łukasz Stelmach
2014-12-16 16:38 ` Casey Schaufler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox