public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: Constify struct pci_error_handlers
@ 2025-01-19 20:29 Christophe JAILLET
  2025-02-03 22:37 ` Martin K. Petersen
  2025-02-10  2:58 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2025-01-19 20:29 UTC (permalink / raw)
  To: Adaptec OEM Raid Solutions, James E.J. Bottomley,
	Martin K. Petersen, Ketan Mukadam, Anil Gurumurthy,
	Sudarsana Kalluru, James Smart, Ram Vegesna,
	Sathya Prakash Veerichetty, Kashyap Desai, Sumit Saxena,
	Sreekanth Reddy, Suganath Prabu Subramani, Nilesh Javali,
	Manish Rangankar, GR-QLogic-Storage-Upstream
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-scsi,
	target-devel, mpi3mr-linuxdrv.pdl, MPT-FusionLinux.pdl

'struct pci_error_handlers' are not modified in these drivers.

Constifying these structures moves some data to a read-only section, so
increase 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
  39049	   6429	    112	  45590	   b216	drivers/scsi/aacraid/linit.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
  39113	   6365	    112	  45590	   b216	drivers/scsi/aacraid/linit.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested-only.
---
 drivers/scsi/aacraid/linit.c         | 2 +-
 drivers/scsi/be2iscsi/be_main.c      | 2 +-
 drivers/scsi/bfa/bfad.c              | 2 +-
 drivers/scsi/csiostor/csio_init.c    | 2 +-
 drivers/scsi/elx/efct/efct_driver.c  | 2 +-
 drivers/scsi/mpi3mr/mpi3mr_os.c      | 2 +-
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 2 +-
 drivers/scsi/qedi/qedi_main.c        | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 91170a67cc91..4b12e6dd8f07 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -2029,7 +2029,7 @@ static void aac_pci_resume(struct pci_dev *pdev)
 	dev_err(&pdev->dev, "aacraid: PCI error - resume\n");
 }
 
-static struct pci_error_handlers aac_pci_err_handler = {
+static const struct pci_error_handlers aac_pci_err_handler = {
 	.error_detected		= aac_pci_error_detected,
 	.mmio_enabled		= aac_pci_mmio_enabled,
 	.slot_reset		= aac_pci_slot_reset,
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 76a1e373386e..a8b399ed98fc 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -5776,7 +5776,7 @@ static void beiscsi_remove(struct pci_dev *pcidev)
 }
 
 
-static struct pci_error_handlers beiscsi_eeh_handlers = {
+static const struct pci_error_handlers beiscsi_eeh_handlers = {
 	.error_detected = beiscsi_eeh_err_detected,
 	.slot_reset = beiscsi_eeh_reset,
 	.resume = beiscsi_eeh_resume,
diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
index 6aa1d3a7e24b..f015c53de0d4 100644
--- a/drivers/scsi/bfa/bfad.c
+++ b/drivers/scsi/bfa/bfad.c
@@ -1642,7 +1642,7 @@ MODULE_DEVICE_TABLE(pci, bfad_id_table);
 /*
  * PCI error recovery handlers.
  */
-static struct pci_error_handlers bfad_err_handler = {
+static const struct pci_error_handlers bfad_err_handler = {
 	.error_detected = bfad_pci_error_detected,
 	.slot_reset = bfad_pci_slot_reset,
 	.mmio_enabled = bfad_pci_mmio_enabled,
diff --git a/drivers/scsi/csiostor/csio_init.c b/drivers/scsi/csiostor/csio_init.c
index 9a3f2ed050bd..79c8dafdd49e 100644
--- a/drivers/scsi/csiostor/csio_init.c
+++ b/drivers/scsi/csiostor/csio_init.c
@@ -1162,7 +1162,7 @@ csio_pci_resume(struct pci_dev *pdev)
 	dev_err(&pdev->dev, "resume of device failed: %d\n", rv);
 }
 
-static struct pci_error_handlers csio_err_handler = {
+static const struct pci_error_handlers csio_err_handler = {
 	.error_detected = csio_pci_error_detected,
 	.slot_reset	= csio_pci_slot_reset,
 	.resume		= csio_pci_resume,
diff --git a/drivers/scsi/elx/efct/efct_driver.c b/drivers/scsi/elx/efct/efct_driver.c
index 8469c156ab33..59f277593785 100644
--- a/drivers/scsi/elx/efct/efct_driver.c
+++ b/drivers/scsi/elx/efct/efct_driver.c
@@ -735,7 +735,7 @@ efct_pci_io_resume(struct pci_dev *pdev)
 
 MODULE_DEVICE_TABLE(pci, efct_pci_table);
 
-static struct pci_error_handlers efct_pci_err_handler = {
+static const struct pci_error_handlers efct_pci_err_handler = {
 	.error_detected = efct_pci_io_error_detected,
 	.slot_reset = efct_pci_io_slot_reset,
 	.resume = efct_pci_io_resume,
diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
index b9a51d3f2024..e3547ea42613 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_os.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
@@ -5803,7 +5803,7 @@ static const struct pci_device_id mpi3mr_pci_id_table[] = {
 };
 MODULE_DEVICE_TABLE(pci, mpi3mr_pci_id_table);
 
-static struct pci_error_handlers mpi3mr_err_handler = {
+static const struct pci_error_handlers mpi3mr_err_handler = {
 	.error_detected = mpi3mr_pcierr_error_detected,
 	.mmio_enabled = mpi3mr_pcierr_mmio_enabled,
 	.slot_reset = mpi3mr_pcierr_slot_reset,
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index a456e5ec74d8..92572cde3485 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -12710,7 +12710,7 @@ static const struct pci_device_id mpt3sas_pci_table[] = {
 };
 MODULE_DEVICE_TABLE(pci, mpt3sas_pci_table);
 
-static struct pci_error_handlers _mpt3sas_err_handler = {
+static const struct pci_error_handlers _mpt3sas_err_handler = {
 	.error_detected	= scsih_pci_error_detected,
 	.mmio_enabled	= scsih_pci_mmio_enabled,
 	.slot_reset	= scsih_pci_slot_reset,
diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
index c9539897048a..e87885cc701c 100644
--- a/drivers/scsi/qedi/qedi_main.c
+++ b/drivers/scsi/qedi/qedi_main.c
@@ -2876,7 +2876,7 @@ MODULE_DEVICE_TABLE(pci, qedi_pci_tbl);
 
 static enum cpuhp_state qedi_cpuhp_state;
 
-static struct pci_error_handlers qedi_err_handler = {
+static const struct pci_error_handlers qedi_err_handler = {
 	.error_detected = qedi_io_error_detected,
 };
 
-- 
2.48.1


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

* Re: [PATCH] scsi: Constify struct pci_error_handlers
  2025-01-19 20:29 [PATCH] scsi: Constify struct pci_error_handlers Christophe JAILLET
@ 2025-02-03 22:37 ` Martin K. Petersen
  2025-02-10  2:58 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2025-02-03 22:37 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Adaptec OEM Raid Solutions, James E.J. Bottomley,
	Martin K. Petersen, Ketan Mukadam, Anil Gurumurthy,
	Sudarsana Kalluru, James Smart, Ram Vegesna,
	Sathya Prakash Veerichetty, Kashyap Desai, Sumit Saxena,
	Sreekanth Reddy, Suganath Prabu Subramani, Nilesh Javali,
	Manish Rangankar, GR-QLogic-Storage-Upstream, linux-kernel,
	kernel-janitors, linux-scsi, target-devel, mpi3mr-linuxdrv.pdl,
	MPT-FusionLinux.pdl


Christophe,

> 'struct pci_error_handlers' are not modified in these drivers.
>
> Constifying these structures moves some data to a read-only section, so
> increase overall security, especially when the structure holds some
> function pointers.

Applied to 6.15/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] scsi: Constify struct pci_error_handlers
  2025-01-19 20:29 [PATCH] scsi: Constify struct pci_error_handlers Christophe JAILLET
  2025-02-03 22:37 ` Martin K. Petersen
@ 2025-02-10  2:58 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2025-02-10  2:58 UTC (permalink / raw)
  To: Adaptec OEM Raid Solutions, James E.J. Bottomley, Ketan Mukadam,
	Anil Gurumurthy, Sudarsana Kalluru, James Smart, Ram Vegesna,
	Sathya Prakash Veerichetty, Kashyap Desai, Sumit Saxena,
	Sreekanth Reddy, Suganath Prabu Subramani, Nilesh Javali,
	Manish Rangankar, GR-QLogic-Storage-Upstream, Christophe JAILLET
  Cc: Martin K . Petersen, linux-kernel, kernel-janitors, linux-scsi,
	target-devel, mpi3mr-linuxdrv.pdl, MPT-FusionLinux.pdl

On Sun, 19 Jan 2025 21:29:39 +0100, Christophe JAILLET wrote:

> 'struct pci_error_handlers' are not modified in these drivers.
> 
> Constifying these structures moves some data to a read-only section, so
> increase 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
>   39049	   6429	    112	  45590	   b216	drivers/scsi/aacraid/linit.o
> 
> [...]

Applied to 6.15/scsi-queue, thanks!

[1/1] scsi: Constify struct pci_error_handlers
      https://git.kernel.org/mkp/scsi/c/14807b4a4e03

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2025-02-10  2:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-19 20:29 [PATCH] scsi: Constify struct pci_error_handlers Christophe JAILLET
2025-02-03 22:37 ` Martin K. Petersen
2025-02-10  2:58 ` Martin K. Petersen

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