From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.kernel.org ([198.145.29.99]:43740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727799AbgCZXYR (ORCPT ); Thu, 26 Mar 2020 19:24:17 -0400 From: Sasha Levin Subject: [PATCH AUTOSEL 5.5 16/28] modpost: Get proper section index by get_secindex() instead of st_shndx Date: Thu, 26 Mar 2020 19:23:45 -0400 Message-Id: <20200326232357.7516-16-sashal@kernel.org> In-Reply-To: <20200326232357.7516-1-sashal@kernel.org> References: <20200326232357.7516-1-sashal@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kbuild-owner@vger.kernel.org List-ID: To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Xiao Yang , Masahiro Yamada , Sasha Levin , linux-kbuild@vger.kernel.org From: Xiao Yang [ Upstream commit 4b8a5cfb5fd375cf4c7502a18f0096ed2881be27 ] (uint16_t) st_shndx is limited to 65535(i.e. SHN_XINDEX) so sym_get_data() gets wrong section index by st_shndx if requested symbol contains extended section index that is more than 65535. 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. Fixes: 56067812d5b0 ("kbuild: modversions: add infrastructure for emitting relative CRCs") Fixes: e84f9fbbece1 ("modpost: refactor namespace_from_kstrtabns() to not hard-code section name") Signed-off-by: Xiao Yang Signed-off-by: Masahiro Yamada Signed-off-by: Sasha Levin --- 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 6e892c93d104a..90aaf29c61a0f 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -307,7 +307,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; -- 2.20.1