@@ -336,7 +336,8 @@ static int ipathfs_fill_super(struct super_block *sb, void *data,
{""},
};
- ret = simple_fill_super(sb, IPATHFS_MAGIC, files);
+ ret = simple_fill_super(sb, IPATHFS_MAGIC, files,
+ S_IWUSR | S_IRUGO | S_IXUGO);
if (ret) {
printk(KERN_ERR "simple_fill_super failed: %d\n", ret);
goto bail;
@@ -530,7 +530,8 @@ static int qibfs_fill_super(struct super_block *sb, void *data, int silent)
{""},
};
- ret = simple_fill_super(sb, QIBFS_MAGIC, files);
+ ret = simple_fill_super(sb, QIBFS_MAGIC, files,
+ S_IWUSR | S_IRUGO | S_IXUGO);
if (ret) {
printk(KERN_ERR "simple_fill_super failed: %d\n", ret);
goto bail;
@@ -89,7 +89,8 @@ static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
};
int rc;
- rc = simple_fill_super(sb, XENFS_SUPER_MAGIC, xenfs_files);
+ rc = simple_fill_super(sb, XENFS_SUPER_MAGIC, xenfs_files,
+ S_IWUSR | S_IRUGO | S_IXUGO);
if (rc < 0)
return rc;
@@ -700,7 +700,8 @@ static int bm_fill_super(struct super_block * sb, void * data, int silent)
[3] = {"register", &bm_register_operations, S_IWUSR},
/* last one */ {""}
};
- int err = simple_fill_super(sb, 0x42494e4d, bm_files);
+ int err = simple_fill_super(sb, 0x42494e4d, bm_files,
+ S_IWUSR | S_IRUGO | S_IXUGO);
if (!err)
sb->s_op = &s_ops;
return err;
@@ -132,7 +132,8 @@ static int debug_fill_super(struct super_block *sb, void *data, int silent)
{
static struct tree_descr debug_files[] = {{""}};
- return simple_fill_super(sb, DEBUGFS_MAGIC, debug_files);
+ return simple_fill_super(sb, DEBUGFS_MAGIC, debug_files,
+ S_IWUSR | S_IRUGO | S_IXUGO);
}
static struct dentry *debug_mount(struct file_system_type *fs_type,
@@ -302,7 +302,8 @@ static int fuse_ctl_fill_super(struct super_block *sb, void *data, int silent)
struct fuse_conn *fc;
int err;
- err = simple_fill_super(sb, FUSE_CTL_SUPER_MAGIC, &empty_descr);
+ err = simple_fill_super(sb, FUSE_CTL_SUPER_MAGIC, &empty_descr,
+ S_IWUSR | S_IRUGO | S_IXUGO);
if (err)
return err;
@@ -463,7 +463,7 @@ int simple_write_end(struct file *file, struct address_space *mapping,
* to pass it an appropriate max_reserved value to avoid collisions.
*/
int simple_fill_super(struct super_block *s, unsigned long magic,
- struct tree_descr *files)
+ struct tree_descr *files, umode_t mode)
{
struct inode *inode;
struct dentry *root;
@@ -484,7 +484,7 @@ int simple_fill_super(struct super_block *s, unsigned long magic,
* entry at index 1
*/
inode->i_ino = 1;
- inode->i_mode = S_IFDIR | 0755;
+ inode->i_mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->i_op = &simple_dir_inode_operations;
inode->i_fop = &simple_dir_operations;
@@ -1404,7 +1404,8 @@ static int nfsd_fill_super(struct super_block * sb, void * data, int silent)
#endif
/* last one */ {""}
};
- return simple_fill_super(sb, 0x6e667364, nfsd_files);
+ return simple_fill_super(sb, 0x6e667364, nfsd_files,
+ S_IWUSR | S_IRUGO | S_IXUGO);
}
static struct dentry *nfsd_mount(struct file_system_type *fs_type,
@@ -2435,7 +2435,8 @@ extern const struct file_operations simple_dir_operations;
extern const struct inode_operations simple_dir_inode_operations;
struct tree_descr { char *name; const struct file_operations *ops; int mode; };
struct dentry *d_alloc_name(struct dentry *, const char *);
-extern int simple_fill_super(struct super_block *, unsigned long, struct tree_descr *);
+extern int simple_fill_super(struct super_block *, unsigned long,
+ struct tree_descr *, umode_t mode);
extern int simple_pin_fs(struct file_system_type *, struct vfsmount **mount, int *count);
extern void simple_release_fs(struct vfsmount **mount, int *count);
@@ -128,7 +128,8 @@ static int fill_super(struct super_block *sb, void *data, int silent)
{
static struct tree_descr files[] = {{""}};
- return simple_fill_super(sb, SECURITYFS_MAGIC, files);
+ return simple_fill_super(sb, SECURITYFS_MAGIC, files,
+ S_IWUSR | S_IRUGO | S_IXUGO);
}
static struct dentry *get_sb(struct file_system_type *fs_type,
@@ -1792,7 +1792,8 @@ static int sel_fill_super(struct super_block *sb, void *data, int silent)
[SEL_POLICY] = {"policy", &sel_policy_ops, S_IRUSR},
/* last one */ {""}
};
- ret = simple_fill_super(sb, SELINUX_MAGIC, selinux_files);
+ ret = simple_fill_super(sb, SELINUX_MAGIC, selinux_files,
+ S_IWUSR | S_IRUGO | S_IXUGO);
if (ret)
goto err;
@@ -1323,7 +1323,8 @@ static int smk_fill_super(struct super_block *sb, void *data, int silent)
/* last one */ {""}
};
- rc = simple_fill_super(sb, SMACK_MAGIC, smack_files);
+ rc = simple_fill_super(sb, SMACK_MAGIC, smack_files,
+ S_IWUSR | S_IRUGO | S_IXUGO);
if (rc != 0) {
printk(KERN_ERR "%s failed %d while creating inodes\n",
__func__, rc);
There was no way to specify the mode of the root directory of filesystems created with simple_fill_super. Signed-off-by: Kees Cook <kees.cook@canonical.com> --- drivers/infiniband/hw/ipath/ipath_fs.c | 3 ++- drivers/infiniband/hw/qib/qib_fs.c | 3 ++- drivers/xen/xenfs/super.c | 3 ++- fs/binfmt_misc.c | 3 ++- fs/debugfs/inode.c | 3 ++- fs/fuse/control.c | 3 ++- fs/libfs.c | 4 ++-- fs/nfsd/nfsctl.c | 3 ++- include/linux/fs.h | 3 ++- security/inode.c | 3 ++- security/selinux/selinuxfs.c | 3 ++- security/smack/smackfs.c | 3 ++- 12 files changed, 24 insertions(+), 13 deletions(-)