[PATCH] ata: Constify struct pci_device_id

Christophe JAILLET posted 1 patch 6 days, 13 hours ago
drivers/ata/ata_generic.c  | 2 +-
drivers/ata/pata_atp867x.c | 2 +-
drivers/ata/pata_piccolo.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
[PATCH] ata: Constify struct pci_device_id
Posted by Christophe JAILLET 6 days, 13 hours ago
'struct pci_device_id' is not modified in these drivers.

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
   4245	   1454	      4	   5703	   1647	drivers/ata/ata_generic.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
   4725	    974	      4	   5703	   1647	drivers/ata/ata_generic.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested-only.
---
---
 drivers/ata/ata_generic.c  | 2 +-
 drivers/ata/pata_atp867x.c | 2 +-
 drivers/ata/pata_piccolo.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c
index 2f57ec00ab82..e70b6c089cf1 100644
--- a/drivers/ata/ata_generic.c
+++ b/drivers/ata/ata_generic.c
@@ -209,7 +209,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id
 	return ata_pci_bmdma_init_one(dev, ppi, &generic_sht, (void *)id, 0);
 }
 
-static struct pci_device_id ata_generic[] = {
+static const struct pci_device_id ata_generic[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_PCTECH, PCI_DEVICE_ID_PCTECH_SAMURAI_IDE), },
 	{ PCI_DEVICE(PCI_VENDOR_ID_HOLTEK, PCI_DEVICE_ID_HOLTEK_6565), },
 	{ PCI_DEVICE(PCI_VENDOR_ID_UMC,    PCI_DEVICE_ID_UMC_UM8673F), },
diff --git a/drivers/ata/pata_atp867x.c b/drivers/ata/pata_atp867x.c
index aaef5924f636..308f86f9e2f0 100644
--- a/drivers/ata/pata_atp867x.c
+++ b/drivers/ata/pata_atp867x.c
@@ -525,7 +525,7 @@ static int atp867x_reinit_one(struct pci_dev *pdev)
 }
 #endif
 
-static struct pci_device_id atp867x_pci_tbl[] = {
+static const struct pci_device_id atp867x_pci_tbl[] = {
 	{ PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP867A),	0 },
 	{ PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP867B),	0 },
 	{ },
diff --git a/drivers/ata/pata_piccolo.c b/drivers/ata/pata_piccolo.c
index ced906bf56be..beb53bd990be 100644
--- a/drivers/ata/pata_piccolo.c
+++ b/drivers/ata/pata_piccolo.c
@@ -97,7 +97,7 @@ static int ata_tosh_init_one(struct pci_dev *dev, const struct pci_device_id *id
 	return ata_pci_bmdma_init_one(dev, ppi, &tosh_sht, NULL, 0);
 }
 
-static struct pci_device_id ata_tosh[] = {
+static const struct pci_device_id ata_tosh[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), },
 	{ PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_2),  },
 	{ PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_3),  },
-- 
2.47.0
Re: [PATCH] ata: Constify struct pci_device_id
Posted by Niklas Cassel 3 days, 23 hours ago
On Fri, Nov 15, 2024 at 10:08:55PM +0100, Christophe JAILLET wrote:
> 'struct pci_device_id' is not modified in these drivers.
> 
> 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
>    4245	   1454	      4	   5703	   1647	drivers/ata/ata_generic.o
> 
> After:
> =====
>    text	   data	    bss	    dec	    hex	filename
>    4725	    974	      4	   5703	   1647	drivers/ata/ata_generic.o
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Compile tested-only.
> ---
> ---
>  drivers/ata/ata_generic.c  | 2 +-
>  drivers/ata/pata_atp867x.c | 2 +-
>  drivers/ata/pata_piccolo.c | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c
> index 2f57ec00ab82..e70b6c089cf1 100644
> --- a/drivers/ata/ata_generic.c
> +++ b/drivers/ata/ata_generic.c
> @@ -209,7 +209,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id
>  	return ata_pci_bmdma_init_one(dev, ppi, &generic_sht, (void *)id, 0);
>  }
>  
> -static struct pci_device_id ata_generic[] = {
> +static const struct pci_device_id ata_generic[] = {
>  	{ PCI_DEVICE(PCI_VENDOR_ID_PCTECH, PCI_DEVICE_ID_PCTECH_SAMURAI_IDE), },
>  	{ PCI_DEVICE(PCI_VENDOR_ID_HOLTEK, PCI_DEVICE_ID_HOLTEK_6565), },
>  	{ PCI_DEVICE(PCI_VENDOR_ID_UMC,    PCI_DEVICE_ID_UMC_UM8673F), },
> diff --git a/drivers/ata/pata_atp867x.c b/drivers/ata/pata_atp867x.c
> index aaef5924f636..308f86f9e2f0 100644
> --- a/drivers/ata/pata_atp867x.c
> +++ b/drivers/ata/pata_atp867x.c
> @@ -525,7 +525,7 @@ static int atp867x_reinit_one(struct pci_dev *pdev)
>  }
>  #endif
>  
> -static struct pci_device_id atp867x_pci_tbl[] = {
> +static const struct pci_device_id atp867x_pci_tbl[] = {
>  	{ PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP867A),	0 },
>  	{ PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP867B),	0 },
>  	{ },
> diff --git a/drivers/ata/pata_piccolo.c b/drivers/ata/pata_piccolo.c
> index ced906bf56be..beb53bd990be 100644
> --- a/drivers/ata/pata_piccolo.c
> +++ b/drivers/ata/pata_piccolo.c
> @@ -97,7 +97,7 @@ static int ata_tosh_init_one(struct pci_dev *dev, const struct pci_device_id *id
>  	return ata_pci_bmdma_init_one(dev, ppi, &tosh_sht, NULL, 0);
>  }
>  
> -static struct pci_device_id ata_tosh[] = {
> +static const struct pci_device_id ata_tosh[] = {
>  	{ PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), },
>  	{ PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_2),  },
>  	{ PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_3),  },
> -- 
> 2.47.0
> 

Looks good to me:
Reviewed-by: Niklas Cassel <cassel@kernel.org>

However, since we are in the middle of the merge window, expect to wait
until 6.13-rc1 is out until this is picked up.


Kind regards,
Niklas
Re: [PATCH] ata: Constify struct pci_device_id
Posted by Sergey Shtylyov 4 days, 22 hours ago
On 11/16/24 12:08 AM, Christophe JAILLET wrote:

> 'struct pci_device_id' is not modified in these drivers.
> 
> 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
>    4245	   1454	      4	   5703	   1647	drivers/ata/ata_generic.o
> 
> After:
> =====
>    text	   data	    bss	    dec	    hex	filename
>    4725	    974	      4	   5703	   1647	drivers/ata/ata_generic.o
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

[...]
   No longer an "official" PATA reviewer, but FWIW:

Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>

MBR, Sergey