RDMA/hfi1: Constify struct mmu_rb_ops
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Mon, 24 Jun 2024 20:13:27 +0000 (22:13 +0200)
committerJason Gunthorpe <jgg@nvidia.com>
Wed, 26 Jun 2024 13:53:29 +0000 (10:53 -0300)
'struct mmu_rb_ops' 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
  10879     164       0   11043    2b23 drivers/infiniband/hw/hfi1/pin_system.o

After:
=====
   text    data     bss     dec     hex filename
  10907     140       0   11047    2b27 drivers/infiniband/hw/hfi1/pin_system.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/b826dd05eefa5f4d6a7a1b4d191eaf37c714ed04.1719259997.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/hfi1/mmu_rb.c
drivers/infiniband/hw/hfi1/mmu_rb.h
drivers/infiniband/hw/hfi1/pin_system.c

index d4a6acad0e65e4f045c60a7aee72e57b33195dfd..67a5c410fb5e1943dfa937ec47513b154c4a9955 100644 (file)
@@ -40,7 +40,7 @@ static unsigned long mmu_node_last(struct mmu_rb_node *node)
 }
 
 int hfi1_mmu_rb_register(void *ops_arg,
-                        struct mmu_rb_ops *ops,
+                        const struct mmu_rb_ops *ops,
                         struct workqueue_struct *wq,
                         struct mmu_rb_handler **handler)
 {
index 8e5d05454d703a59870d722acee888ef8d4d4692..3fa50dd64db6edf8f26afcfe88aba78c9d4654a7 100644 (file)
@@ -42,7 +42,7 @@ struct mmu_rb_handler {
        /* Begin on a new cachline boundary here */
        struct rb_root_cached root ____cacheline_aligned_in_smp;
        void *ops_arg;
-       struct mmu_rb_ops *ops;
+       const struct mmu_rb_ops *ops;
        struct list_head lru_list;
        struct work_struct del_work;
        struct list_head del_list;
@@ -51,7 +51,7 @@ struct mmu_rb_handler {
 };
 
 int hfi1_mmu_rb_register(void *ops_arg,
-                        struct mmu_rb_ops *ops,
+                        const struct mmu_rb_ops *ops,
                         struct workqueue_struct *wq,
                         struct mmu_rb_handler **handler);
 void hfi1_mmu_rb_unregister(struct mmu_rb_handler *handler);
index 384f722093e0b13737a671b1c6a3d5f9c2ece844..cce56134519ba851e41dab92ed2ae653b5dab689 100644 (file)
@@ -26,7 +26,7 @@ static int sdma_rb_evict(void *arg, struct mmu_rb_node *mnode, void *arg2,
                         bool *stop);
 static void sdma_rb_remove(void *arg, struct mmu_rb_node *mnode);
 
-static struct mmu_rb_ops sdma_rb_ops = {
+static const struct mmu_rb_ops sdma_rb_ops = {
        .filter = sdma_rb_filter,
        .evict = sdma_rb_evict,
        .remove = sdma_rb_remove,