summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2017-03-26 00:15:37 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2017-04-26 23:54:06 -0400
commitcda37124f4e95ad5ccb11394a5802b0972668b32 (patch)
treea4c51e172c57885b2edf4f74c797aa4918097d76
parenta0c111b49bbe11c3970bc668600e3b61fbbb7fca (diff)
fs: constify tree_descr arrays passed to simple_fill_super()
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>
-rw-r--r--drivers/infiniband/hw/qib/qib_fs.c2
-rw-r--r--drivers/xen/xenfs/super.c4
-rw-r--r--fs/binfmt_misc.c2
-rw-r--r--fs/debugfs/inode.c2
-rw-r--r--fs/fuse/control.c2
-rw-r--r--fs/libfs.c2
-rw-r--r--fs/nfsd/nfsctl.c2
-rw-r--r--fs/tracefs/inode.c2
-rw-r--r--include/linux/fs.h5
-rw-r--r--kernel/bpf/inode.c2
-rw-r--r--security/inode.c2
-rw-r--r--security/selinux/selinuxfs.c4
-rw-r--r--security/smack/smackfs.c2
13 files changed, 17 insertions, 16 deletions
diff --git a/drivers/infiniband/hw/qib/qib_fs.c b/drivers/infiniband/hw/qib/qib_fs.c
index f1e66efea98a..1d940a2885c9 100644
--- a/drivers/infiniband/hw/qib/qib_fs.c
+++ b/drivers/infiniband/hw/qib/qib_fs.c
@@ -512,7 +512,7 @@ static int qibfs_fill_super(struct super_block *sb, void *data, int silent)
512 unsigned long flags; 512 unsigned long flags;
513 int ret; 513 int ret;
514 514
515 static struct tree_descr files[] = { 515 static const struct tree_descr files[] = {
516 [2] = {"driver_stats", &driver_ops[0], S_IRUGO}, 516 [2] = {"driver_stats", &driver_ops[0], S_IRUGO},
517 [3] = {"driver_stats_names", &driver_ops[1], S_IRUGO}, 517 [3] = {"driver_stats_names", &driver_ops[1], S_IRUGO},
518 {""}, 518 {""},
diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c
index 328c3987b112..967f069385d0 100644
--- a/drivers/xen/xenfs/super.c
+++ b/drivers/xen/xenfs/super.c
@@ -44,14 +44,14 @@ static const struct file_operations capabilities_file_ops = {
44 44
45static int xenfs_fill_super(struct super_block *sb, void *data, int silent) 45static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
46{ 46{
47 static struct tree_descr xenfs_files[] = { 47 static const struct tree_descr xenfs_files[] = {
48 [2] = { "xenbus", &xen_xenbus_fops, S_IRUSR|S_IWUSR }, 48 [2] = { "xenbus", &xen_xenbus_fops, S_IRUSR|S_IWUSR },
49 { "capabilities", &capabilities_file_ops, S_IRUGO }, 49 { "capabilities", &capabilities_file_ops, S_IRUGO },
50 { "privcmd", &xen_privcmd_fops, S_IRUSR|S_IWUSR }, 50 { "privcmd", &xen_privcmd_fops, S_IRUSR|S_IWUSR },
51 {""}, 51 {""},
52 }; 52 };
53 53
54 static struct tree_descr xenfs_init_files[] = { 54 static const struct tree_descr xenfs_init_files[] = {
55 [2] = { "xenbus", &xen_xenbus_fops, S_IRUSR|S_IWUSR }, 55 [2] = { "xenbus", &xen_xenbus_fops, S_IRUSR|S_IWUSR },
56 { "capabilities", &capabilities_file_ops, S_IRUGO }, 56 { "capabilities", &capabilities_file_ops, S_IRUGO },
57 { "privcmd", &xen_privcmd_fops, S_IRUSR|S_IWUSR }, 57 { "privcmd", &xen_privcmd_fops, S_IRUSR|S_IWUSR },
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index bee1a36bc2ec..f4718098ac31 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -818,7 +818,7 @@ static const struct super_operations s_ops = {
818static int bm_fill_super(struct super_block *sb, void *data, int silent) 818static int bm_fill_super(struct super_block *sb, void *data, int silent)
819{ 819{
820 int err; 820 int err;
821 static struct tree_descr bm_files[] = { 821 static const struct tree_descr bm_files[] = {
822 [2] = {"status", &bm_status_operations, S_IWUSR|S_IRUGO}, 822 [2] = {"status", &bm_status_operations, S_IWUSR|S_IRUGO},
823 [3] = {"register", &bm_register_operations, S_IWUSR}, 823 [3] = {"register", &bm_register_operations, S_IWUSR},
824 /* last one */ {""} 824 /* last one */ {""}
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 7fd4ec4bb214..e892ae7d89f8 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -199,7 +199,7 @@ static const struct dentry_operations debugfs_dops = {
199 199
200static int debug_fill_super(struct super_block *sb, void *data, int silent) 200static int debug_fill_super(struct super_block *sb, void *data, int silent)
201{ 201{
202 static struct tree_descr debug_files[] = {{""}}; 202 static const struct tree_descr debug_files[] = {{""}};
203 struct debugfs_fs_info *fsi; 203 struct debugfs_fs_info *fsi;
204 int err; 204 int err;
205 205
diff --git a/fs/fuse/control.c b/fs/fuse/control.c
index 6e22748b0704..b9ea99c5b5b3 100644
--- a/fs/fuse/control.c
+++ b/fs/fuse/control.c
@@ -292,7 +292,7 @@ void fuse_ctl_remove_conn(struct fuse_conn *fc)
292 292
293static int fuse_ctl_fill_super(struct super_block *sb, void *data, int silent) 293static int fuse_ctl_fill_super(struct super_block *sb, void *data, int silent)
294{ 294{
295 struct tree_descr empty_descr = {""}; 295 static const struct tree_descr empty_descr = {""};
296 struct fuse_conn *fc; 296 struct fuse_conn *fc;
297 int err; 297 int err;
298 298
diff --git a/fs/libfs.c b/fs/libfs.c
index a8b62e5d43a9..a04395334bb1 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -507,7 +507,7 @@ EXPORT_SYMBOL(simple_write_end);
507 * to pass it an appropriate max_reserved value to avoid collisions. 507 * to pass it an appropriate max_reserved value to avoid collisions.
508 */ 508 */
509int simple_fill_super(struct super_block *s, unsigned long magic, 509int simple_fill_super(struct super_block *s, unsigned long magic,
510 struct tree_descr *files) 510 const struct tree_descr *files)
511{ 511{
512 struct inode *inode; 512 struct inode *inode;
513 struct dentry *root; 513 struct dentry *root;
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 8bf8f667a8cf..6493df6b1bd5 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -1146,7 +1146,7 @@ static ssize_t write_v4_end_grace(struct file *file, char *buf, size_t size)
1146 1146
1147static int nfsd_fill_super(struct super_block * sb, void * data, int silent) 1147static int nfsd_fill_super(struct super_block * sb, void * data, int silent)
1148{ 1148{
1149 static struct tree_descr nfsd_files[] = { 1149 static const struct tree_descr nfsd_files[] = {
1150 [NFSD_List] = {"exports", &exports_nfsd_operations, S_IRUGO}, 1150 [NFSD_List] = {"exports", &exports_nfsd_operations, S_IRUGO},
1151 [NFSD_Export_features] = {"export_features", 1151 [NFSD_Export_features] = {"export_features",
1152 &export_features_operations, S_IRUGO}, 1152 &export_features_operations, S_IRUGO},
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index 21d36d284735..328e89c2cf83 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -266,7 +266,7 @@ static const struct super_operations tracefs_super_operations = {
266 266
267static int trace_fill_super(struct super_block *sb, void *data, int silent) 267static int trace_fill_super(struct super_block *sb, void *data, int silent)
268{ 268{
269 static struct tree_descr trace_files[] = {{""}}; 269 static const struct tree_descr trace_files[] = {{""}};
270 struct tracefs_fs_info *fsi; 270 struct tracefs_fs_info *fsi;
271 int err; 271 int err;
272 272
diff --git a/include/linux/fs.h b/include/linux/fs.h
index dee12c171e07..fc1b4faa6272 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2995,9 +2995,10 @@ extern const struct file_operations simple_dir_operations;
2995extern const struct inode_operations simple_dir_inode_operations; 2995extern const struct inode_operations simple_dir_inode_operations;
2996extern void make_empty_dir_inode(struct inode *inode); 2996extern void make_empty_dir_inode(struct inode *inode);
2997extern bool is_empty_dir_inode(struct inode *inode); 2997extern bool is_empty_dir_inode(struct inode *inode);
2998struct tree_descr { char *name; const struct file_operations *ops; int mode; }; 2998struct tree_descr { const char *name; const struct file_operations *ops; int mode; };
2999struct dentry *d_alloc_name(struct dentry *, const char *); 2999struct dentry *d_alloc_name(struct dentry *, const char *);
3000extern int simple_fill_super(struct super_block *, unsigned long, struct tree_descr *); 3000extern int simple_fill_super(struct super_block *, unsigned long,
3001 const struct tree_descr *);
3001extern int simple_pin_fs(struct file_system_type *, struct vfsmount **mount, int *count); 3002extern int simple_pin_fs(struct file_system_type *, struct vfsmount **mount, int *count);
3002extern void simple_release_fs(struct vfsmount **mount, int *count); 3003extern void simple_release_fs(struct vfsmount **mount, int *count);
3003 3004
diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index fddcae801724..9bbd33497d3d 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -429,7 +429,7 @@ static int bpf_parse_options(char *data, struct bpf_mount_opts *opts)
429 429
430static int bpf_fill_super(struct super_block *sb, void *data, int silent) 430static int bpf_fill_super(struct super_block *sb, void *data, int silent)
431{ 431{
432 static struct tree_descr bpf_rfiles[] = { { "" } }; 432 static const struct tree_descr bpf_rfiles[] = { { "" } };
433 struct bpf_mount_opts opts; 433 struct bpf_mount_opts opts;
434 struct inode *inode; 434 struct inode *inode;
435 int ret; 435 int ret;
diff --git a/security/inode.c b/security/inode.c
index 2cb14162ff8d..eccd58ef2ae8 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -28,7 +28,7 @@ static int mount_count;
28 28
29static int fill_super(struct super_block *sb, void *data, int silent) 29static int fill_super(struct super_block *sb, void *data, int silent)
30{ 30{
31 static struct tree_descr files[] = {{""}}; 31 static const struct tree_descr files[] = {{""}};
32 32
33 return simple_fill_super(sb, SECURITYFS_MAGIC, files); 33 return simple_fill_super(sb, SECURITYFS_MAGIC, files);
34} 34}
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index cb3fd98fb05a..6a9efedf7eb2 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -1496,7 +1496,7 @@ static const struct file_operations sel_avc_cache_stats_ops = {
1496static int sel_make_avc_files(struct dentry *dir) 1496static int sel_make_avc_files(struct dentry *dir)
1497{ 1497{
1498 int i; 1498 int i;
1499 static struct tree_descr files[] = { 1499 static const struct tree_descr files[] = {
1500 { "cache_threshold", 1500 { "cache_threshold",
1501 &sel_avc_cache_threshold_ops, S_IRUGO|S_IWUSR }, 1501 &sel_avc_cache_threshold_ops, S_IRUGO|S_IWUSR },
1502 { "hash_stats", &sel_avc_hash_stats_ops, S_IRUGO }, 1502 { "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)
1805 struct inode *inode; 1805 struct inode *inode;
1806 struct inode_security_struct *isec; 1806 struct inode_security_struct *isec;
1807 1807
1808 static struct tree_descr selinux_files[] = { 1808 static const struct tree_descr selinux_files[] = {
1809 [SEL_LOAD] = {"load", &sel_load_ops, S_IRUSR|S_IWUSR}, 1809 [SEL_LOAD] = {"load", &sel_load_ops, S_IRUSR|S_IWUSR},
1810 [SEL_ENFORCE] = {"enforce", &sel_enforce_ops, S_IRUGO|S_IWUSR}, 1810 [SEL_ENFORCE] = {"enforce", &sel_enforce_ops, S_IRUGO|S_IWUSR},
1811 [SEL_CONTEXT] = {"context", &transaction_ops, S_IRUGO|S_IWUGO}, 1811 [SEL_CONTEXT] = {"context", &transaction_ops, S_IRUGO|S_IWUGO},
diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index 366b8356f75b..f6482e53d55a 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -2855,7 +2855,7 @@ static int smk_fill_super(struct super_block *sb, void *data, int silent)
2855 int rc; 2855 int rc;
2856 struct inode *root_inode; 2856 struct inode *root_inode;
2857 2857
2858 static struct tree_descr smack_files[] = { 2858 static const struct tree_descr smack_files[] = {
2859 [SMK_LOAD] = { 2859 [SMK_LOAD] = {
2860 "load", &smk_load_ops, S_IRUGO|S_IWUSR}, 2860 "load", &smk_load_ops, S_IRUGO|S_IWUSR},
2861 [SMK_CIPSO] = { 2861 [SMK_CIPSO] = {