]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommufd: Constify struct dma_buf_attach_ops
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Thu, 26 Feb 2026 21:05:21 +0000 (22:05 +0100)
committerJason Gunthorpe <jgg@nvidia.com>
Tue, 3 Mar 2026 00:24:52 +0000 (20:24 -0400)
'struct dma_buf_attach_ops' is not modified in this driver.

Constifying this structure 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:
Before:
======
   text    data     bss     dec     hex filename
  81096   13899     192   95187   173d3 drivers/iommu/iommufd/pages.o

After:
=====
   text    data     bss     dec     hex filename
  81160   13835     192   95187   173d3 drivers/iommu/iommufd/pages.o

Link: https://patch.msgid.link/r/67e9126bbffa1d5c05124773a8dd4a3493be77ac.1772139886.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/iommufd/pages.c

index 9b49f0c5b4599938aeb8f3579c41ef552bc6f49d..4691456616ea39c34ca8b27df004c7cedcc9e5ab 100644 (file)
@@ -1450,7 +1450,7 @@ static void iopt_revoke_notify(struct dma_buf_attachment *attach)
        pages->dmabuf.phys.len = 0;
 }
 
-static struct dma_buf_attach_ops iopt_dmabuf_attach_revoke_ops = {
+static const struct dma_buf_attach_ops iopt_dmabuf_attach_revoke_ops = {
        .allow_peer2peer = true,
        .move_notify = iopt_revoke_notify,
 };