Re: [PATCH 5.4 57/60] modpost: fix section mismatch check for exported init/exit sections

From: Florian Fainelli
Date: Mon Jun 27 2022 - 13:03:13 EST


On 6/27/22 04:22, Greg Kroah-Hartman wrote:
From: Masahiro Yamada <masahiroy@xxxxxxxxxx>

commit 28438794aba47a27e922857d27b31b74e8559143 upstream.

Since commit f02e8a6596b7 ("module: Sort exported symbols"),
EXPORT_SYMBOL* is placed in the individual section ___ksymtab(_gpl)+<sym>
(3 leading underscores instead of 2).

Since then, modpost cannot detect the bad combination of EXPORT_SYMBOL
and __init/__exit.

Fix the .fromsec field.

Fixes: f02e8a6596b7 ("module: Sort exported symbols")
Signed-off-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
Reviewed-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

This commit causes the following warning to show up on my kernel builds used for testing 5.4 stable candidates:

WARNING: vmlinux.o(___ksymtab+drm_fb_helper_modinit+0x0): Section mismatch in reference from the variable __ksymtab_drm_fb_helper_modinit to the function .init.text:drm_fb_helper_modinit()
The symbol drm_fb_helper_modinit is exported and annotated __init
Fix this by removing the __init annotation of drm_fb_helper_modinit or drop the export.

The kernel configuration to reproduce this is located here (this is 5.10 but works in 5.4 as well):

https://gist.github.com/2c3e8edd5ceb089c8040db724073d941

Same applies to the 5.10, 5.15 and 5.18 stable queues FWIW.
--
Florian