From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42645C43331 for ; Tue, 24 Mar 2020 13:27:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1B0F6208D6 for ; Tue, 24 Mar 2020 13:27:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585056421; bh=sV/7tZu+9jzAgfabfiSVc15CYjE0b5LlMjqpkrHWOS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=qP0MnKdQ1ObJ4Zo2zUJwE6ObJePO63sr0aNjyKs/MRKX8bDyHg/cdm7mkArNba1hN RdJ7CSDoMtnwSXQx96wPcyr7dC4s7I7acSjbQq18x78Ne7gJ0JRpPQFiegMJ9sCibf RJ7TcR6BVtGGlWhLkHKzBirjG2jpZ4JUaXApBYDY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727674AbgCXN07 (ORCPT ); Tue, 24 Mar 2020 09:26:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:52268 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729754AbgCXN06 (ORCPT ); Tue, 24 Mar 2020 09:26:58 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4808C20B80; Tue, 24 Mar 2020 13:26:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585056417; bh=sV/7tZu+9jzAgfabfiSVc15CYjE0b5LlMjqpkrHWOS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bAzj3TnHl7JAkJ3ccN7Rd0+fzi4p4Hqlw5x/sy5kja0CWcd3lEa+fC5CWoPAlK0Ik hcoXViAWQEaIPKdhMi02wS+gt8fRe2CPN9asCScl41zJnkUBFurhxnWIThglt2NpvK Wq8ei+sqH7zkmhW3+yxRuRYi23GamicsH9YGdxTo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiao Yang , Masahiro Yamada Subject: [PATCH 5.5 110/119] modpost: Get proper section index by get_secindex() instead of st_shndx Date: Tue, 24 Mar 2020 14:11:35 +0100 Message-Id: <20200324130818.764177274@linuxfoundation.org> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200324130808.041360967@linuxfoundation.org> References: <20200324130808.041360967@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Xiao Yang commit 4b8a5cfb5fd375cf4c7502a18f0096ed2881be27 upstream. (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: Greg Kroah-Hartman --- scripts/mod/modpost.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -307,7 +307,8 @@ static const char *sec_name(struct elf_i 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;