Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1681592 > unrolled thread

[RFC][PATCH 00/14] VFS: Make all filesystems implement ->show_options()

Started byDavid Howells <dhowells@redhat.com>
First post2017-07-05 17:30 +0200
Last post2017-07-08 17:40 +0200
Articles 14 — 5 participants

Back to article view | Back to linux.kernel


Contents

  [RFC][PATCH 00/14] VFS: Make all filesystems implement  ->show_options() David Howells <dhowells@redhat.com> - 2017-07-05 17:30 +0200
    [PATCH 11/14] isofs: Implement show_options David Howells <dhowells@redhat.com> - 2017-07-05 17:30 +0200
      [PATCH] isofs: Fix isofs_show_options() David Howells <dhowells@redhat.com> - 2017-07-11 17:30 +0200
    [PATCH 04/14] pstore: Implement show_options David Howells <dhowells@redhat.com> - 2017-07-05 17:30 +0200
      Re: [PATCH 04/14] pstore: Implement show_options Kees Cook <keescook@chromium.org> - 2017-07-05 19:20 +0200
        Re: [PATCH 04/14] pstore: Implement show_options David Howells <dhowells@redhat.com> - 2017-07-07 18:10 +0200
    [PATCH 07/14] spufs: Implement show_options David Howells <dhowells@redhat.com> - 2017-07-05 17:30 +0200
    [PATCH 10/14] afs: Implement show_options David Howells <dhowells@redhat.com> - 2017-07-05 17:30 +0200
    [PATCH 08/14] befs: Implement show_options David Howells <dhowells@redhat.com> - 2017-07-05 17:30 +0200
    [PATCH 06/14] bpf: Implement show_options David Howells <dhowells@redhat.com> - 2017-07-05 17:30 +0200
      Re: [PATCH 06/14] bpf: Implement show_options Daniel Borkmann <daniel@iogearbox.net> - 2017-07-06 10:10 +0200
    Re: [RFC][PATCH 00/14] VFS: Make all filesystems implement ->show_options() ebiederm@xmission.com (Eric W. Biederman) - 2017-07-05 18:50 +0200
      Re: [RFC][PATCH 00/14] VFS: Make all filesystems implement ->show_options() David Howells <dhowells@redhat.com> - 2017-07-07 18:00 +0200
        Re: [RFC][PATCH 00/14] VFS: Make all filesystems implement  ->show_options() Theodore Ts'o <tytso@mit.edu> - 2017-07-08 17:40 +0200

#1681592 — [RFC][PATCH 00/14] VFS: Make all filesystems implement ->show_options()

FromDavid Howells <dhowells@redhat.com>
Date2017-07-05 17:30 +0200
Subject[RFC][PATCH 00/14] VFS: Make all filesystems implement ->show_options()
Message-ID<tZUpz-83i-3@gated-at.bofh.it>
Here's a set of patches that:

 (1) Removes calls to save/replace_mount_options() where the filesystem
     then implements ->show_options() anyway, ignoring ->s_options.

 (2) Makes all filesystems implement the ->show_options() superblock
     operation rather than using generic_show_options().  If necessary,
     extra information is stored in the superblock information.

 (3) Deletes save_mount_options(), replace_mount_options(),
     generic_show_options() and super_block::s_options.

This makes it easier to implement a context-based mount where the options
are passed individually over a file descriptor.  It also allows duplicate
options, options that override each other and ignored options to be
resolved rather than storing irrelevant data.

Further, a lot of the time, all the information we want to display is
stored in the super block information anyway, so the option string is
redundant.

Some things I noted whilst doing this:

 (1) A number of filesystems take uid/gid options.  Should these be
     reported relative to the observer's user namespace rather than init's
     user namespace?  After all, you can't then use those uid/gid options
     if the numbers are interpreted incorrectly if you try and forge a
     mount command from them.

 (2) Should I provide a helper for displaying uid/gid options?

 (3) How much do we need to worry about racing with remount?  Some
     filesystems happily give out the contents of the super_block without
     regard to the fact that remount might be changing it simultaneously -
     ext4, for example.

 (4) What string options actually need 'munging'?

These patches can be found here:

	https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=for-viro

on top of three other minor patches.

David
---
David Howells (14):
      VFS: Don't use save/replace_mount_options if not using generic_show_options
      hugetlbfs: Implement show_options
      omfs: Implement show_options
      pstore: Implement show_options
      ramfs: Implement show_options
      bpf: Implement show_options
      spufs: Implement show_options
      befs: Implement show_options
      affs: Implement show_options
      afs: Implement show_options
      isofs: Implement show_options
      9p: Implement show_options
      orangefs: Implement show_options
      VFS: Kill off s_options and helpers


 Documentation/filesystems/vfs.txt         |    6 --
 arch/powerpc/platforms/cell/spufs/inode.c |   21 +++++++--
 fs/9p/v9fs.c                              |   59 ++++++++++++++++++++++++
 fs/9p/v9fs.h                              |    3 +
 fs/9p/vfs_super.c                         |    6 +-
 fs/affs/super.c                           |   42 +++++++++++++++--
 fs/afs/super.c                            |   45 ++++++++++++++++++-
 fs/befs/linuxvfs.c                        |   24 +++++++++-
 fs/btrfs/super.c                          |    1 
 fs/debugfs/inode.c                        |    2 -
 fs/efivarfs/super.c                       |    1 
 fs/hugetlbfs/inode.c                      |   70 +++++++++++++++++++++++------
 fs/isofs/inode.c                          |   51 ++++++++++++++++++++-
 fs/isofs/isofs.h                          |    3 +
 fs/namespace.c                            |   59 ------------------------
 fs/omfs/inode.c                           |   33 ++++++++++++--
 fs/orangefs/super.c                       |   15 ++++++
 fs/pstore/inode.c                         |   14 +++++-
 fs/pstore/internal.h                      |    3 +
 fs/pstore/platform.c                      |    2 -
 fs/ramfs/inode.c                          |   32 +++++++++----
 fs/reiserfs/super.c                       |    4 --
 fs/super.c                                |    1 
 fs/tracefs/inode.c                        |    2 -
 include/linux/fs.h                        |    9 ----
 include/linux/hugetlb.h                   |    3 +
 include/net/9p/client.h                   |   13 +++++
 include/net/9p/transport.h                |    1 
 kernel/bpf/inode.c                        |   16 +++++--
 net/9p/client.c                           |   25 ++++++++++
 net/9p/trans_fd.c                         |   31 ++++++++++++-
 net/9p/trans_rdma.c                       |   31 ++++++++++++-
 32 files changed, 481 insertions(+), 147 deletions(-)

[toc] | [next] | [standalone]


#1681594 — [PATCH 11/14] isofs: Implement show_options

FromDavid Howells <dhowells@redhat.com>
Date2017-07-05 17:30 +0200
Subject[PATCH 11/14] isofs: Implement show_options
Message-ID<tZUpA-83i-31@gated-at.bofh.it>
In reply to#1681592
Implement the show_options superblock op for omfs as part of a bid to get
rid of s_options and generic_show_options() to make it easier to implement
a context-based mount where the mount options can be passed individually
over a file descriptor.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Jan Kara <jack@suse.cz>
---

 fs/isofs/inode.c |   51 ++++++++++++++++++++++++++++++++++++++++++++++++---
 fs/isofs/isofs.h |    3 +++
 2 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 020ba0936146..f80ee600d1bc 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -23,6 +23,7 @@
 #include <linux/parser.h>
 #include <linux/mpage.h>
 #include <linux/user_namespace.h>
+#include <linux/seq_file.h>
 
 #include "isofs.h"
 #include "zisofs.h"
@@ -57,6 +58,7 @@ static void isofs_put_super(struct super_block *sb)
 
 static int isofs_read_inode(struct inode *, int relocated);
 static int isofs_statfs (struct dentry *, struct kstatfs *);
+static int isofs_show_options(struct seq_file *, struct dentry *);
 
 static struct kmem_cache *isofs_inode_cachep;
 
@@ -123,7 +125,7 @@ static const struct super_operations isofs_sops = {
 	.put_super	= isofs_put_super,
 	.statfs		= isofs_statfs,
 	.remount_fs	= isofs_remount,
-	.show_options	= generic_show_options,
+	.show_options	= isofs_show_options,
 };
 
 
@@ -473,6 +475,48 @@ static int parse_options(char *options, struct iso9660_options *popt)
 }
 
 /*
+ * Display the mount options in /proc/mounts.
+ */
+static int isofs_show_options(struct seq_file *m, struct dentry *root)
+{
+	struct isofs_sb_info *sbi = ISOFS_SB(root->d_sb);
+
+	if (!sbi->s_rock)		seq_puts(m, ",norock");
+	else if (!sbi->s_joliet_level)	seq_puts(m, ",nojoliet");
+	if (sbi->s_cruft)		seq_puts(m, ",cruft");
+	if (sbi->s_hide)		seq_puts(m, ",hide");
+	if (sbi->s_nocompress)		seq_puts(m, ",nocompress");
+	if (sbi->s_overriderockperm)	seq_puts(m, ",overriderockperm");
+	if (sbi->s_showassoc)		seq_puts(m, ",showassoc");
+	if (sbi->s_utf8)		seq_puts(m, ",utf8");
+
+	if (sbi->s_check)		seq_printf(m, ",check=%c", sbi->s_check);
+	if (sbi->s_mapping)		seq_printf(m, ",map=%c", sbi->s_mapping);
+	if (sbi->s_session != -1)	seq_printf(m, ",session=%u", sbi->s_session);
+	if (sbi->s_sbsector != -1)	seq_printf(m, ",sbsector=%u", sbi->s_sbsector);
+
+	if (root->d_sb->s_blocksize != 1024)
+		seq_printf(m, ",blocksize=%lu", root->d_sb->s_blocksize);
+
+	if (sbi->s_uid_set)
+		seq_printf(m, ",uid=%u",
+			   from_kuid_munged(&init_user_ns, sbi->s_uid));
+	if (sbi->s_gid_set)
+		seq_printf(m, ",gid=%u",
+			   from_kgid_munged(&init_user_ns, sbi->s_gid));
+
+	if (sbi->s_dmode != ISOFS_INVALID_MODE)
+		seq_printf(m, ",dmode=%o", sbi->s_dmode);
+	if (sbi->s_fmode != ISOFS_INVALID_MODE)
+		seq_printf(m, ",fmode=%o", sbi->s_fmode);
+
+	if (sbi->s_nls_iocharset &&
+	    strcmp(sbi->s_nls_iocharset->charset, CONFIG_NLS_DEFAULT) != 0)
+		seq_printf(m, ",iocharset=%s", sbi->s_nls_iocharset->charset);
+	return 0;
+}
+
+/*
  * look if the driver can tell the multi session redirection value
  *
  * don't change this if you don't know what you do, please!
@@ -583,8 +627,6 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
 	int table, error = -EINVAL;
 	unsigned int vol_desc_start;
 
-	save_mount_options(s, data);
-
 	sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
 	if (!sbi)
 		return -ENOMEM;
@@ -605,6 +647,8 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
 	opt.blocksize = sb_min_blocksize(s, opt.blocksize);
 
 	sbi->s_high_sierra = 0; /* default is iso9660 */
+	sbi->s_session = opt.session;
+	sbi->s_sbsector = opt.sbsector;
 
 	vol_desc_start = (opt.sbsector != -1) ?
 		opt.sbsector : isofs_get_last_session(s,opt.session);
@@ -911,6 +955,7 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
 		table += 2;
 	if (opt.check == 'r')
 		table++;
+	sbi->s_check = opt.check;
 
 	if (table)
 		s->s_d_op = &isofs_dentry_ops[table - 1];
diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h
index 0ac4c1f73fbd..133a456b0425 100644
--- a/fs/isofs/isofs.h
+++ b/fs/isofs/isofs.h
@@ -36,8 +36,11 @@ struct isofs_sb_info {
 	unsigned long s_max_size;
 	
 	int           s_rock_offset; /* offset of SUSP fields within SU area */
+	s32           s_sbsector;
 	unsigned char s_joliet_level;
 	unsigned char s_mapping;
+	unsigned char s_check;
+	unsigned char s_session;
 	unsigned int  s_high_sierra:1;
 	unsigned int  s_rock:2;
 	unsigned int  s_utf8:1;

[toc] | [prev] | [next] | [standalone]


#1685136 — [PATCH] isofs: Fix isofs_show_options()

FromDavid Howells <dhowells@redhat.com>
Date2017-07-11 17:30 +0200
Subject[PATCH] isofs: Fix isofs_show_options()
Message-ID<u25gS-41E-7@gated-at.bofh.it>
In reply to#1681594
Hi Al,

The isofs patch needs a small fix to handle a signed/unsigned comparison that
the compiler didn't flag - thanks to Dan for catching it.

It should be noted, however, as mentioned in a previous email, the session
number handing appears to be incorrect between where it is parsed and where it
is used.

David
---
isofs: Fix isofs_show_options()

isofs_show_options() compares sbi->s_session to -1, but s_session is an
unsigned char, so the comparison isn't right.  Compare against 255 instead.

Further, 1 needs subtracting from the session number to counteract the
increment in the option parser.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index f80ee600d1bc..add72c995f90 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -492,7 +492,7 @@ static int isofs_show_options(struct seq_file *m, struct dentry *root)
 
 	if (sbi->s_check)		seq_printf(m, ",check=%c", sbi->s_check);
 	if (sbi->s_mapping)		seq_printf(m, ",map=%c", sbi->s_mapping);
-	if (sbi->s_session != -1)	seq_printf(m, ",session=%u", sbi->s_session);
+	if (sbi->s_session != 255)	seq_printf(m, ",session=%u", sbi->s_session - 1);
 	if (sbi->s_sbsector != -1)	seq_printf(m, ",sbsector=%u", sbi->s_sbsector);
 
 	if (root->d_sb->s_blocksize != 1024)

[toc] | [prev] | [next] | [standalone]


#1681596 — [PATCH 04/14] pstore: Implement show_options

FromDavid Howells <dhowells@redhat.com>
Date2017-07-05 17:30 +0200
Subject[PATCH 04/14] pstore: Implement show_options
Message-ID<tZUpA-83i-35@gated-at.bofh.it>
In reply to#1681592
Implement the show_options superblock op for pstore as part of a bid to get
rid of s_options and generic_show_options() to make it easier to implement
a context-based mount where the mount options can be passed individually
over a file descriptor.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Kees Cook <keescook@chromium.org>
cc: Anton Vorontsov <anton@enomsg.org>
cc: Colin Cross <ccross@android.com>
cc: Tony Luck <tony.luck@intel.com>
---

 fs/pstore/inode.c    |   14 +++++++++++---
 fs/pstore/internal.h |    3 +++
 fs/pstore/platform.c |    2 +-
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index 792a4e5f9226..913e839ac1f5 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -283,6 +283,16 @@ static void parse_options(char *options)
 	}
 }
 
+/*
+ * Display the mount options in /proc/mounts.
+ */
+static int pstore_show_options(struct seq_file *m, struct dentry *root)
+{
+	if (kmsg_bytes != PSTORE_DEFAULT_KMSG_BYTES)
+		seq_printf(m, ",kmsg_bytes=%lu", kmsg_bytes);
+	return 0;
+}
+
 static int pstore_remount(struct super_block *sb, int *flags, char *data)
 {
 	sync_filesystem(sb);
@@ -296,7 +306,7 @@ static const struct super_operations pstore_ops = {
 	.drop_inode	= generic_delete_inode,
 	.evict_inode	= pstore_evict_inode,
 	.remount_fs	= pstore_remount,
-	.show_options	= generic_show_options,
+	.show_options	= pstore_show_options,
 };
 
 static struct super_block *pstore_sb;
@@ -448,8 +458,6 @@ static int pstore_fill_super(struct super_block *sb, void *data, int silent)
 {
 	struct inode *inode;
 
-	save_mount_options(sb, data);
-
 	pstore_sb = sb;
 
 	sb->s_maxbytes		= MAX_LFS_FILESIZE;
diff --git a/fs/pstore/internal.h b/fs/pstore/internal.h
index c416e653dc4f..4d5913130580 100644
--- a/fs/pstore/internal.h
+++ b/fs/pstore/internal.h
@@ -5,6 +5,9 @@
 #include <linux/time.h>
 #include <linux/pstore.h>
 
+#define PSTORE_DEFAULT_KMSG_BYTES 10240
+extern unsigned long kmsg_bytes;
+
 #ifdef CONFIG_PSTORE_FTRACE
 extern void pstore_register_ftrace(void);
 extern void pstore_unregister_ftrace(void);
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index d468eec9b8a6..6640df40908d 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -99,7 +99,7 @@ static char *big_oops_buf;
 static size_t big_oops_buf_sz;
 
 /* How much of the console log to snapshot */
-static unsigned long kmsg_bytes = 10240;
+unsigned long kmsg_bytes = PSTORE_DEFAULT_KMSG_BYTES;
 
 void pstore_set_kmsg_bytes(int bytes)
 {

[toc] | [prev] | [next] | [standalone]


#1681665 — Re: [PATCH 04/14] pstore: Implement show_options

FromKees Cook <keescook@chromium.org>
Date2017-07-05 19:20 +0200
SubjectRe: [PATCH 04/14] pstore: Implement show_options
Message-ID<tZW82-JF-11@gated-at.bofh.it>
In reply to#1681596
On Wed, Jul 5, 2017 at 8:24 AM, David Howells <dhowells@redhat.com> wrote:
> Implement the show_options superblock op for pstore as part of a bid to get
> rid of s_options and generic_show_options() to make it easier to implement
> a context-based mount where the mount options can be passed individually
> over a file descriptor.
>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Kees Cook <keescook@chromium.org>
> cc: Anton Vorontsov <anton@enomsg.org>
> cc: Colin Cross <ccross@android.com>
> cc: Tony Luck <tony.luck@intel.com>

Acked-by: Kees Cook <keescook@chromium.org>

Do you want me to take this into the pstore tree or do you want to
push it via a separate tree?

-Kees

> ---
>
>  fs/pstore/inode.c    |   14 +++++++++++---
>  fs/pstore/internal.h |    3 +++
>  fs/pstore/platform.c |    2 +-
>  3 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
> index 792a4e5f9226..913e839ac1f5 100644
> --- a/fs/pstore/inode.c
> +++ b/fs/pstore/inode.c
> @@ -283,6 +283,16 @@ static void parse_options(char *options)
>         }
>  }
>
> +/*
> + * Display the mount options in /proc/mounts.
> + */
> +static int pstore_show_options(struct seq_file *m, struct dentry *root)
> +{
> +       if (kmsg_bytes != PSTORE_DEFAULT_KMSG_BYTES)
> +               seq_printf(m, ",kmsg_bytes=%lu", kmsg_bytes);
> +       return 0;
> +}
> +
>  static int pstore_remount(struct super_block *sb, int *flags, char *data)
>  {
>         sync_filesystem(sb);
> @@ -296,7 +306,7 @@ static const struct super_operations pstore_ops = {
>         .drop_inode     = generic_delete_inode,
>         .evict_inode    = pstore_evict_inode,
>         .remount_fs     = pstore_remount,
> -       .show_options   = generic_show_options,
> +       .show_options   = pstore_show_options,
>  };
>
>  static struct super_block *pstore_sb;
> @@ -448,8 +458,6 @@ static int pstore_fill_super(struct super_block *sb, void *data, int silent)
>  {
>         struct inode *inode;
>
> -       save_mount_options(sb, data);
> -
>         pstore_sb = sb;
>
>         sb->s_maxbytes          = MAX_LFS_FILESIZE;
> diff --git a/fs/pstore/internal.h b/fs/pstore/internal.h
> index c416e653dc4f..4d5913130580 100644
> --- a/fs/pstore/internal.h
> +++ b/fs/pstore/internal.h
> @@ -5,6 +5,9 @@
>  #include <linux/time.h>
>  #include <linux/pstore.h>
>
> +#define PSTORE_DEFAULT_KMSG_BYTES 10240
> +extern unsigned long kmsg_bytes;
> +
>  #ifdef CONFIG_PSTORE_FTRACE
>  extern void pstore_register_ftrace(void);
>  extern void pstore_unregister_ftrace(void);
> diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
> index d468eec9b8a6..6640df40908d 100644
> --- a/fs/pstore/platform.c
> +++ b/fs/pstore/platform.c
> @@ -99,7 +99,7 @@ static char *big_oops_buf;
>  static size_t big_oops_buf_sz;
>
>  /* How much of the console log to snapshot */
> -static unsigned long kmsg_bytes = 10240;
> +unsigned long kmsg_bytes = PSTORE_DEFAULT_KMSG_BYTES;
>
>  void pstore_set_kmsg_bytes(int bytes)
>  {
>



-- 
Kees Cook
Pixel Security

[toc] | [prev] | [next] | [standalone]


#1683278 — Re: [PATCH 04/14] pstore: Implement show_options

FromDavid Howells <dhowells@redhat.com>
Date2017-07-07 18:10 +0200
SubjectRe: [PATCH 04/14] pstore: Implement show_options
Message-ID<u0DZn-6n4-19@gated-at.bofh.it>
In reply to#1681665
Kees Cook <keescook@chromium.org> wrote:

> Do you want me to take this into the pstore tree or do you want to
> push it via a separate tree?

I really want to punt that question to Al.  These are a prerequisite for my
fs_context patches.

David

[toc] | [prev] | [next] | [standalone]


#1681597 — [PATCH 07/14] spufs: Implement show_options

FromDavid Howells <dhowells@redhat.com>
Date2017-07-05 17:30 +0200
Subject[PATCH 07/14] spufs: Implement show_options
Message-ID<tZUpA-83i-39@gated-at.bofh.it>
In reply to#1681592
Implement the show_options superblock op for spufs as part of a bid to get
rid of s_options and generic_show_options() to make it easier to implement
a context-based mount where the mount options can be passed individually
over a file descriptor.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Jeremy Kerr <jk@ozlabs.org>
cc: linuxppc-dev@lists.ozlabs.org
---

 arch/powerpc/platforms/cell/spufs/inode.c |   21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index d8af9bc0489f..27a51a60bc33 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -605,6 +605,23 @@ static const match_table_t spufs_tokens = {
 	{ Opt_err,    NULL  },
 };
 
+static int spufs_show_options(struct seq_file *m, struct dentry *root)
+{
+	struct spufs_sb_info *sbi = spufs_get_sb_info(root->d_sb);
+
+	if (!uid_eq(root->i_uid, GLOBAL_ROOT_UID))
+		seq_printf(m, ",uid=%u",
+			   from_kuid_munged(&init_user_ns, root->i_uid));
+	if (!gid_eq(root->i_gid, GLOBAL_ROOT_GID))
+		seq_printf(m, ",gid=%u",
+			   from_kgid_munged(&init_user_ns, root->i_gid));
+	if (root->i_mode & S_IALLUGO != 0775)
+		seq_printf(m, ",mode=%o", root->i_mode);
+	if (sbi->debug)
+		seq_puts(m, ",debug");
+	return 0;
+}
+
 static int
 spufs_parse_options(struct super_block *sb, char *options, struct inode *root)
 {
@@ -724,11 +741,9 @@ spufs_fill_super(struct super_block *sb, void *data, int silent)
 		.destroy_inode = spufs_destroy_inode,
 		.statfs = simple_statfs,
 		.evict_inode = spufs_evict_inode,
-		.show_options = generic_show_options,
+		.show_options = spufs_show_options,
 	};
 
-	save_mount_options(sb, data);
-
 	info = kzalloc(sizeof(*info), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;

[toc] | [prev] | [next] | [standalone]


#1681600 — [PATCH 10/14] afs: Implement show_options

FromDavid Howells <dhowells@redhat.com>
Date2017-07-05 17:30 +0200
Subject[PATCH 10/14] afs: Implement show_options
Message-ID<tZUpB-83i-53@gated-at.bofh.it>
In reply to#1681592
Implement the show_options superblock op for afs as part of a bid to get
rid of s_options and generic_show_options() to make it easier to implement
a context-based mount where the mount options can be passed individually
over a file descriptor.

Also implement the show_devname op to display the correct device name and thus
avoid the need to display the cell= and volume= options.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-afs@lists.infradead.org
---

 fs/afs/super.c |   45 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 2 deletions(-)

diff --git a/fs/afs/super.c b/fs/afs/super.c
index c79633e5cfd8..35d7e550b29c 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -37,6 +37,8 @@ static void afs_kill_super(struct super_block *sb);
 static struct inode *afs_alloc_inode(struct super_block *sb);
 static void afs_destroy_inode(struct inode *inode);
 static int afs_statfs(struct dentry *dentry, struct kstatfs *buf);
+static int afs_show_devname(struct seq_file *m, struct dentry *root);
+static int afs_show_options(struct seq_file *m, struct dentry *root);
 
 struct file_system_type afs_fs_type = {
 	.owner		= THIS_MODULE,
@@ -53,7 +55,8 @@ static const struct super_operations afs_super_ops = {
 	.drop_inode	= afs_drop_inode,
 	.destroy_inode	= afs_destroy_inode,
 	.evict_inode	= afs_evict_inode,
-	.show_options	= generic_show_options,
+	.show_devname	= afs_show_devname,
+	.show_options	= afs_show_options,
 };
 
 static struct kmem_cache *afs_inode_cachep;
@@ -136,6 +139,45 @@ void __exit afs_fs_exit(void)
 }
 
 /*
+ * Display the mount device name in /proc/mounts.
+ */
+static int afs_show_devname(struct seq_file *m, struct dentry *root)
+{
+	struct afs_super_info *as = root->d_sb->s_fs_info;
+	struct afs_volume *volume = as->volume;
+	struct afs_cell *cell = volume->cell;
+	const char *suf = "";
+	char pref = '%';
+
+	switch (volume->type) {
+	case AFSVL_RWVOL:
+		break;
+	case AFSVL_ROVOL:
+		pref = '#';
+		if (volume->type_force)
+			suf = ".readonly";
+		break;
+	case AFSVL_BACKVOL:
+		pref = '#';
+		suf = ".backup";
+		break;
+	}
+
+	seq_printf(m, "%c%s:%s%s", pref, cell->name, volume->vlocation->vldb.name, suf);
+	return 0;
+}
+
+/*
+ * Display the mount options in /proc/mounts.
+ */
+static int afs_show_options(struct seq_file *m, struct dentry *root)
+{
+	if (test_bit(AFS_VNODE_AUTOCELL, &AFS_FS_I(d_inode(root))->flags))
+		seq_puts(m, "autocell");
+	return 0;
+}
+
+/*
  * parse the mount options
  * - this function has been shamelessly adapted from the ext3 fs which
  *   shamelessly adapted it from the msdos fs
@@ -426,7 +468,6 @@ static struct dentry *afs_mount(struct file_system_type *fs_type,
 			deactivate_locked_super(sb);
 			goto error;
 		}
-		save_mount_options(sb, new_opts);
 		sb->s_flags |= MS_ACTIVE;
 	} else {
 		_debug("reuse");

[toc] | [prev] | [next] | [standalone]


#1681601 — [PATCH 08/14] befs: Implement show_options

FromDavid Howells <dhowells@redhat.com>
Date2017-07-05 17:30 +0200
Subject[PATCH 08/14] befs: Implement show_options
Message-ID<tZUpB-83i-51@gated-at.bofh.it>
In reply to#1681592
Implement the show_options superblock op for befs as part of a bid to get
rid of s_options and generic_show_options() to make it easier to implement
a context-based mount where the mount options can be passed individually
over a file descriptor.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Luis de Bethencourt <luisbg@osg.samsung.com>
cc: Salah Triki <salah.triki@gmail.com>
---

 fs/befs/linuxvfs.c |   24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 63e7c4760bfb..4a4a5a366158 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -20,6 +20,7 @@
 #include <linux/sched.h>
 #include <linux/cred.h>
 #include <linux/exportfs.h>
+#include <linux/seq_file.h>
 
 #include "befs.h"
 #include "btree.h"
@@ -53,6 +54,7 @@ static int befs_nls2utf(struct super_block *sb, const char *in, int in_len,
 static void befs_put_super(struct super_block *);
 static int befs_remount(struct super_block *, int *, char *);
 static int befs_statfs(struct dentry *, struct kstatfs *);
+static int befs_show_options(struct seq_file *, struct dentry *);
 static int parse_options(char *, struct befs_mount_options *);
 static struct dentry *befs_fh_to_dentry(struct super_block *sb,
 				struct fid *fid, int fh_len, int fh_type);
@@ -66,7 +68,7 @@ static const struct super_operations befs_sops = {
 	.put_super	= befs_put_super,	/* uninit super */
 	.statfs		= befs_statfs,	/* statfs */
 	.remount_fs	= befs_remount,
-	.show_options	= generic_show_options,
+	.show_options	= befs_show_options,
 };
 
 /* slab cache for befs_inode_info objects */
@@ -771,6 +773,24 @@ parse_options(char *options, struct befs_mount_options *opts)
 	return 1;
 }
 
+static int befs_show_options(struct seq_file *m, struct dentry *root)
+{
+	struct befs_sb_info *befs_sb = BEFS_SB(root->d_sb);
+	struct befs_mount_options *opts = &befs_sb->mount_opts;
+
+	if (!uid_eq(opts->uid, GLOBAL_ROOT_UID))
+		seq_printf(m, ",uid=%u",
+			   from_kuid_munged(&init_user_ns, opts->uid));
+	if (!gid_eq(opts->gid, GLOBAL_ROOT_GID))
+		seq_printf(m, ",gid=%u",
+			   from_kgid_munged(&init_user_ns, opts->gid));
+	if (opts->iocharset)
+		seq_printf(m, ",charset=%s", opts->iocharset);
+	if (opts->debug)
+		seq_puts(m, ",debug");
+	return 0;
+}
+
 /* This function has the responsibiltiy of getting the
  * filesystem ready for unmounting.
  * Basically, we free everything that we allocated in
@@ -804,8 +824,6 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
 	const off_t x86_sb_off = 512;
 	int blocksize;
 
-	save_mount_options(sb, data);
-
 	sb->s_fs_info = kzalloc(sizeof(*befs_sb), GFP_KERNEL);
 	if (sb->s_fs_info == NULL)
 		goto unacquire_none;

[toc] | [prev] | [next] | [standalone]


#1681602 — [PATCH 06/14] bpf: Implement show_options

FromDavid Howells <dhowells@redhat.com>
Date2017-07-05 17:30 +0200
Subject[PATCH 06/14] bpf: Implement show_options
Message-ID<tZUpB-83i-55@gated-at.bofh.it>
In reply to#1681592
Implement the show_options superblock op for bpf as part of a bid to get
rid of s_options and generic_show_options() to make it easier to implement
a context-based mount where the mount options can be passed individually
over a file descriptor.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Alexei Starovoitov <ast@kernel.org>
cc: Daniel Borkmann <daniel@iogearbox.net>
cc: netdev@vger.kernel.org
---

 kernel/bpf/inode.c |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index 9bbd33497d3d..e833ed914358 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -377,10 +377,22 @@ static void bpf_evict_inode(struct inode *inode)
 		bpf_any_put(inode->i_private, type);
 }
 
+/*
+ * Display the mount options in /proc/mounts.
+ */
+static int bpf_show_options(struct seq_file *m, struct dentry *root)
+{
+	umode_t mode = d_inode(root)->i_mode & S_IALLUGO & ~S_ISVTX;
+
+	if (mode != S_IRWXUGO)
+		seq_printf(m, ",mode=%o", mode);
+	return 0;
+}
+
 static const struct super_operations bpf_super_ops = {
 	.statfs		= simple_statfs,
 	.drop_inode	= generic_delete_inode,
-	.show_options	= generic_show_options,
+	.show_options	= bpf_show_options,
 	.evict_inode	= bpf_evict_inode,
 };
 
@@ -434,8 +446,6 @@ static int bpf_fill_super(struct super_block *sb, void *data, int silent)
 	struct inode *inode;
 	int ret;
 
-	save_mount_options(sb, data);
-
 	ret = bpf_parse_options(data, &opts);
 	if (ret)
 		return ret;

[toc] | [prev] | [next] | [standalone]


#1682152 — Re: [PATCH 06/14] bpf: Implement show_options

FromDaniel Borkmann <daniel@iogearbox.net>
Date2017-07-06 10:10 +0200
SubjectRe: [PATCH 06/14] bpf: Implement show_options
Message-ID<u0a1k-1IG-19@gated-at.bofh.it>
In reply to#1681602
On 07/05/2017 05:24 PM, David Howells wrote:
> Implement the show_options superblock op for bpf as part of a bid to get
> rid of s_options and generic_show_options() to make it easier to implement
> a context-based mount where the mount options can be passed individually
> over a file descriptor.
>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Alexei Starovoitov <ast@kernel.org>
> cc: Daniel Borkmann <daniel@iogearbox.net>
> cc: netdev@vger.kernel.org

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

[toc] | [prev] | [next] | [standalone]


#1681654 — Re: [RFC][PATCH 00/14] VFS: Make all filesystems implement ->show_options()

Fromebiederm@xmission.com (Eric W. Biederman)
Date2017-07-05 18:50 +0200
SubjectRe: [RFC][PATCH 00/14] VFS: Make all filesystems implement ->show_options()
Message-ID<tZVEZ-ke-9@gated-at.bofh.it>
In reply to#1681592
David Howells <dhowells@redhat.com> writes:

> Here's a set of patches that:
>
>  (1) Removes calls to save/replace_mount_options() where the filesystem
>      then implements ->show_options() anyway, ignoring ->s_options.
>
>  (2) Makes all filesystems implement the ->show_options() superblock
>      operation rather than using generic_show_options().  If necessary,
>      extra information is stored in the superblock information.
>
>  (3) Deletes save_mount_options(), replace_mount_options(),
>      generic_show_options() and super_block::s_options.
>
> This makes it easier to implement a context-based mount where the options
> are passed individually over a file descriptor.  It also allows duplicate
> options, options that override each other and ignored options to be
> resolved rather than storing irrelevant data.

This makes me a little nervous but is probably fine.  But we do need
to be careful with remount.  Today the rule is all options that need
to be preserved need to be passed to remount.  Passing options in one by
one looks like it may make it easy to get that confused while you are
developing your patches.

> Further, a lot of the time, all the information we want to display is
> stored in the super block information anyway, so the option string is
> redundant.
>
> Some things I noted whilst doing this:
>
>  (1) A number of filesystems take uid/gid options.  Should these be
>      reported relative to the observer's user namespace rather than init's
>      user namespace?  After all, you can't then use those uid/gid options
>      if the numbers are interpreted incorrectly if you try and forge a
>      mount command from them.

Options should be relative to the mount call.  Which is almost always
&init_user_ns and in the general case would be sb->s_user_ns.

Which I believe becomes the creator of the mount context in the model
you are working towards.

>  (2) Should I provide a helper for displaying uid/gid options?
>
>  (3) How much do we need to worry about racing with remount?  Some
>      filesystems happily give out the contents of the super_block without
>      regard to the fact that remount might be changing it simultaneously -
>      ext4, for example.
>
>  (4) What string options actually need 'munging'?
>
> These patches can be found here:
>
> 	https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=for-viro
>
> on top of three other minor patches.
>
> David
> ---
> David Howells (14):
>       VFS: Don't use save/replace_mount_options if not using generic_show_options
>       hugetlbfs: Implement show_options
>       omfs: Implement show_options
>       pstore: Implement show_options
>       ramfs: Implement show_options
>       bpf: Implement show_options
>       spufs: Implement show_options
>       befs: Implement show_options
>       affs: Implement show_options
>       afs: Implement show_options
>       isofs: Implement show_options
>       9p: Implement show_options
>       orangefs: Implement show_options
>       VFS: Kill off s_options and helpers
>
>
>  Documentation/filesystems/vfs.txt         |    6 --
>  arch/powerpc/platforms/cell/spufs/inode.c |   21 +++++++--
>  fs/9p/v9fs.c                              |   59 ++++++++++++++++++++++++
>  fs/9p/v9fs.h                              |    3 +
>  fs/9p/vfs_super.c                         |    6 +-
>  fs/affs/super.c                           |   42 +++++++++++++++--
>  fs/afs/super.c                            |   45 ++++++++++++++++++-
>  fs/befs/linuxvfs.c                        |   24 +++++++++-
>  fs/btrfs/super.c                          |    1 
>  fs/debugfs/inode.c                        |    2 -
>  fs/efivarfs/super.c                       |    1 
>  fs/hugetlbfs/inode.c                      |   70 +++++++++++++++++++++++------
>  fs/isofs/inode.c                          |   51 ++++++++++++++++++++-
>  fs/isofs/isofs.h                          |    3 +
>  fs/namespace.c                            |   59 ------------------------
>  fs/omfs/inode.c                           |   33 ++++++++++++--
>  fs/orangefs/super.c                       |   15 ++++++
>  fs/pstore/inode.c                         |   14 +++++-
>  fs/pstore/internal.h                      |    3 +
>  fs/pstore/platform.c                      |    2 -
>  fs/ramfs/inode.c                          |   32 +++++++++----
>  fs/reiserfs/super.c                       |    4 --
>  fs/super.c                                |    1 
>  fs/tracefs/inode.c                        |    2 -
>  include/linux/fs.h                        |    9 ----
>  include/linux/hugetlb.h                   |    3 +
>  include/net/9p/client.h                   |   13 +++++
>  include/net/9p/transport.h                |    1 
>  kernel/bpf/inode.c                        |   16 +++++--
>  net/9p/client.c                           |   25 ++++++++++
>  net/9p/trans_fd.c                         |   31 ++++++++++++-
>  net/9p/trans_rdma.c                       |   31 ++++++++++++-
>  32 files changed, 481 insertions(+), 147 deletions(-)

[toc] | [prev] | [next] | [standalone]


#1683267 — Re: [RFC][PATCH 00/14] VFS: Make all filesystems implement ->show_options()

FromDavid Howells <dhowells@redhat.com>
Date2017-07-07 18:00 +0200
SubjectRe: [RFC][PATCH 00/14] VFS: Make all filesystems implement ->show_options()
Message-ID<u0DPJ-63n-13@gated-at.bofh.it>
In reply to#1681654
Eric W. Biederman <ebiederm@xmission.com> wrote:

> > This makes it easier to implement a context-based mount where the options
> > are passed individually over a file descriptor.  It also allows duplicate
> > options, options that override each other and ignored options to be
> > resolved rather than storing irrelevant data.
> 
> This makes me a little nervous but is probably fine.  But we do need
> to be careful with remount.  Today the rule is all options that need
> to be preserved need to be passed to remount.  Passing options in one by
> one looks like it may make it easy to get that confused while you are
> developing your patches.

Yeah.  We actually currently get this *wrong* in both ext4 and btrfs - and
probably other disk filesystems too.  During ext4 remount and btrfs remount,
the options are parsed directly into the live xxx_fs_info struct, but if
there's a parse error mid-way, we only partially apply the options and have no
idea where it went wrong and what the current state is.

What I'm looking it is breaking it down into a number of steps:

 (1) Parse the options one at a time into a context struct.

 (2) Once we've got all the options, validate the options we've been given
     with respect to themselves.

 (3) Under lock:

     (a) Check the coherency of the options we've been given with respect to
     	 the superblock (if new mount) or the current live state (if remount).

     (b) Apply the options.  This is not permitted to fail.

This gets more complicated under ext4 as you've got an extra option string
stored on disk that you also have to apply and combine with the options
presented to the mount interface.

> Options should be relative to the mount call.  Which is almost always
> &init_user_ns and in the general case would be sb->s_user_ns.

I generally agree with this - my only doubt is that it might leak external
user/group IDs into a container.  Not sure if that's really worth worrying
about, though.

'user' permitted mounts are handled in userspace by a SUID mount program,
right?

David

[toc] | [prev] | [next] | [standalone]


#1683614

FromTheodore Ts'o <tytso@mit.edu>
Date2017-07-08 17:40 +0200
Message-ID<u0ZZT-3WD-7@gated-at.bofh.it>
In reply to#1683267
On Fri, Jul 07, 2017 at 04:58:56PM +0100, David Howells wrote:
> Yeah.  We actually currently get this *wrong* in both ext4 and btrfs - and
> probably other disk filesystems too.  During ext4 remount and btrfs remount,
> the options are parsed directly into the live xxx_fs_info struct, but if
> there's a parse error mid-way, we only partially apply the options and have no
> idea where it went wrong and what the current state is.
> 
> What I'm looking it is breaking it down into a number of steps:
> 
>  (1) Parse the options one at a time into a context struct.
> 
>  (2) Once we've got all the options, validate the options we've been given
>      with respect to themselves.
> 
>  (3) Under lock:
> 
>      (a) Check the coherency of the options we've been given with respect to
>      	 the superblock (if new mount) or the current live state (if remount).
> 
>      (b) Apply the options.  This is not permitted to fail.
> 
> This gets more complicated under ext4 as you've got an extra option string
> stored on disk that you also have to apply and combine with the options
> presented to the mount interface.

Remounts aren't really performance critical, so it might be simpler
just to do one pass which just checks the options, applying the
options to a scratch xx_fs_info struct, and if it seeded, redo the
parse from scratch, this time applying to the live xxx_fs_info struct.

      	   	    	      	       	  - Ted
					  

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web