]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
netconsole: Constify struct configfs_item_operations and configfs_group_operations
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Mon, 25 May 2026 12:23:00 +0000 (14:23 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 27 May 2026 01:04:58 +0000 (18:04 -0700)
'struct configfs_item_operations' and 'configfs_group_operations' are not
modified in this driver.

Constifying these structures moves some data to a read-only section, so
increases overall security, especially when the structure holds some
function pointers.

On a x86_64, with allmodconfig, as an example:
Before:
======
   text    data     bss     dec     hex filename
  64259   24272     608   89139   15c33 drivers/net/netconsole.o

After:
=====
   text    data     bss     dec     hex filename
  64579   23952     608   89139   15c33 drivers/net/netconsole.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/7ff56bdb0cee826a56365f930dcdf457b44931df.1779711734.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/netconsole.c

index d804d44af87c811c6be419a0d22dad4541fff9ef..8ecc2c71c699c837dd1a22745ef9a64ae37da51a 100644 (file)
@@ -1264,7 +1264,7 @@ static void userdatum_release(struct config_item *item)
        kfree(to_userdatum(item));
 }
 
-static struct configfs_item_operations userdatum_ops = {
+static const struct configfs_item_operations userdatum_ops = {
        .release = userdatum_release,
 };
 
@@ -1319,7 +1319,7 @@ static struct configfs_attribute *userdata_attrs[] = {
        NULL,
 };
 
-static struct configfs_group_operations userdata_ops = {
+static const struct configfs_group_operations userdata_ops = {
        .make_item              = userdatum_make_item,
        .drop_item              = userdatum_drop,
 };
@@ -1370,7 +1370,7 @@ static void netconsole_target_release(struct config_item *item)
        kfree(nt);
 }
 
-static struct configfs_item_operations netconsole_target_item_ops = {
+static const struct configfs_item_operations netconsole_target_item_ops = {
        .release                = netconsole_target_release,
 };
 
@@ -1480,7 +1480,7 @@ static void drop_netconsole_target(struct config_group *group,
        config_item_put(&nt->group.cg_item);
 }
 
-static struct configfs_group_operations netconsole_subsys_group_ops = {
+static const struct configfs_group_operations netconsole_subsys_group_ops = {
        .make_group     = make_netconsole_target,
        .drop_item      = drop_netconsole_target,
 };