mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] RDMA/mlx5: Constify struct ib_frmr_pool_ops and dma_buf_attach_ops
@ 2026-07-14  8:19 Christophe JAILLET
  2026-07-15  9:09 ` Leon Romanovsky
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2026-07-14  8:19 UTC (permalink / raw)
  To: Leon Romanovsky, Jason Gunthorpe
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-rdma

'struct ib_frmr_pool_ops' and 'struct dma_buf_attach_ops' 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.

While at it, change a '1' into a 'true' into the mlx5_ib_dmabuf_attach_ops
structure. The 'allow_peer2peer' field is a bool and other usages of
'struct dma_buf_attach_ops' prefer using true/false.

On a x86_64, with allmodconfig, as an example:
Before:
======
   text	   data	    bss	    dec	    hex	filename
  77631	  10392	    320	  88343	  15917	drivers/infiniband/hw/mlx5/mr.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
  77759	  10264	    320	  88343	  15917	drivers/infiniband/hw/mlx5/mr.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only.
---
 drivers/infiniband/hw/mlx5/mr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index e6b74955d95d..00e13028762a 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -339,7 +339,7 @@ static int mlx5r_build_frmr_key(struct ib_device *device,
 	return 0;
 }
 
-static struct ib_frmr_pool_ops mlx5r_frmr_pool_ops = {
+static const struct ib_frmr_pool_ops mlx5r_frmr_pool_ops = {
 	.create_frmrs = mlx5r_create_mkeys,
 	.destroy_frmrs = mlx5r_destroy_mkeys,
 	.build_key = mlx5r_build_frmr_key,
@@ -898,8 +898,8 @@ static void mlx5_ib_dmabuf_invalidate_cb(struct dma_buf_attachment *attach)
 	ib_umem_dmabuf_unmap_pages(umem_dmabuf);
 }
 
-static struct dma_buf_attach_ops mlx5_ib_dmabuf_attach_ops = {
-	.allow_peer2peer = 1,
+static const struct dma_buf_attach_ops mlx5_ib_dmabuf_attach_ops = {
+	.allow_peer2peer = true,
 	.invalidate_mappings = mlx5_ib_dmabuf_invalidate_cb,
 };
 
-- 
2.55.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] RDMA/mlx5: Constify struct ib_frmr_pool_ops and dma_buf_attach_ops
  2026-07-14  8:19 [PATCH] RDMA/mlx5: Constify struct ib_frmr_pool_ops and dma_buf_attach_ops Christophe JAILLET
@ 2026-07-15  9:09 ` Leon Romanovsky
  0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2026-07-15  9:09 UTC (permalink / raw)
  To: Jason Gunthorpe, Christophe JAILLET
  Cc: linux-kernel, kernel-janitors, linux-rdma


On Tue, 14 Jul 2026 10:19:06 +0200, Christophe JAILLET wrote:
> 'struct ib_frmr_pool_ops' and 'struct dma_buf_attach_ops' 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.
> 
> [...]

Applied, thanks!

[1/1] RDMA/mlx5: Constify struct ib_frmr_pool_ops and dma_buf_attach_ops
      https://git.kernel.org/rdma/rdma/c/dcae56cfecc6e1

Best regards,
-- 
Leon Romanovsky <leon@kernel.org>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-15  9:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-14  8:19 [PATCH] RDMA/mlx5: Constify struct ib_frmr_pool_ops and dma_buf_attach_ops Christophe JAILLET
2026-07-15  9:09 ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox