vfs: fix mounting a filesystem with i_version
diff mbox

Message ID 1507436901.5841.4.camel@linux.vnet.ibm.com
State New
Headers show

Commit Message

Mimi Zohar Oct. 8, 2017, 4:28 a.m. UTC
The mount i_version flag is not enabled in the new sb_flags.  This patch
adds the missing SB_I_VERSION flag.

Fixes: e462ec5 "VFS: Differentiate mount flags (MS_*) from internal
       superblock flags"
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
---
 fs/namespace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Christoph Hellwig Oct. 8, 2017, 8:58 a.m. UTC | #1
On Sun, Oct 08, 2017 at 12:28:21AM -0400, Mimi Zohar wrote:
> The mount i_version flag is not enabled in the new sb_flags.  This patch
> adds the missing SB_I_VERSION flag.
> 
> Fixes: e462ec5 "VFS: Differentiate mount flags (MS_*) from internal
>        superblock flags"
> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
> ---
>  fs/namespace.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/namespace.c b/fs/namespace.c
> index 3b601f115b6c..d18deb4c410b 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -2825,7 +2825,8 @@ long do_mount(const char *dev_name, const char __user *dir_name,
>  			    SB_MANDLOCK |
>  			    SB_DIRSYNC |
>  			    SB_SILENT |
> -			    SB_POSIXACL);
> +			    SB_POSIXACL |
> +			    SB_I_VERSION);

The problem is that the whole masking there is a piece of crap.

It assumes that MS_* and SB_* flags have the same numeric values,
which is bound to create a major problem rather sooner than later.

What we need is a separate __bitwise type for SB_*, translated them
here and treat them as a separate namespaces.
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mimi Zohar Oct. 8, 2017, 12:54 p.m. UTC | #2
On Sun, 2017-10-08 at 01:58 -0700, Christoph Hellwig wrote:
> On Sun, Oct 08, 2017 at 12:28:21AM -0400, Mimi Zohar wrote:
> > The mount i_version flag is not enabled in the new sb_flags.  This patch
> > adds the missing SB_I_VERSION flag.
> > 
> > Fixes: e462ec5 "VFS: Differentiate mount flags (MS_*) from internal
> >        superblock flags"
> > Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
> > ---
> >  fs/namespace.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/fs/namespace.c b/fs/namespace.c
> > index 3b601f115b6c..d18deb4c410b 100644
> > --- a/fs/namespace.c
> > +++ b/fs/namespace.c
> > @@ -2825,7 +2825,8 @@ long do_mount(const char *dev_name, const char __user *dir_name,
> >  			    SB_MANDLOCK |
> >  			    SB_DIRSYNC |
> >  			    SB_SILENT |
> > -			    SB_POSIXACL);
> > +			    SB_POSIXACL |
> > +			    SB_I_VERSION);
> 
> The problem is that the whole masking there is a piece of crap.
> 
> It assumes that MS_* and SB_* flags have the same numeric values,
> which is bound to create a major problem rather sooner than later.

According to the original commit, separating them is just the first
step.  This patch fixes that first step so that filesystems can be
mounted with i_version.

Mimi

> What we need is a separate __bitwise type for SB_*, translated them
> here and treat them as a separate namespaces.
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
James Morris Oct. 8, 2017, 10:24 p.m. UTC | #3
cc: Al Viro.


On Sun, 8 Oct 2017, Mimi Zohar wrote:

> The mount i_version flag is not enabled in the new sb_flags.  This patch
> adds the missing SB_I_VERSION flag.
> 
> Fixes: e462ec5 "VFS: Differentiate mount flags (MS_*) from internal
>        superblock flags"
> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
> ---
>  fs/namespace.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/namespace.c b/fs/namespace.c
> index 3b601f115b6c..d18deb4c410b 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -2825,7 +2825,8 @@ long do_mount(const char *dev_name, const char __user *dir_name,
>  			    SB_MANDLOCK |
>  			    SB_DIRSYNC |
>  			    SB_SILENT |
> -			    SB_POSIXACL);
> +			    SB_POSIXACL |
> +			    SB_I_VERSION);
>  
>  	if (flags & MS_REMOUNT)
>  		retval = do_remount(&path, flags, sb_flags, mnt_flags,
>
Mimi Zohar Oct. 11, 2017, 12:28 p.m. UTC | #4
Hi Al,

This patch fixes a regression.  Without it, you can't mount a file
system with i_version.  This obviously affects IMA.  Could you pick up
this patch and forward it to Linus please?

Commit dd924ea17c0c "vfs: fix mounting a filesystem with i_version"
can be found in my git repo.

thanks,

Mimi


On Mon, 2017-10-09 at 09:24 +1100, James Morris wrote:
> cc: Al Viro.
> 
> 
> On Sun, 8 Oct 2017, Mimi Zohar wrote:
> 
> > The mount i_version flag is not enabled in the new sb_flags.  This patch
> > adds the missing SB_I_VERSION flag.
> > 
> > Fixes: e462ec5 "VFS: Differentiate mount flags (MS_*) from internal
> >        superblock flags"
> > Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
> > ---
> >  fs/namespace.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/fs/namespace.c b/fs/namespace.c
> > index 3b601f115b6c..d18deb4c410b 100644
> > --- a/fs/namespace.c
> > +++ b/fs/namespace.c
> > @@ -2825,7 +2825,8 @@ long do_mount(const char *dev_name, const char __user *dir_name,
> >  			    SB_MANDLOCK |
> >  			    SB_DIRSYNC |
> >  			    SB_SILENT |
> > -			    SB_POSIXACL);
> > +			    SB_POSIXACL |
> > +			    SB_I_VERSION);
> >  
> >  	if (flags & MS_REMOUNT)
> >  		retval = do_remount(&path, flags, sb_flags, mnt_flags,
> > 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/fs/namespace.c b/fs/namespace.c
index 3b601f115b6c..d18deb4c410b 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2825,7 +2825,8 @@  long do_mount(const char *dev_name, const char __user *dir_name,
 			    SB_MANDLOCK |
 			    SB_DIRSYNC |
 			    SB_SILENT |
-			    SB_POSIXACL);
+			    SB_POSIXACL |
+			    SB_I_VERSION);
 
 	if (flags & MS_REMOUNT)
 		retval = do_remount(&path, flags, sb_flags, mnt_flags,