From patchwork Sat Sep 30 16:52:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 13405170 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9206BE7737A for ; Sat, 30 Sep 2023 16:52:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=TNyIvMX5NKaSdcZllPpt5EiolMDJekECR1S5qe3uBp8=; b=wAjavdsWCi46nd P9RPOdIcnQIhbQ7w202Gqjm7CqlkRUg4/QOL8eAmq0pVN2wcuyPQB97XcwP+kN6tbRfxoNaVWUAsc /n9Xz/s49J8cPTGG+J2W/wUvBafWaCF818livXxcauG/DKO93NN2ADZjbFF8EBBC+oH3DFjQ6IS1b QBDdFIguBELH8OoEIHn9bTrlO//sYLSL55fvIfGJprtWGlRHYpIaYOyGW4xus+wkQDGB6FIU+FRPc b2SHmwgRfyDwQJcHc+8LOTaQq6zbJqDLbqiqx1LWvxLGPWMy6OY6dCglkmyUkkCuVEYfmY4T6/esP vaFUVE+AdkyGFT9s7g1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qmdCi-009rcj-2Y; Sat, 30 Sep 2023 16:52:32 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qmdCf-009rZL-2n for linux-arm-kernel@lists.infradead.org; Sat, 30 Sep 2023 16:52:31 +0000 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 ) 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 ) 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 ) id 1qmdCM-006YZS-RT; Sat, 30 Sep 2023 18:52:10 +0200 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Masahiro Yamada Cc: Mathieu Poirier , Arnd Bergmann , linux-kbuild@vger.kernel.org, Alexander Shishkin , Greg Kroah-Hartman , coresight@lists.linaro.org, Suzuki K Poulose , Nick Desaulniers , linux-kernel@vger.kernel.org, Nathan Chancellor , James Clark , kernel@pengutronix.de, Leo Yan , Nicolas Schier , linux-arm-kernel@lists.infradead.org, Mike Leach 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 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 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-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230930_095229_910611_43D7680C X-CRM114-Status: GOOD ( 17.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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 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;