net: genetlink: Move initialization to core_initcall
authorDaniel Lezcano <daniel.lezcano@linaro.org>
Wed, 15 Jul 2020 07:41:18 +0000 (09:41 +0200)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Tue, 21 Jul 2020 08:40:08 +0000 (10:40 +0200)
commitc62e7ac395641a764639b1c6635955f02b8d9d16
tree435b1188244d08afd0846b38c8ee473b8a8896e5
parent947d85f00c030aa88eef0c065b6f4636547257d7
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.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: David S. Miller <davem@davemloft.net>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Amit Kucheria <amit.kucheria@linaro.org>
Link: https://lore.kernel.org/r/20200715074120.8768-1-daniel.lezcano@linaro.org
net/netlink/genetlink.c