]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ocfs2: constify struct ocfs2_stack_operations
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Fri, 14 Jun 2024 20:57:09 +0000 (22:57 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 25 Jun 2024 05:25:10 +0000 (22:25 -0700)
"struct ocfs2_stack_operations" are not modified in this driver.

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

In order to do it, "struct ocfs2_stack_plugin" also needs to be adjusted
to this new const qualifier.

On a x86_64, with allmodconfig:
Before:
======
   text    data     bss     dec     hex filename
   6241     644       0    6885    1ae5 fs/ocfs2/stack_o2cb.o

After:
=====
   text    data     bss     dec     hex filename
   6337     548       0    6885    1ae5 fs/ocfs2/stack_o2cb.o

Link: https://lkml.kernel.org/r/f52dab89ee0049ec6271de29183a781efbb275ab.1718398605.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Joseph Qi <jiangqi903@gmail.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Gang He <ghe@suse.com>
Cc: Jun Piao <piaojun@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/ocfs2/stack_o2cb.c
fs/ocfs2/stack_user.c
fs/ocfs2/stackglue.h

index c973c03f6fd8b2df5b7a01e560d3e9dcaa1a7abc..10157d9d7a9c0b99421bebf284ddb2c0b636c283 100644 (file)
@@ -404,7 +404,7 @@ static int o2cb_cluster_this_node(struct ocfs2_cluster_connection *conn,
        return 0;
 }
 
-static struct ocfs2_stack_operations o2cb_stack_ops = {
+static const struct ocfs2_stack_operations o2cb_stack_ops = {
        .connect        = o2cb_cluster_connect,
        .disconnect     = o2cb_cluster_disconnect,
        .this_node      = o2cb_cluster_this_node,
index c11406cd87a88e5329d78a8bd252a180d810e361..77edcd70f72c21db4f16b436e8b464ec710b5c8e 100644 (file)
@@ -1065,7 +1065,7 @@ static int user_cluster_this_node(struct ocfs2_cluster_connection *conn,
        return 0;
 }
 
-static struct ocfs2_stack_operations ocfs2_user_plugin_ops = {
+static const struct ocfs2_stack_operations ocfs2_user_plugin_ops = {
        .connect        = user_cluster_connect,
        .disconnect     = user_cluster_disconnect,
        .this_node      = user_cluster_this_node,
index 3636847fae19eae12fbe3789bdf89ded2a42edc7..02ab072c528a781e1d02273bb912255f6faa47bf 100644 (file)
@@ -223,7 +223,7 @@ struct ocfs2_stack_operations {
  */
 struct ocfs2_stack_plugin {
        char *sp_name;
-       struct ocfs2_stack_operations *sp_ops;
+       const struct ocfs2_stack_operations *sp_ops;
        struct module *sp_owner;
 
        /* These are managed by the stackglue code. */