diff mbox series

[net-next] net: netconsole: Constify struct config_item_type

Message ID 9c205b2b4bdb09fc9e9d2cb2f2936ec053da1b1b.1723325900.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State Accepted
Commit ed4290f39f417793928630e85c26411db233d841
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: netconsole: Constify struct config_item_type | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 29 this patch: 29
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 29 this patch: 29
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 29 this patch: 29
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-11--21-00 (tests: 707)

Commit Message

Christophe JAILLET Aug. 10, 2024, 9:39 p.m. UTC
'struct config_item_type' is not modified in this driver.

This structure is only used with config_group_init_type_name() which takes
a const struct config_item_type* as a 3rd argument.

This also makes things consistent with 'netconsole_target_type' witch is
already const.

Constifying this structure 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:
Before:
======
   text	   data	    bss	    dec	    hex	filename
  33007	   3952	   1312	  38271	   957f	drivers/net/netconsole.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
  33071	   3888	   1312	  38271	   957f	drivers/net/netconsole.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested-only.
---
 drivers/net/netconsole.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Breno Leitao Aug. 13, 2024, 10:46 a.m. UTC | #1
Hello Christophe,

On Sat, Aug 10, 2024 at 11:39:04PM +0200, Christophe JAILLET wrote:
> 'struct config_item_type' is not modified in this driver.
> 
> This structure is only used with config_group_init_type_name() which takes
> a const struct config_item_type* as a 3rd argument.
> 
> This also makes things consistent with 'netconsole_target_type' witch is
> already const.
> 
> Constifying this structure 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:
> Before:
> ======
>    text	   data	    bss	    dec	    hex	filename
>   33007	   3952	   1312	  38271	   957f	drivers/net/netconsole.o
> 
> After:
> =====
>    text	   data	    bss	    dec	    hex	filename
>   33071	   3888	   1312	  38271	   957f	drivers/net/netconsole.o
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Breno Leitao <leitao@debian.org>

> Compile tested-only.

I've tested it using a selftime I am creating, and it is all good.

Thanks for the patch!
--breno
patchwork-bot+netdevbpf@kernel.org Aug. 14, 2024, 2:30 a.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Sat, 10 Aug 2024 23:39:04 +0200 you wrote:
> 'struct config_item_type' is not modified in this driver.
> 
> This structure is only used with config_group_init_type_name() which takes
> a const struct config_item_type* as a 3rd argument.
> 
> This also makes things consistent with 'netconsole_target_type' witch is
> already const.
> 
> [...]

Here is the summary with links:
  - [net-next] net: netconsole: Constify struct config_item_type
    https://git.kernel.org/netdev/net-next/c/ed4290f39f41

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index ffedf7648bed..48b309e0a93a 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -778,7 +778,7 @@  static struct configfs_group_operations userdata_ops = {
 	.drop_item		= userdatum_drop,
 };
 
-static struct config_item_type userdata_type = {
+static const struct config_item_type userdata_type = {
 	.ct_item_ops	= &userdatum_ops,
 	.ct_group_ops	= &userdata_ops,
 	.ct_attrs	= userdata_attrs,