From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de> To: Masahiro Yamada <masahiroy@kernel.org> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>, Arnd Bergmann <arnd@arndb.de>, linux-kbuild@vger.kernel.org, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, coresight@lists.linaro.org, Suzuki K Poulose <suzuki.poulose@arm.com>, Nick Desaulniers <ndesaulniers@google.com>, linux-kernel@vger.kernel.org, Nathan Chancellor <nathan@kernel.org>, James Clark <james.clark@arm.com>, kernel@pengutronix.de, Leo Yan <leo.yan@linaro.org>, Nicolas Schier <nicolas@fjasle.eu>, linux-arm-kernel@lists.infradead.org, Mike Leach <mike.leach@linaro.org> Subject: [PATCH v2] modpost: Don't let "driver"s reference .exit.* Date: Sat, 30 Sep 2023 18:52:04 +0200 [thread overview] Message-ID: <20230930165204.2478282-1-u.kleine-koenig@pengutronix.de> (raw) 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
WARNING: multiple messages have this Message-ID (diff)
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de> To: Masahiro Yamada <masahiroy@kernel.org> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>, Arnd Bergmann <arnd@arndb.de>, linux-kbuild@vger.kernel.org, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, coresight@lists.linaro.org, Suzuki K Poulose <suzuki.poulose@arm.com>, Nick Desaulniers <ndesaulniers@google.com>, linux-kernel@vger.kernel.org, Nathan Chancellor <nathan@kernel.org>, James Clark <james.clark@arm.com>, kernel@pengutronix.de, Leo Yan <leo.yan@linaro.org>, Nicolas Schier <nicolas@fjasle.eu>, linux-arm-kernel@lists.infradead.org, Mike Leach <mike.leach@linaro.org> Subject: [PATCH v2] modpost: Don't let "driver"s reference .exit.* Date: Sat, 30 Sep 2023 18:52:04 +0200 [thread overview] Message-ID: <20230930165204.2478282-1-u.kleine-koenig@pengutronix.de> (raw) 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
next reply other threads:[~2023-09-30 16:52 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-09-30 16:52 Uwe Kleine-König [this message] 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:33 ` Masahiro Yamada 2023-09-30 20:48 ` Uwe Kleine-König 2023-09-30 20:48 ` Uwe Kleine-König
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230930165204.2478282-1-u.kleine-koenig@pengutronix.de \ --to=u.kleine-koenig@pengutronix.de \ --cc=alexander.shishkin@linux.intel.com \ --cc=arnd@arndb.de \ --cc=coresight@lists.linaro.org \ --cc=gregkh@linuxfoundation.org \ --cc=james.clark@arm.com \ --cc=kernel@pengutronix.de \ --cc=leo.yan@linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kbuild@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=masahiroy@kernel.org \ --cc=mathieu.poirier@linaro.org \ --cc=mike.leach@linaro.org \ --cc=nathan@kernel.org \ --cc=ndesaulniers@google.com \ --cc=nicolas@fjasle.eu \ --cc=suzuki.poulose@arm.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.