]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
md-cluster: Constify struct md_cluster_operations
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 23 Jun 2024 20:17:54 +0000 (22:17 +0200)
committerSong Liu <song@kernel.org>
Thu, 4 Jul 2024 06:20:27 +0000 (06:20 +0000)
'struct md_cluster_operations' is not modified in this driver.

Constifying this structure moves some data to a read-only section, so
increase overall security.

On a x86_64, with allmodconfig, as an example:
Before:
======
   text    data     bss     dec     hex filename
  51941    1442      80   53463    d0d7 drivers/md/md-cluster.o

After:
=====
   text    data     bss     dec     hex filename
  52133    1246      80   53459    d0d3 drivers/md/md-cluster.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/3727f3ce9693cae4e62ae6778ea13971df805479.1719173852.git.christophe.jaillet@wanadoo.fr
drivers/md/md-cluster.c
drivers/md/md.c
drivers/md/md.h

index 8e36a0feec09896eda6bc88ac0a855ae82da0f13..139fe2019c1dd66fbbf2196c751a03c427466c8c 100644 (file)
@@ -1570,7 +1570,7 @@ out:
        return err;
 }
 
-static struct md_cluster_operations cluster_ops = {
+static const struct md_cluster_operations cluster_ops = {
        .join   = join,
        .leave  = leave,
        .slot_number = slot_number,
index 149be072546a59a6f0769b340dd0bd47f88ac4dd..b50721ddf5d37fa0330011dc2ab2e9c56fd84944 100644 (file)
@@ -85,7 +85,7 @@ static DEFINE_SPINLOCK(pers_lock);
 
 static const struct kobj_type md_ktype;
 
-struct md_cluster_operations *md_cluster_ops;
+const struct md_cluster_operations *md_cluster_ops;
 EXPORT_SYMBOL(md_cluster_ops);
 static struct module *md_cluster_mod;
 
@@ -8543,7 +8543,7 @@ int unregister_md_personality(struct md_personality *p)
 }
 EXPORT_SYMBOL(unregister_md_personality);
 
-int register_md_cluster_operations(struct md_cluster_operations *ops,
+int register_md_cluster_operations(const struct md_cluster_operations *ops,
                                   struct module *module)
 {
        int ret = 0;
index 28cb4b0b6c1740ea564b3aade87553aa2b3f19e0..a0d6827dced9b79fcaba188e8ddb7c0d71b656e5 100644 (file)
@@ -849,7 +849,7 @@ static inline void safe_put_page(struct page *p)
 
 extern int register_md_personality(struct md_personality *p);
 extern int unregister_md_personality(struct md_personality *p);
-extern int register_md_cluster_operations(struct md_cluster_operations *ops,
+extern int register_md_cluster_operations(const struct md_cluster_operations *ops,
                struct module *module);
 extern int unregister_md_cluster_operations(void);
 extern int md_setup_cluster(struct mddev *mddev, int nodes);
@@ -932,7 +932,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
        }
 }
 
-extern struct md_cluster_operations *md_cluster_ops;
+extern const struct md_cluster_operations *md_cluster_ops;
 static inline int mddev_is_clustered(struct mddev *mddev)
 {
        return mddev->cluster_info && mddev->bitmap_info.nodes > 1;