]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
fs: constify tree_descr arrays passed to simple_fill_super()
authorEric Biggers <ebiggers@google.com>
Sun, 26 Mar 2017 04:15:37 +0000 (21:15 -0700)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 27 Apr 2017 03:54:06 +0000 (23:54 -0400)
simple_fill_super() is passed an array of tree_descr structures which
describe the files to create in the filesystem's root directory.  Since
these arrays are never modified intentionally, they should be 'const' so
that they are placed in .rodata and benefit from memory protection.
This patch updates the function signature and all users, and also
constifies tree_descr.name.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
13 files changed:
drivers/infiniband/hw/qib/qib_fs.c
drivers/xen/xenfs/super.c
fs/binfmt_misc.c
fs/debugfs/inode.c
fs/fuse/control.c
fs/libfs.c
fs/nfsd/nfsctl.c
fs/tracefs/inode.c
include/linux/fs.h
kernel/bpf/inode.c
security/inode.c
security/selinux/selinuxfs.c
security/smack/smackfs.c

index f1e66efea98a87f1a5327cbb638c51a7688bc3cc..1d940a2885c98fa93e17332572c86a3e73ece983 100644 (file)
@@ -512,7 +512,7 @@ static int qibfs_fill_super(struct super_block *sb, void *data, int silent)
        unsigned long flags;
        int ret;
 
-       static struct tree_descr files[] = {
+       static const struct tree_descr files[] = {
                [2] = {"driver_stats", &driver_ops[0], S_IRUGO},
                [3] = {"driver_stats_names", &driver_ops[1], S_IRUGO},
                {""},
index 328c3987b112dcf84fe40005d936bfbfed601f91..967f069385d0cf1fa9933cdeb0f8804dc0324e06 100644 (file)
@@ -44,14 +44,14 @@ static const struct file_operations capabilities_file_ops = {
 
 static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
 {
-       static struct tree_descr xenfs_files[] = {
+       static const struct tree_descr xenfs_files[] = {
                [2] = { "xenbus", &xen_xenbus_fops, S_IRUSR|S_IWUSR },
                { "capabilities", &capabilities_file_ops, S_IRUGO },
                { "privcmd", &xen_privcmd_fops, S_IRUSR|S_IWUSR },
                {""},
        };
 
-       static struct tree_descr xenfs_init_files[] = {
+       static const struct tree_descr xenfs_init_files[] = {
                [2] = { "xenbus", &xen_xenbus_fops, S_IRUSR|S_IWUSR },
                { "capabilities", &capabilities_file_ops, S_IRUGO },
                { "privcmd", &xen_privcmd_fops, S_IRUSR|S_IWUSR },
index bee1a36bc2ec4e0be1343c11bb07da13bbcb384f..f4718098ac31885b64ebaba7c03af5fe75515092 100644 (file)
@@ -818,7 +818,7 @@ static const struct super_operations s_ops = {
 static int bm_fill_super(struct super_block *sb, void *data, int silent)
 {
        int err;
-       static struct tree_descr bm_files[] = {
+       static const struct tree_descr bm_files[] = {
                [2] = {"status", &bm_status_operations, S_IWUSR|S_IRUGO},
                [3] = {"register", &bm_register_operations, S_IWUSR},
                /* last one */ {""}
index 7fd4ec4bb21406b1d427f24ee7789c54b62c335b..e892ae7d89f8bc078848d8752affa1598a7e1e11 100644 (file)
@@ -199,7 +199,7 @@ static const struct dentry_operations debugfs_dops = {
 
 static int debug_fill_super(struct super_block *sb, void *data, int silent)
 {
-       static struct tree_descr debug_files[] = {{""}};
+       static const struct tree_descr debug_files[] = {{""}};
        struct debugfs_fs_info *fsi;
        int err;
 
index 6e22748b0704c509edad6a0e93d0a6626601137b..b9ea99c5b5b31948882d37113d520ab9cdcf9564 100644 (file)
@@ -292,7 +292,7 @@ void fuse_ctl_remove_conn(struct fuse_conn *fc)
 
 static int fuse_ctl_fill_super(struct super_block *sb, void *data, int silent)
 {
-       struct tree_descr empty_descr = {""};
+       static const struct tree_descr empty_descr = {""};
        struct fuse_conn *fc;
        int err;
 
index a8b62e5d43a972d3b02867e6d9c2136b23987ecd..a04395334bb156ae04853639650dc9751fb55753 100644 (file)
@@ -507,7 +507,7 @@ EXPORT_SYMBOL(simple_write_end);
  * 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)
+                     const struct tree_descr *files)
 {
        struct inode *inode;
        struct dentry *root;
index 8bf8f667a8cf2fe8359f74b41497bc9436ca0efb..6493df6b1bd5f192646d1f63b2230af840833651 100644 (file)
@@ -1146,7 +1146,7 @@ static ssize_t write_v4_end_grace(struct file *file, char *buf, size_t size)
 
 static int nfsd_fill_super(struct super_block * sb, void * data, int silent)
 {
-       static struct tree_descr nfsd_files[] = {
+       static const struct tree_descr nfsd_files[] = {
                [NFSD_List] = {"exports", &exports_nfsd_operations, S_IRUGO},
                [NFSD_Export_features] = {"export_features",
                                        &export_features_operations, S_IRUGO},
index 21d36d28473562d4a40f75134ae3916b11c8041c..328e89c2cf835d4ff3cec1572ae30a30621fa183 100644 (file)
@@ -266,7 +266,7 @@ static const struct super_operations tracefs_super_operations = {
 
 static int trace_fill_super(struct super_block *sb, void *data, int silent)
 {
-       static struct tree_descr trace_files[] = {{""}};
+       static const struct tree_descr trace_files[] = {{""}};
        struct tracefs_fs_info *fsi;
        int err;
 
index dee12c171e07a38082d563a2597887c51a78a315..fc1b4faa62729c3371c8376fc4856cbfea6379c0 100644 (file)
@@ -2995,9 +2995,10 @@ extern const struct file_operations simple_dir_operations;
 extern const struct inode_operations simple_dir_inode_operations;
 extern void make_empty_dir_inode(struct inode *inode);
 extern bool is_empty_dir_inode(struct inode *inode);
-struct tree_descr { char *name; const struct file_operations *ops; int mode; };
+struct tree_descr { const 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,
+                            const struct tree_descr *);
 extern int simple_pin_fs(struct file_system_type *, struct vfsmount **mount, int *count);
 extern void simple_release_fs(struct vfsmount **mount, int *count);
 
index fddcae801724be149b73794ab42f9f177ecf4f56..9bbd33497d3d0846de8ebd7b74828e5566045e68 100644 (file)
@@ -429,7 +429,7 @@ static int bpf_parse_options(char *data, struct bpf_mount_opts *opts)
 
 static int bpf_fill_super(struct super_block *sb, void *data, int silent)
 {
-       static struct tree_descr bpf_rfiles[] = { { "" } };
+       static const struct tree_descr bpf_rfiles[] = { { "" } };
        struct bpf_mount_opts opts;
        struct inode *inode;
        int ret;
index 2cb14162ff8d5fa2f2ebfdd58061c07f4569f34c..eccd58ef2ae8456af7523414c5405024332e4731 100644 (file)
@@ -28,7 +28,7 @@ static int mount_count;
 
 static int fill_super(struct super_block *sb, void *data, int silent)
 {
-       static struct tree_descr files[] = {{""}};
+       static const struct tree_descr files[] = {{""}};
 
        return simple_fill_super(sb, SECURITYFS_MAGIC, files);
 }
index cb3fd98fb05ae7df77b2ad20bf640d38b5133123..6a9efedf7eb26e9c3776b7479d395402a79765c3 100644 (file)
@@ -1496,7 +1496,7 @@ static const struct file_operations sel_avc_cache_stats_ops = {
 static int sel_make_avc_files(struct dentry *dir)
 {
        int i;
-       static struct tree_descr files[] = {
+       static const struct tree_descr files[] = {
                { "cache_threshold",
                  &sel_avc_cache_threshold_ops, S_IRUGO|S_IWUSR },
                { "hash_stats", &sel_avc_hash_stats_ops, S_IRUGO },
@@ -1805,7 +1805,7 @@ static int sel_fill_super(struct super_block *sb, void *data, int silent)
        struct inode *inode;
        struct inode_security_struct *isec;
 
-       static struct tree_descr selinux_files[] = {
+       static const struct tree_descr selinux_files[] = {
                [SEL_LOAD] = {"load", &sel_load_ops, S_IRUSR|S_IWUSR},
                [SEL_ENFORCE] = {"enforce", &sel_enforce_ops, S_IRUGO|S_IWUSR},
                [SEL_CONTEXT] = {"context", &transaction_ops, S_IRUGO|S_IWUGO},
index 366b8356f75b45315c43b6067aa569680c20eea4..f6482e53d55a82d97882d40d04736247281a4239 100644 (file)
@@ -2855,7 +2855,7 @@ static int smk_fill_super(struct super_block *sb, void *data, int silent)
        int rc;
        struct inode *root_inode;
 
-       static struct tree_descr smack_files[] = {
+       static const struct tree_descr smack_files[] = {
                [SMK_LOAD] = {
                        "load", &smk_load_ops, S_IRUGO|S_IWUSR},
                [SMK_CIPSO] = {