Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp458859ybh; Wed, 18 Mar 2020 03:10:42 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs6wbY6vIikvISoCem/nEofXsT6B1gfzD8DAAiPsde5cm6qd7bOIM1NAbWG5ZKizxUYgFbo X-Received: by 2002:aca:b9d6:: with SMTP id j205mr2572496oif.179.1584526241888; Wed, 18 Mar 2020 03:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584526241; cv=none; d=google.com; s=arc-20160816; b=vtGG9IoSfIOA7p/Z/s6AAbG8U/BhAj5o4AlxpBRx197/t+MlgB8niVrDsXgEQLNI7Z 4N2iVzijlWCcK+lY9n72SCbj6rOLjPAzKu+b8eqV02iA+3GsySkkJIdGDJPB0x2yxJXw ja0xSRN2ZWsfIlM3hHg/0ksaRxdHQ5hohDAr3AYHJKC4vzbFBMT9p3APH/C2ICZqd8D1 uBE/RvfJcbBwiRYDH0rcV2RzXN/xTW9b3akqC6QuYhxiGMS7u/aoAGEllOKiIfAbUVGy qjxf38AY2RjSqHRIUKFMtO8aWMk5QNbW9aGdpH3U1gvYuqktvJDMlbVc3+QCxhKkAP8i 6zJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :references:subject:cc:to:mime-version:user-agent:from:date :message-id; bh=hRWEmm9/WxVfizG4Pdz4qYzjoM9Wv/gz1Pu0uNqN/HE=; b=zX4FszTPquic1NeyHgmYdJw/Z3Wa1KOgeLdPIJTcQE3u/zljbSN9gdFkLQGrouYOcR s35XfZnF4/hMg2SGfi1wHZerSgv1JWZ/qfMx0CJwaxCeQABI47UZPDnxOWE71I22T85C I4fXA4Ec8FOG9o0EPFxiUS0SG3EapAd0X42HocuJmj/Q5X2NSghsRQHs6hb6nB24LEWf 6Vipg+yr3wymuihdSEyRSm0APSckGPJQzX4hSeMshOeXAWFnR4ymgA4KNoMNtNCQhpUv igqTaGkH3RvYPORq/xA/w6oOXvCCpWTy72ZKLhafxqi6Qq7BL50zaYmshUUGjQylWWJt VT+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 65si3441580oif.14.2020.03.18.03.10.28; Wed, 18 Mar 2020 03:10:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727441AbgCRKI5 (ORCPT + 99 others); Wed, 18 Mar 2020 06:08:57 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:50399 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726310AbgCRKI4 (ORCPT ); Wed, 18 Mar 2020 06:08:56 -0400 X-IronPort-AV: E=Sophos;i="5.70,566,1574092800"; d="scan'208";a="86537415" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 18 Mar 2020 18:08:49 +0800 Received: from G08CNEXMBPEKD06.g08.fujitsu.local (unknown [10.167.33.206]) by cn.fujitsu.com (Postfix) with ESMTP id 78DDB49DF12A; Wed, 18 Mar 2020 17:58:45 +0800 (CST) Received: from [10.167.220.69] (10.167.220.69) by G08CNEXMBPEKD06.g08.fujitsu.local (10.167.33.206) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 18 Mar 2020 18:08:49 +0800 Message-ID: <5E71F32E.20300@cn.fujitsu.com> Date: Wed, 18 Mar 2020 18:08:46 +0800 From: Xiao Yang User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.2; zh-CN; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 MIME-Version: 1.0 To: Masahiro Yamada CC: Michal Marek , Linux Kbuild mailing list , Linux Kernel Mailing List Subject: Re: [PATCH] modpost: Get proper section index by get_secindex() instead of st_shndx References: <20200316122820.11032-1-yangx.jy@cn.fujitsu.com> <5E702236.8070109@cn.fujitsu.com> In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.167.220.69] X-ClientProxiedBy: G08CNEXCHPEKD05.g08.fujitsu.local (10.167.33.203) To G08CNEXMBPEKD06.g08.fujitsu.local (10.167.33.206) X-yoursite-MailScanner-ID: 78DDB49DF12A.AD4C3 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: yangx.jy@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/3/18 17:49, Masahiro Yamada wrote: > On Tue, Mar 17, 2020 at 10:05 AM Xiao Yang wrote: >> >> On 2020/3/16 20:28, Xiao Yang wrote: > > Thanks for catching this bug. > > >>> (uint16_t) st_shndx is limited to 65535(i.e. SHN_XINDEX) so sym_get_data() gets >>> wrong section index by st_shndx if object file(e.g. vmlinux.o) has more than >> Hi, >> >> It seems better to say that sym_get_data() gets wrong section index by >> st_shndx if requested symbol contains extended section index that is >> more than 65535. > > > Sounds good to me. > > >> Thanks, >> Xiao Yang >>> 65535 sessions. In this case, we need to get proper section index by .symtab_shndx >>> section. >>> >>> Module.symvers generated by building kernel with "-ffunction-sections -fdata-sections" >>> shows the issue(i.e. cannot get 89902 by st_shndx): >>> ------------------------------------------------------------------- >>> [root@Fedora-30 linux]# file Module.symvers >>> Module.symvers: data >>> [root@Fedora-30 linux]# head -n1 Module.symvers >>> 0x5caf3011 ipv6_chk_custom_prefix ▒▒▒▒▒▒▒▒ vmlinux EXPORT_SYMBOL > > > Could you delete this dump? > I'd like to avoid garbling where possible. > Hi Masahiro, Sure, it is OK to delete it. > >>> ... >>> [root@Fedora-30 linux]# readelf -s -W vmlinux.o | grep __kstrtabns_ipv6_chk_custom_prefix >>> 199174: 0000000000032578 1 OBJECT LOCAL DEFAULT 89902 __kstrtabns_ipv6_chk_custom_prefix >>> [root@Fedora-30 linux]# readelf -S -W vmlinux.o | grep 89902 >>> [89902] __ksymtab_strings PROGBITS 0000000000000000 a94e00 0345a2 00 A 0 0 1 >>> ------------------------------------------------------------------- >>> >>> Fixes: afa0459daa7b ("modpost: add a helper to get data pointed by a symbol") > > Strictly speaking, this commit does not introduce any bug. > > The CRC bug for MODVERSIONS exists since > 56067812d5b0 ("kbuild: modversions: add infrastructure for emitting > relative CRCs") > Will replace it with your suggested commit. > >>> Fixes: 5545322c86d9 ("modpost: refactor namespace_from_kstrtabns() to not hard-code section name") > > This commit hash is wrong. > The correct one is > > Fixes: e84f9fbbece1 ("modpost: refactor namespace_from_kstrtabns() to > not hard-code section name") > > Sorry for the wrong commit hash. Thanks a lot for your quick review. I will send v2 patch soon. Best Regards, Xiao Yang > > > >>> Signed-off-by: Xiao Yang >>> --- >>> scripts/mod/modpost.c | 3 ++- >>> 1 file changed, 2 insertions(+), 1 deletion(-) >>> >>> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c >>> index d9418c58a8c0..c1fec8cac257 100644 >>> --- a/scripts/mod/modpost.c >>> +++ b/scripts/mod/modpost.c >>> @@ -310,7 +310,8 @@ static const char *sec_name(struct elf_info *elf, int secindex) >>> >>> static void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym) >>> { >>> - Elf_Shdr *sechdr =&info->sechdrs[sym->st_shndx]; >>> + unsigned int secindex = get_secindex(info, sym); >>> + Elf_Shdr *sechdr =&info->sechdrs[secindex]; >>> unsigned long offset; >>> >>> offset = sym->st_value; >> >> >> > > > -- > Best Regards > Masahiro Yamada > > > . >