netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] can: m_can: Constify struct m_can_ops
@ 2024-06-23 20:01 Christophe JAILLET
  2024-06-24  6:08 ` Marc Kleine-Budde
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2024-06-23 20:01 UTC (permalink / raw)
  To: Chandrasekar Ramakrishnan, Marc Kleine-Budde, Vincent Mailhol,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-can,
	netdev

'struct m_can_ops' 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
   4806	    520	      0	   5326	   14ce	drivers/net/can/m_can/m_can_pci.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
   4862	    464	      0	   5326	   14ce	drivers/net/can/m_can/m_can_pci.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested-only
---
 drivers/net/can/m_can/m_can.h          | 2 +-
 drivers/net/can/m_can/m_can_pci.c      | 2 +-
 drivers/net/can/m_can/m_can_platform.c | 2 +-
 drivers/net/can/m_can/tcan4x5x-core.c  | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h
index 3a9edc292593..92b2bd8628e6 100644
--- a/drivers/net/can/m_can/m_can.h
+++ b/drivers/net/can/m_can/m_can.h
@@ -91,7 +91,7 @@ struct m_can_classdev {
 
 	ktime_t irq_timer_wait;
 
-	struct m_can_ops *ops;
+	const struct m_can_ops *ops;
 
 	int version;
 	u32 irqstatus;
diff --git a/drivers/net/can/m_can/m_can_pci.c b/drivers/net/can/m_can/m_can_pci.c
index 45400de4163d..d72fe771dfc7 100644
--- a/drivers/net/can/m_can/m_can_pci.c
+++ b/drivers/net/can/m_can/m_can_pci.c
@@ -77,7 +77,7 @@ static int iomap_write_fifo(struct m_can_classdev *cdev, int offset,
 	return 0;
 }
 
-static struct m_can_ops m_can_pci_ops = {
+static const struct m_can_ops m_can_pci_ops = {
 	.read_reg = iomap_read_reg,
 	.write_reg = iomap_write_reg,
 	.write_fifo = iomap_write_fifo,
diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
index df0367124b4c..983ab80260dd 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -68,7 +68,7 @@ static int iomap_write_fifo(struct m_can_classdev *cdev, int offset,
 	return 0;
 }
 
-static struct m_can_ops m_can_plat_ops = {
+static const struct m_can_ops m_can_plat_ops = {
 	.read_reg = iomap_read_reg,
 	.write_reg = iomap_write_reg,
 	.write_fifo = iomap_write_fifo,
diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c
index a42600dac70d..f15619d31065 100644
--- a/drivers/net/can/m_can/tcan4x5x-core.c
+++ b/drivers/net/can/m_can/tcan4x5x-core.c
@@ -357,7 +357,7 @@ static int tcan4x5x_get_gpios(struct m_can_classdev *cdev,
 	return 0;
 }
 
-static struct m_can_ops tcan4x5x_ops = {
+static const struct m_can_ops tcan4x5x_ops = {
 	.init = tcan4x5x_init,
 	.read_reg = tcan4x5x_read_reg,
 	.write_reg = tcan4x5x_write_reg,
-- 
2.45.2


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

* Re: [PATCH net-next] can: m_can: Constify struct m_can_ops
  2024-06-23 20:01 [PATCH net-next] can: m_can: Constify struct m_can_ops Christophe JAILLET
@ 2024-06-24  6:08 ` Marc Kleine-Budde
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Kleine-Budde @ 2024-06-24  6:08 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Chandrasekar Ramakrishnan, Vincent Mailhol, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel,
	kernel-janitors, linux-can, netdev

[-- Attachment #1: Type: text/plain, Size: 960 bytes --]

On 23.06.2024 22:01:50, Christophe JAILLET wrote:
> 'struct m_can_ops' 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
>    4806	    520	      0	   5326	   14ce	drivers/net/can/m_can/m_can_pci.o
> 
> After:
> =====
>    text	   data	    bss	    dec	    hex	filename
>    4862	    464	      0	   5326	   14ce	drivers/net/can/m_can/m_can_pci.o
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied to linuc-can-next.

Thanks,
Marc


-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2024-06-24  6:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-23 20:01 [PATCH net-next] can: m_can: Constify struct m_can_ops Christophe JAILLET
2024-06-24  6:08 ` Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).