* [PATCH v2] modpost: Don't let "driver"s reference .exit.*
@ 2023-09-30 16:52 Uwe Kleine-König
2023-09-30 20:33 ` Masahiro Yamada
0 siblings, 1 reply; 3+ messages in thread
From: Uwe Kleine-König @ 2023-09-30 16:52 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Mathieu Poirier, Arnd Bergmann, linux-kbuild, Alexander Shishkin,
Greg Kroah-Hartman, coresight, Suzuki K Poulose, Nick Desaulniers,
linux-kernel, Nathan Chancellor, James Clark, kernel, Leo Yan,
Nicolas Schier, linux-arm-kernel, Mike Leach
Drivers must not reference functions marked with __exit as these likely
are not available when the code is built-in.
There are few creative offenders uncovered for example in ARCH=amd64
allmodconfig builds. So only trigger the section mismatch warning for
W=1 builds.
The dual rule that drivers must not reference .init.* is implemented
since commit 0db252452378 ("modpost: don't allow *driver to reference
.init.*") which however missed that .exit.* should be handled in the
same way.
Thanks to Masahiro Yamada and Arnd Bergmann who gave valuable hints to
find this improvement.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Hello,
changes since (implicit) v1, sent with Message-Id:
20230930140601.2457711-1-u.kleine-koenig@pengutronix.de:
- enable the warning about .data -> .exit.* only in W=1 builds to keep
normal builds without warnings. *sigh*
- improved commit log and mention the above item.
- updated the code comment to match the code
Thanks
Uwe
scripts/mod/modpost.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index de499dce5265..b3dee80497cb 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1015,9 +1015,20 @@ static int secref_whitelist(const char *fromsec, const char *fromsym,
"*_console")))
return 0;
- /* symbols in data sections that may refer to meminit/exit sections */
+ /* symbols in data sections that may refer to meminit sections */
if (match(fromsec, PATTERNS(DATA_SECTIONS)) &&
- match(tosec, PATTERNS(ALL_XXXINIT_SECTIONS, ALL_EXIT_SECTIONS)) &&
+ match(tosec, PATTERNS(ALL_XXXINIT_SECTIONS, ALL_XXXEXIT_SECTIONS)) &&
+ match(fromsym, PATTERNS("*driver")))
+ return 0;
+
+ /*
+ * symbols in data sections must not refer to .exit.*, but there are
+ * quite a few offenders, so hide these unless for W=1 builds until
+ * these are fixed.
+ */
+ if (!extra_warn &&
+ match(fromsec, PATTERNS(DATA_SECTIONS)) &&
+ match(tosec, PATTERNS(EXIT_SECTIONS)) &&
match(fromsym, PATTERNS("*driver")))
return 0;
base-commit: 6465e260f48790807eef06b583b38ca9789b6072
--
2.40.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] modpost: Don't let "driver"s reference .exit.*
2023-09-30 16:52 [PATCH v2] modpost: Don't let "driver"s reference .exit.* Uwe Kleine-König
@ 2023-09-30 20:33 ` Masahiro Yamada
2023-09-30 20:48 ` Uwe Kleine-König
0 siblings, 1 reply; 3+ messages in thread
From: Masahiro Yamada @ 2023-09-30 20:33 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Mathieu Poirier, Arnd Bergmann, linux-kbuild, Alexander Shishkin,
Greg Kroah-Hartman, coresight, Suzuki K Poulose, Nick Desaulniers,
linux-kernel, Nathan Chancellor, James Clark, kernel, Leo Yan,
Nicolas Schier, linux-arm-kernel, Mike Leach
On Sun, Oct 1, 2023 at 1:52 AM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>
> Drivers must not reference functions marked with __exit as these likely
> are not available when the code is built-in.
>
> There are few creative offenders uncovered for example in ARCH=amd64
> allmodconfig builds. So only trigger the section mismatch warning for
> W=1 builds.
>
> The dual rule that drivers must not reference .init.* is implemented
> since commit 0db252452378 ("modpost: don't allow *driver to reference
> .init.*") which however missed that .exit.* should be handled in the
> same way.
>
> Thanks to Masahiro Yamada and Arnd Bergmann who gave valuable hints to
> find this improvement.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Thanks.
If there is no objection from anybody, I will apply this
to my fixes branch and send a pull request.
Then, I hope you (or somebody) will volunteer to fix broken drivers.
--
Best Regards
Masahiro Yamada
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] modpost: Don't let "driver"s reference .exit.*
2023-09-30 20:33 ` Masahiro Yamada
@ 2023-09-30 20:48 ` Uwe Kleine-König
0 siblings, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2023-09-30 20:48 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Mathieu Poirier, Arnd Bergmann, linux-kbuild, Alexander Shishkin,
Greg Kroah-Hartman, coresight, Suzuki K Poulose, Nick Desaulniers,
linux-kernel, Nathan Chancellor, James Clark, kernel, Leo Yan,
Mike Leach, linux-arm-kernel, Nicolas Schier
[-- Attachment #1.1: Type: text/plain, Size: 456 bytes --]
Hello Masahiro,
On Sun, Oct 01, 2023 at 05:33:54AM +0900, Masahiro Yamada wrote:
> Then, I hope you (or somebody) will volunteer to fix broken drivers.
I already added that to my todo list. However it's otherwise non-empty,
so I won't promise to tackle that quickly.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-30 20:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-30 16:52 [PATCH v2] modpost: Don't let "driver"s reference .exit.* Uwe Kleine-König
2023-09-30 20:33 ` Masahiro Yamada
2023-09-30 20:48 ` Uwe Kleine-König
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).