net: genetlink: Move initialization to core_initcall
Subsystems (2)
PATCH 1/1 net: genetlink: Move initialization to core_initcall
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.
--- net/netlink/genetlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netlink/genetlink.c +1 -1
@@ -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)
Signature · 1 line
2.17.1
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
Quoted 46 lines · Daniel Lezcano
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:[ ... ]
374ffff8000115f22c0<__initcall_devlink_init4>:
375ffff8000115f22c4<__initcall_genl_init4>:
[ ... ]The function
devlink_init()callsgenl_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_initcalllevel which creates the generic netlink family and sends a notification which leads to a subtle memory corruption only detectable when theCONFIG_INIT_ON_ALLOC_DEFAULT_ONoption 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_initcallis acceptable.This patch changes the initialization level for the generic netlink family to the
core_initcalland comes after the netlink protocol initialization.Signed-off-by Daniel Lezcano <[email protected]>--- net/netlink/genetlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/netlink/genetlink.c +1
-1@@ -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)
Signature · 5 lines
<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
From: Daniel Lezcano <[email protected]>
Date: Wed, 15 Jul 2020 09:43:00 +0200
Quoted 2 lines
if you agree with this change, is it possible I merge it through the thermal tree in order to fix the issue ?
No problem:
Quoted 9 lines · David Miller
From: Daniel Lezcano <[email protected]>
Date: Wed, 15 Jul 2020 09:43:00 +0200Quoted 2 lines
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 <[email protected]>
Thanks!
Signature · 5 lines
<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
Hi
Quoted 23 lines · Daniel Lezcano
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:[ ... ]
374ffff8000115f22c0<__initcall_devlink_init4>:
375ffff8000115f22c4<__initcall_genl_init4>:
[ ... ]The function
devlink_init()callsgenl_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_initcalllevel which creates the generic netlink family and sends a notification which leads to a subtle memory corruption only detectable when theCONFIG_INIT_ON_ALLOC_DEFAULT_ONoption 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_initcallis acceptable.
Quoted 5 lines
This patch changes the initialization level for the generic netlink family to the
core_initcalland comes after the netlink protocol initialization.Signed-off-by Daniel Lezcano <[email protected]>
I confirm, that this change together with the thermal subsystem initcall change fixes the issue observed in linux-next for the last few days.
Quoted 9 lines
--- net/netlink/genetlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/netlink/genetlink.c +0
-0
net/netlink/genetlink.c static int __init genl_init(void) · line 1269
Quoted 8 lines
net/netlink/genetlink.c +1
-1@@ -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
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
Quoted 24 lines · Daniel Lezcano
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:[ ... ]
374ffff8000115f22c0<__initcall_devlink_init4>:
375ffff8000115f22c4<__initcall_genl_init4>:
[ ... ]The function
devlink_init()callsgenl_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_initcalllevel which creates the generic netlink family and sends a notification which leads to a subtle memory corruption only detectable when theCONFIG_INIT_ON_ALLOC_DEFAULT_ONoption 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_initcallis acceptable.
Quoted 5 lines
This patch changes the initialization level for the generic netlink family to the
core_initcalland comes after the netlink protocol initialization.Signed-off-by Daniel Lezcano <[email protected]>
Quoted 20 lines
--- net/netlink/genetlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/netlink/genetlink.c +1
-2@@ -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