linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: genetlink: Move initialization to core_initcall
@ 2020-07-15  7:41 Daniel Lezcano
  2020-07-15  7:43 ` Daniel Lezcano
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Daniel Lezcano @ 2020-07-15  7:41 UTC (permalink / raw)
  To: davem
  Cc: daniel.lezcano, Jakub Kicinski, Jiri Pirko, Cong Wang,
	Johannes Berg, Michal Kubecek, open list:NETWORKING [GENERAL],
	open list

The generic netlink is initialized far after the netlink protocol
itself at subsys_initcall. The devlink is initialized at the same
level, but after, as shown by a disassembly of the vmlinux:

[ ... ]
374 ffff8000115f22c0 <__initcall_devlink_init4>:
375 ffff8000115f22c4 <__initcall_genl_init4>:
[ ... ]

The function devlink_init() calls genl_register_family() before the
generic netlink subsystem is initialized.

As the generic netlink initcall level is set since 2005, it seems that
was not a problem, but now we have the thermal framework initialized
at the core_initcall level which creates the generic netlink family
and sends a notification which leads to a subtle memory corruption
only detectable when the CONFIG_INIT_ON_ALLOC_DEFAULT_ON option is set
with the earlycon at init time.

The thermal framework needs to be initialized early in order to begin
the mitigation as soon as possible. Moving it to postcore_initcall is
acceptable.

This patch changes the initialization level for the generic netlink
family to the core_initcall and comes after the netlink protocol
initialization.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 net/netlink/genetlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 55ee680e9db1..36b8a1909826 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -1263,7 +1263,7 @@ static int __init genl_init(void)
 	panic("GENL: Cannot register controller: %d\n", err);
 }
 
-subsys_initcall(genl_init);
+core_initcall(genl_init);
 
 static int genlmsg_mcast(struct sk_buff *skb, u32 portid, unsigned long group,
 			 gfp_t flags)
-- 
2.17.1


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

* Re: [PATCH] net: genetlink: Move initialization to core_initcall
  2020-07-15  7:41 [PATCH] net: genetlink: Move initialization to core_initcall Daniel Lezcano
@ 2020-07-15  7:43 ` Daniel Lezcano
  2020-07-17 17:34   ` David Miller
       [not found] ` <CGME20200717211704eucas1p2192d6f38ba11691eff214a84cd3d4489@eucas1p2.samsung.com>
  2020-07-20  5:35 ` Amit Kucheria
  2 siblings, 1 reply; 6+ messages in thread
From: Daniel Lezcano @ 2020-07-15  7:43 UTC (permalink / raw)
  To: davem
  Cc: Jakub Kicinski, Jiri Pirko, Cong Wang, Johannes Berg,
	Michal Kubecek, open list:NETWORKING [GENERAL],
	open list


Hi Dave,

if you agree with this change, is it possible I merge it through the
thermal tree in order to fix the issue ?

Thanks

  -- Daniel


On 15/07/2020 09:41, Daniel Lezcano wrote:
> The generic netlink is initialized far after the netlink protocol
> itself at subsys_initcall. The devlink is initialized at the same
> level, but after, as shown by a disassembly of the vmlinux:
> 
> [ ... ]
> 374 ffff8000115f22c0 <__initcall_devlink_init4>:
> 375 ffff8000115f22c4 <__initcall_genl_init4>:
> [ ... ]
> 
> The function devlink_init() calls genl_register_family() before the
> generic netlink subsystem is initialized.
> 
> As the generic netlink initcall level is set since 2005, it seems that
> was not a problem, but now we have the thermal framework initialized
> at the core_initcall level which creates the generic netlink family
> and sends a notification which leads to a subtle memory corruption
> only detectable when the CONFIG_INIT_ON_ALLOC_DEFAULT_ON option is set
> with the earlycon at init time.
> 
> The thermal framework needs to be initialized early in order to begin
> the mitigation as soon as possible. Moving it to postcore_initcall is
> acceptable.
> 
> This patch changes the initialization level for the generic netlink
> family to the core_initcall and comes after the netlink protocol
> initialization.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
>  net/netlink/genetlink.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
> index 55ee680e9db1..36b8a1909826 100644
> --- a/net/netlink/genetlink.c
> +++ b/net/netlink/genetlink.c
> @@ -1263,7 +1263,7 @@ static int __init genl_init(void)
>  	panic("GENL: Cannot register controller: %d\n", err);
>  }
>  
> -subsys_initcall(genl_init);
> +core_initcall(genl_init);
>  
>  static int genlmsg_mcast(struct sk_buff *skb, u32 portid, unsigned long group,
>  			 gfp_t flags)
> 


-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

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

* Re: [PATCH] net: genetlink: Move initialization to core_initcall
  2020-07-15  7:43 ` Daniel Lezcano
@ 2020-07-17 17:34   ` David Miller
  2020-07-17 17:48     ` Daniel Lezcano
  0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2020-07-17 17:34 UTC (permalink / raw)
  To: daniel.lezcano
  Cc: kuba, jiri, xiyou.wangcong, johannes.berg, mkubecek, netdev,
	linux-kernel

From: Daniel Lezcano <daniel.lezcano@linaro.org>
Date: Wed, 15 Jul 2020 09:43:00 +0200

> if you agree with this change, is it possible I merge it through the
> thermal tree in order to fix the issue ?

No problem:

Acked-by: David S. Miller <davem@davemloft.net>

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

* Re: [PATCH] net: genetlink: Move initialization to core_initcall
  2020-07-17 17:34   ` David Miller
@ 2020-07-17 17:48     ` Daniel Lezcano
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Lezcano @ 2020-07-17 17:48 UTC (permalink / raw)
  To: David Miller
  Cc: kuba, jiri, xiyou.wangcong, johannes.berg, mkubecek, netdev,
	linux-kernel

On 17/07/2020 19:34, David Miller wrote:
> From: Daniel Lezcano <daniel.lezcano@linaro.org>
> Date: Wed, 15 Jul 2020 09:43:00 +0200
> 
>> if you agree with this change, is it possible I merge it through the
>> thermal tree in order to fix the issue ?
> 
> No problem:
> 
> Acked-by: David S. Miller <davem@davemloft.net>

Thanks!


-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

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

* Re: [PATCH] net: genetlink: Move initialization to core_initcall
       [not found] ` <CGME20200717211704eucas1p2192d6f38ba11691eff214a84cd3d4489@eucas1p2.samsung.com>
@ 2020-07-17 21:17   ` Marek Szyprowski
  0 siblings, 0 replies; 6+ messages in thread
From: Marek Szyprowski @ 2020-07-17 21:17 UTC (permalink / raw)
  To: Daniel Lezcano, davem
  Cc: Jakub Kicinski, Jiri Pirko, Cong Wang, Johannes Berg,
	Michal Kubecek, open list:NETWORKING [GENERAL],
	open list

Hi

On 15.07.2020 09:41, Daniel Lezcano wrote:
> The generic netlink is initialized far after the netlink protocol
> itself at subsys_initcall. The devlink is initialized at the same
> level, but after, as shown by a disassembly of the vmlinux:
>
> [ ... ]
> 374 ffff8000115f22c0 <__initcall_devlink_init4>:
> 375 ffff8000115f22c4 <__initcall_genl_init4>:
> [ ... ]
>
> The function devlink_init() calls genl_register_family() before the
> generic netlink subsystem is initialized.
>
> As the generic netlink initcall level is set since 2005, it seems that
> was not a problem, but now we have the thermal framework initialized
> at the core_initcall level which creates the generic netlink family
> and sends a notification which leads to a subtle memory corruption
> only detectable when the CONFIG_INIT_ON_ALLOC_DEFAULT_ON option is set
> with the earlycon at init time.
>
> The thermal framework needs to be initialized early in order to begin
> the mitigation as soon as possible. Moving it to postcore_initcall is
> acceptable.
>
> This patch changes the initialization level for the generic netlink
> family to the core_initcall and comes after the netlink protocol
> initialization.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

I confirm, that this change together with the thermal subsystem initcall 
change fixes the issue observed in linux-next for the last few days.

Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>

> ---
>   net/netlink/genetlink.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
> index 55ee680e9db1..36b8a1909826 100644
> --- a/net/netlink/genetlink.c
> +++ b/net/netlink/genetlink.c
> @@ -1263,7 +1263,7 @@ static int __init genl_init(void)
>   	panic("GENL: Cannot register controller: %d\n", err);
>   }
>   
> -subsys_initcall(genl_init);
> +core_initcall(genl_init);
>   
>   static int genlmsg_mcast(struct sk_buff *skb, u32 portid, unsigned long group,
>   			 gfp_t flags)

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


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

* Re: [PATCH] net: genetlink: Move initialization to core_initcall
  2020-07-15  7:41 [PATCH] net: genetlink: Move initialization to core_initcall Daniel Lezcano
  2020-07-15  7:43 ` Daniel Lezcano
       [not found] ` <CGME20200717211704eucas1p2192d6f38ba11691eff214a84cd3d4489@eucas1p2.samsung.com>
@ 2020-07-20  5:35 ` Amit Kucheria
  2 siblings, 0 replies; 6+ messages in thread
From: Amit Kucheria @ 2020-07-20  5:35 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: David S. Miller, Jakub Kicinski, Jiri Pirko, Cong Wang,
	Johannes Berg, Michal Kubecek, open list:NETWORKING [GENERAL],
	open list

On Wed, Jul 15, 2020 at 1:11 PM Daniel Lezcano
<daniel.lezcano@linaro.org> wrote:
>
> The generic netlink is initialized far after the netlink protocol
> itself at subsys_initcall. The devlink is initialized at the same
> level, but after, as shown by a disassembly of the vmlinux:
>
> [ ... ]
> 374 ffff8000115f22c0 <__initcall_devlink_init4>:
> 375 ffff8000115f22c4 <__initcall_genl_init4>:
> [ ... ]
>
> The function devlink_init() calls genl_register_family() before the
> generic netlink subsystem is initialized.
>
> As the generic netlink initcall level is set since 2005, it seems that
> was not a problem, but now we have the thermal framework initialized
> at the core_initcall level which creates the generic netlink family
> and sends a notification which leads to a subtle memory corruption
> only detectable when the CONFIG_INIT_ON_ALLOC_DEFAULT_ON option is set
> with the earlycon at init time.
>
> The thermal framework needs to be initialized early in order to begin
> the mitigation as soon as possible. Moving it to postcore_initcall is
> acceptable.
>
> This patch changes the initialization level for the generic netlink
> family to the core_initcall and comes after the netlink protocol
> initialization.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>


> ---
>  net/netlink/genetlink.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
> index 55ee680e9db1..36b8a1909826 100644
> --- a/net/netlink/genetlink.c
> +++ b/net/netlink/genetlink.c
> @@ -1263,7 +1263,7 @@ static int __init genl_init(void)
>         panic("GENL: Cannot register controller: %d\n", err);
>  }
>
> -subsys_initcall(genl_init);
> +core_initcall(genl_init);
>
>  static int genlmsg_mcast(struct sk_buff *skb, u32 portid, unsigned long group,
>                          gfp_t flags)
> --
> 2.17.1
>

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

end of thread, other threads:[~2020-07-20  5:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-15  7:41 [PATCH] net: genetlink: Move initialization to core_initcall Daniel Lezcano
2020-07-15  7:43 ` Daniel Lezcano
2020-07-17 17:34   ` David Miller
2020-07-17 17:48     ` Daniel Lezcano
     [not found] ` <CGME20200717211704eucas1p2192d6f38ba11691eff214a84cd3d4489@eucas1p2.samsung.com>
2020-07-17 21:17   ` Marek Szyprowski
2020-07-20  5:35 ` Amit Kucheria

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).