devlink: Constify the 'table_ops' parameter of devl_dpipe_table_register()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 2 Jun 2024 14:18:52 +0000 (16:18 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 5 Jun 2024 09:24:57 +0000 (10:24 +0100)
"struct devlink_dpipe_table_ops" only contains some function pointers.

Update "struct devlink_dpipe_table" and the 'table_ops' parameter of
devl_dpipe_table_register() so that structures in drivers can be
constified.

Constifying these structures will move some data to a read-only section, so
increase overall security.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/devlink.h
net/devlink/dpipe.c

index 35eb0f884386175259231855b2c3287b3ae36d00..db5eff6cb60fa0c095ae7bac937d823281389499 100644 (file)
@@ -352,7 +352,7 @@ struct devlink_dpipe_table {
        bool resource_valid;
        u64 resource_id;
        u64 resource_units;
-       struct devlink_dpipe_table_ops *table_ops;
+       const struct devlink_dpipe_table_ops *table_ops;
        struct rcu_head rcu;
 };
 
@@ -1751,7 +1751,7 @@ void devl_sb_unregister(struct devlink *devlink, unsigned int sb_index);
 void devlink_sb_unregister(struct devlink *devlink, unsigned int sb_index);
 int devl_dpipe_table_register(struct devlink *devlink,
                              const char *table_name,
-                             struct devlink_dpipe_table_ops *table_ops,
+                             const struct devlink_dpipe_table_ops *table_ops,
                              void *priv, bool counter_control_extern);
 void devl_dpipe_table_unregister(struct devlink *devlink,
                                 const char *table_name);
index a72a9292efc5cfc1a8548d04a7f404941a24874c..55009b377447fe7734a1533828185e8e2e162bd8 100644 (file)
@@ -839,7 +839,7 @@ EXPORT_SYMBOL_GPL(devlink_dpipe_table_counter_enabled);
  */
 int devl_dpipe_table_register(struct devlink *devlink,
                              const char *table_name,
-                             struct devlink_dpipe_table_ops *table_ops,
+                             const struct devlink_dpipe_table_ops *table_ops,
                              void *priv, bool counter_control_extern)
 {
        struct devlink_dpipe_table *table;