Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3295002rwa; Tue, 23 Aug 2022 02:10:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR7FHwP1dFcstHXZv3BZs7NwAjruXFfdcEF1KdZrNZiaLdPU7aZWlhltitdFwKPC/Xa9YQrq X-Received: by 2002:a17:907:1689:b0:73d:9b1a:3507 with SMTP id hc9-20020a170907168900b0073d9b1a3507mr1774398ejc.319.1661245834235; Tue, 23 Aug 2022 02:10:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661245834; cv=none; d=google.com; s=arc-20160816; b=plGRRfwW94VegOomsd9WK0XUmLw9nwCoPMorXZRmABphHXGMETOuysz4BkpnmDJNAo PNjIT6Mz3vH/Y795SORxj/+7BPLPSGFMkJJ6/WjOanXSLrt0s7/v9q9UOMq2q6i+Rew9 wDYghSb2+Kd8HHpa19lrsuWVzHq0ipaFwdzD0U/TkR2ENtkYImBVJM1wv3V+ggOexe4V RWTFbWpR/veQ4zApu+m3u57Ca2vnFolb8XMOeFFzBD42+mML4N9bzfPnzqeYuFGR0u4n KmU7cDcXkUHpcFdx31zX2CDSeLAWg7gwQZY6OL1bfvsAmsdaHNxETIXtsgoM167UExut R/+Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=e3fZvJM2Rkt0AyXr+M/OuFzCtMHBm8daxhBsuiMf0s0=; b=q/REPNn7Xf6gdZuAOJoKCEDb5JM48v/FoXSh0qwbvG+FfSyswptFBqcw1bV8SZp4dB Cj5IFefIqA6dzMKv+59v++2zMFsz0w//2ixau8wnz8CtJNTdwesqqcvuh9fdDB0qq5kJ N8lHcX34zxTMOzSbldSdjvKMBtIDiT7zSRlXOjCWjh8/R/SZiHhUzzbCF5/qiur1eETk IK79PPpOnIuQ+wJPzbG3qsRoq45JxdTI4r1duM0qg6lCE2MJV69JVy7prmYhtNO/jOJG 2X2pcGLDSBGJu8OzPkHWR3zaCOQGkplB4p/J9WP2xKbTAPF9YlssQTlPAtRET6TkjyQd 2Q7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cLY15dk6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gv13-20020a1709072bcd00b007316ac034c1si10189985ejc.496.2022.08.23.02.10.02; Tue, 23 Aug 2022 02:10:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cLY15dk6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240994AbiHWJGB (ORCPT + 99 others); Tue, 23 Aug 2022 05:06:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242352AbiHWJEo (ORCPT ); Tue, 23 Aug 2022 05:04:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D959D83F2E; Tue, 23 Aug 2022 01:29:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 24FAD61360; Tue, 23 Aug 2022 08:28:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DA51C433C1; Tue, 23 Aug 2022 08:28:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243288; bh=8Jm9YYqLw/pElrVNBlgxZpV/Wi6IBZMDszQgvh2y7wA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cLY15dk6CmQSeOdKgvaQDLe2D296n7xHFbuvrXWz+zV7J/pOpy8Gf+cugtvPhDaul 4NFH/DeN7Iiwzt7t2ozzpX1dAAIlHv/an6qdC/DK/jjyHfIcZpmxVhGQ3HZZrg3V/A BUzOeSNGhpno9b9ohMzZmR9S50r6QgqaTaOBSzEw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, matoro , Masahiro Yamada Subject: [PATCH 5.19 228/365] modpost: fix module versioning when a symbol lacks valid CRC Date: Tue, 23 Aug 2022 10:02:09 +0200 Message-Id: <20220823080127.738695343@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masahiro Yamada commit 5b8a9a8fd1f0c3d55d407cf759d54ca68798d9ad upstream. Since commit 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS"), module versioning is broken on some architectures. Loading a module fails with "disagrees about version of symbol module_layout". On such architectures (e.g. ARCH=sparc build with sparc64_defconfig), modpost shows a warning, like follows: WARNING: modpost: EXPORT symbol "_mcount" [vmlinux] version generation failed, symbol will not be versioned. Is "_mcount" prototyped in ? Previously, it was a harmless warning (CRC check was just skipped), but now wrong CRCs are used for comparison because invalid CRCs are just skipped. $ sparc64-linux-gnu-nm -n vmlinux [snip] 0000000000c2cea0 r __ksymtab__kstrtol 0000000000c2ceb8 r __ksymtab__kstrtoul 0000000000c2ced0 r __ksymtab__local_bh_enable 0000000000c2cee8 r __ksymtab__mcount 0000000000c2cf00 r __ksymtab__printk 0000000000c2cf18 r __ksymtab__raw_read_lock 0000000000c2cf30 r __ksymtab__raw_read_lock_bh [snip] 0000000000c53b34 D __crc__kstrtol 0000000000c53b38 D __crc__kstrtoul 0000000000c53b3c D __crc__local_bh_enable 0000000000c53b40 D __crc__printk 0000000000c53b44 D __crc__raw_read_lock 0000000000c53b48 D __crc__raw_read_lock_bh Please notice __crc__mcount is missing here. When the module subsystem looks up a CRC that comes after, it results in reading out a wrong address. For example, when __crc__printk is needed, the module subsystem reads 0xc53b44 instead of 0xc53b40. All CRC entries must be output for correct index accessing. Invalid CRCs will be unused, but are needed to keep the one-to-one mapping between __ksymtab_* and __crc_*. The best is to fix all modpost warnings, but several warnings are still remaining on less popular architectures. Fixes: 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS") Reported-by: matoro Signed-off-by: Masahiro Yamada Tested-by: matoro Signed-off-by: Greg Kroah-Hartman --- scripts/mod/modpost.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2203,13 +2203,11 @@ static void add_exported_symbols(struct /* record CRCs for exported symbols */ buf_printf(buf, "\n"); list_for_each_entry(sym, &mod->exported_symbols, list) { - if (!sym->crc_valid) { + if (!sym->crc_valid) warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n" "Is \"%s\" prototyped in ?\n", sym->name, mod->name, mod->is_vmlinux ? "" : ".ko", sym->name); - continue; - } buf_printf(buf, "SYMBOL_CRC(%s, 0x%08x, \"%s\");\n", sym->name, sym->crc, sym->is_gpl_only ? "_gpl" : "");