mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scsi: target: tcmu: Constify some structures
@ 2024-11-11 13:10 Christophe JAILLET
  2024-11-12 13:49 ` Bodo Stroesser
  2024-11-21  2:55 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2024-11-11 13:10 UTC (permalink / raw)
  To: Bodo Stroesser, Martin K. Petersen
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-scsi,
	target-devel

'struct nla_policy' and 'struct match_table_t' are not modified in this
driver.

Constifying these structures moves some data to a read-only section, so
increase overall security, especially when the structure holds some
function pointers, which is the case of struct nla_policy.

On a x86_64, with allmodconfig:
Before:
======
   text	   data	    bss	    dec	    hex	filename
  93188	   6933	    338	 100459	  1886b	drivers/target/target_core_user.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
  93508	   6581	    338	 100427	  1884b	drivers/target/target_core_user.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only
---
 drivers/target/target_core_user.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 717931267bda..0f5d820af119 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -361,7 +361,7 @@ static const struct genl_multicast_group tcmu_mcgrps[] = {
 	[TCMU_MCGRP_CONFIG] = { .name = "config", },
 };
 
-static struct nla_policy tcmu_attr_policy[TCMU_ATTR_MAX+1] = {
+static const struct nla_policy tcmu_attr_policy[TCMU_ATTR_MAX + 1] = {
 	[TCMU_ATTR_DEVICE]	= { .type = NLA_STRING },
 	[TCMU_ATTR_MINOR]	= { .type = NLA_U32 },
 	[TCMU_ATTR_CMD_STATUS]	= { .type = NLA_S32 },
@@ -2430,7 +2430,7 @@ enum {
 	Opt_cmd_ring_size_mb, Opt_err,
 };
 
-static match_table_t tokens = {
+static const match_table_t tokens = {
 	{Opt_dev_config, "dev_config=%s"},
 	{Opt_dev_size, "dev_size=%s"},
 	{Opt_hw_block_size, "hw_block_size=%d"},
-- 
2.47.0


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

* Re: [PATCH] scsi: target: tcmu: Constify some structures
  2024-11-11 13:10 [PATCH] scsi: target: tcmu: Constify some structures Christophe JAILLET
@ 2024-11-12 13:49 ` Bodo Stroesser
  2024-11-21  2:55 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Bodo Stroesser @ 2024-11-12 13:49 UTC (permalink / raw)
  To: Christophe JAILLET, Martin K. Petersen
  Cc: linux-kernel, kernel-janitors, linux-scsi, target-devel

On 11.11.24 14:10, Christophe JAILLET wrote:
> 'struct nla_policy' and 'struct match_table_t' are not modified in this
> driver.
> 
> Constifying these structures moves some data to a read-only section, so
> increase overall security, especially when the structure holds some
> function pointers, which is the case of struct nla_policy.
> 
> On a x86_64, with allmodconfig:
> Before:
> ======
>     text	   data	    bss	    dec	    hex	filename
>    93188	   6933	    338	 100459	  1886b	drivers/target/target_core_user.o
> 
> After:
> =====
>     text	   data	    bss	    dec	    hex	filename
>    93508	   6581	    338	 100427	  1884b	drivers/target/target_core_user.o
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Compile tested only
> ---
>   drivers/target/target_core_user.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
> index 717931267bda..0f5d820af119 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -361,7 +361,7 @@ static const struct genl_multicast_group tcmu_mcgrps[] = {
>   	[TCMU_MCGRP_CONFIG] = { .name = "config", },
>   };
>   
> -static struct nla_policy tcmu_attr_policy[TCMU_ATTR_MAX+1] = {
> +static const struct nla_policy tcmu_attr_policy[TCMU_ATTR_MAX + 1] = {
>   	[TCMU_ATTR_DEVICE]	= { .type = NLA_STRING },
>   	[TCMU_ATTR_MINOR]	= { .type = NLA_U32 },
>   	[TCMU_ATTR_CMD_STATUS]	= { .type = NLA_S32 },
> @@ -2430,7 +2430,7 @@ enum {
>   	Opt_cmd_ring_size_mb, Opt_err,
>   };
>   
> -static match_table_t tokens = {
> +static const match_table_t tokens = {
>   	{Opt_dev_config, "dev_config=%s"},
>   	{Opt_dev_size, "dev_size=%s"},
>   	{Opt_hw_block_size, "hw_block_size=%d"},


Reviewed-by: Bodo Stroesser <bostroesser@gmail.com>

Thanks,
Bodo

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

* Re: [PATCH] scsi: target: tcmu: Constify some structures
  2024-11-11 13:10 [PATCH] scsi: target: tcmu: Constify some structures Christophe JAILLET
  2024-11-12 13:49 ` Bodo Stroesser
@ 2024-11-21  2:55 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2024-11-21  2:55 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Bodo Stroesser, Martin K. Petersen, linux-kernel,
	kernel-janitors, linux-scsi, target-devel


Christophe,

> 'struct nla_policy' and 'struct match_table_t' are not modified in this
> driver.

Applied to 6.13/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2024-11-21  2:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-11 13:10 [PATCH] scsi: target: tcmu: Constify some structures Christophe JAILLET
2024-11-12 13:49 ` Bodo Stroesser
2024-11-21  2:55 ` 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

all inboxes | Powered by JetHome®