Message ID | 20230930165204.2478282-1-u.kleine-koenig@pengutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp486729vqb; Sat, 30 Sep 2023 09:52:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1hXGaknWAwwmf0xBqCfzY2yLjgzbk9qo1YXvLd1/ubUuLG4lSkxalFVBczMC02ec4rE6/ X-Received: by 2002:a92:ca45:0:b0:34d:ec9c:7321 with SMTP id q5-20020a92ca45000000b0034dec9c7321mr8936403ilo.3.1696092766107; Sat, 30 Sep 2023 09:52:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696092766; cv=none; d=google.com; s=arc-20160816; b=qIlO2O90vgirLKi210ivwwuUOhngnVcqzdlk8yMzDwn11KHT9ByP2vQUOaoPXy/wpA 71MrCdX34ybCJeSgAeRDzCJZsb5NGc4FBbtU5o1+UO4E4u9MLwA5eD7fM3mh5bWAzl0s Ykun5BjiGttCohLYSk5ojboWQe9ELbNrV7Ei48FqezCokAPgOcEm+CTKIH1lpVznigSO IjLhwrynVAab7sbHwyjfB8z0tcDMENsmuNHvplVx9Vt+d2xXu4YOuN1YvuyJFO9CrWMP ToIIL68+ftimyiEsq6G1DHRy2/HMigUGWnFseLGmXStdMgv4+k0ON+P2UDTvGosJs4Lu uIUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=LnSfQiFOMxxO+kEpDVpAG9H9/4c7R1Pb0ukWbUCDjsQ=; fh=jiqWx6oaKT5TyMYUZGVw9q2PqZlKWiqxOk4EKOg2Ns4=; b=hvdtqM8PuEwHy673hyPZPRTbSFzV20CSubzp6zHP1BSYyUNHbuq31Hgfu5zNHOdaJn XeI4B5SryYPT6dMhronnQGFhlLSMu9cmlOstVlmxk1j2R6hyC/75EpXOaFC2p8iZiQWQ 17YpdY7KJQKVZMaqMHzWvQyXLQcNt9EhCF9JGb17SZxRNepet9CLZR/IevXuvq+/fOMz 5LDv3H72aOHrmyq7ezEOdpukLtKtuQXyfE2xoV8kJ7j7tx1Eaa2UbqCKauJP0d4j/49u jx585Qkwo+OGOvQiKuYWSGLK53QvbVQn2QqtsFOC4qn8MC+HW7jjrCQuHozZYEkZF5PQ kq/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id e4-20020a635444000000b005774c90073asi22948198pgm.320.2023.09.30.09.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Sep 2023 09:52:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id A45778025452; Sat, 30 Sep 2023 09:52:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234573AbjI3QwY (ORCPT <rfc822;chrisfriedt@gmail.com> + 20 others); Sat, 30 Sep 2023 12:52:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229788AbjI3QwX (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 30 Sep 2023 12:52:23 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12014C6 for <linux-kernel@vger.kernel.org>; Sat, 30 Sep 2023 09:52:22 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <ukl@pengutronix.de>) id 1qmdCQ-00083K-Ew; Sat, 30 Sep 2023 18:52:14 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from <ukl@pengutronix.de>) id 1qmdCN-00A5ig-54; Sat, 30 Sep 2023 18:52:11 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from <ukl@pengutronix.de>) id 1qmdCM-006YZS-RT; Sat, 30 Sep 2023 18:52:10 +0200 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= <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 Message-Id: <20230930165204.2478282-1-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Developer-Signature: v=1; a=openpgp-sha256; l=2253; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=ExAgENbFDy79YPL9zwkhUwd58OR3hIj9/ep56FwARBs=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlGFIw1iaUvqRkXmdHEuuytknWrwe98MGZS0mOe bymTwqIL/yJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZRhSMAAKCRCPgPtYfRL+ Tv2wB/9TZ6zWLaUiIJNkMCcwv2THuCRjyXxDTrBVdfE1pAaQc617coqXgFNc7JgziISZgwDoeQn 0N0zbxBSZ4GXFF6OfcZjqkucea+mDp0ik+Sbg27CFFJ+Pyi5pHvL5i6dVVL6vN1InUzbb0H1st8 dklibia6QN0FCthvN90MIxGzMrOhC9U8gpr5PZmCxEVRAoaSGQXKVS7gM4WCEkdiIkGERLVB2IL IR8Uqxa6jU1N8yGa7W51ySmyi3jyEsy2PhKcePHHw2kaR+xNNht1mvi1ynAgo+jh2o9kohc+ruD dYXXkixPCno0nGA21I1gAeRFGZGhuzvqIGzcCtj2GGKLyFJL X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sat, 30 Sep 2023 09:52:42 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778471851735088966 X-GMAIL-MSGID: 1778482168077349238 |
Series |
[v2] modpost: Don't let "driver"s reference .exit.*
|
|
Commit Message
Uwe Kleine-König
Sept. 30, 2023, 4:52 p.m. UTC
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(-)
base-commit: 6465e260f48790807eef06b583b38ca9789b6072
Comments
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
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
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;