Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1636730iob; Thu, 5 May 2022 05:38:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdpPmUkU6AD7eydorz8vUOnYyRT/E+uT/VqKdsU7y3anwRHjcb7iitQo5tRQy7TYyRe0rV X-Received: by 2002:a63:dc42:0:b0:3c5:e187:572 with SMTP id f2-20020a63dc42000000b003c5e1870572mr7035133pgj.82.1651754304509; Thu, 05 May 2022 05:38:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651754304; cv=none; d=google.com; s=arc-20160816; b=SpF4Re4/6nc5KEXa8G+xpZngAkjTNhj5bnLvWkr3ClAdR+fQxbRQvV5lQR83VbRb7Z +9WgfKlA654awjYqW70vLZ8oqEbHSUEun1fZ4Nu/6QtZog3pT1JaGFrNTCwxTP5B1gOj klmL/tcakqLxvi1K2pDrtmBn2zxgBkhq/PUgdNmF9CMb2fFCIZYr69reXyUuXCtaBmkT VG4ddlgZd9L67zdPSG+CTV5V5UcFi55pUWDzPtY7Jvz+FSm51L726GoKnfhB35T9cxwo kpoz9NYMoZrtXH0KdigN5ySYmwJDcAtDwin7bPvVWNurjH5bAcxtCpKLG5M95zrpXC22 nFcg== 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=4SVgTsD9LQxxbRsLTapcIhEdCAvZuLY9o/ixMm/dSvk=; b=Ui2Cg5RepHaHdYDtl9U0/F7VCHbIgGhXMi4Owhcy5ClvT8KzGaijVnGgts1m/FCs8T xQ4R0A8SbthHeclsnTK3aN7ZIP0fLUJFi30a9qpnyk3/klwDDcH4vK3EAvVr+QUKIlJo 9cA1caxaQAfmHFJ/hP1AW6+Fn4PNDTlOQey2I2bdjUxiitwTxJQLlKyLH7TvWKbCbMR2 rOaf7KwAy5jJNbTsFw/8XoPqSQiSPsa+4CF+ncJv0I+9ZSz6XKTizKzxwKBuuy5VQkve yYba+46Q20ZoWRum9amt2CQmSN1Wqg+AS3ymt0tBRF+7l3Y1GRAC7Iqn8rSPRjwTXpZR Qv8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mF4yGrzm; 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 d15-20020a170903230f00b0015e8684f37bsi2013676plh.78.2022.05.05.05.38.07; Thu, 05 May 2022 05:38:24 -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=mF4yGrzm; 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 S1357904AbiEDRlF (ORCPT + 99 others); Wed, 4 May 2022 13:41:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356665AbiEDRJh (ORCPT ); Wed, 4 May 2022 13:09:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F32583B9; Wed, 4 May 2022 09:55:19 -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 B040761851; Wed, 4 May 2022 16:55:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04470C385A4; Wed, 4 May 2022 16:55:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683319; bh=M0/axqTGok4fcs8rG0eauRfmKiO8nOsazqCkI5HiV/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mF4yGrzmeZ0g4gnSiKHdByCvwSpO1Tec8uV4LVfBNgNTpqAbjdrpascX5kyjJyjvi 0/moh8u+lCRx3OHcXhSflatH57Ld64sn/xj5w/iEMEm1e/c4cMBrd7z8EM8L0fKsAC 3RgNq1o0Bq9PuD22JLIYyM+EoMSdBepORukLaqdc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , Josh Poimboeuf Subject: [PATCH 5.15 176/177] objtool: Fix type of reloc::addend Date: Wed, 4 May 2022 18:46:09 +0200 Message-Id: <20220504153109.467732856@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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: Peter Zijlstra commit c087c6e7b551b7f208c0b852304f044954cf2bb3 upstream. Elf{32,64}_Rela::r_addend is of type: Elf{32,64}_Sword, that means that our reloc::addend needs to be long or face tuncation issues when we do elf_rebuild_reloc_section(): - 107: 48 b8 00 00 00 00 00 00 00 00 movabs $0x0,%rax 109: R_X86_64_64 level4_kernel_pgt+0x80000067 + 107: 48 b8 00 00 00 00 00 00 00 00 movabs $0x0,%rax 109: R_X86_64_64 level4_kernel_pgt-0x7fffff99 Fixes: 627fce14809b ("objtool: Add ORC unwind table generation") Signed-off-by: Peter Zijlstra (Intel) Acked-by: Josh Poimboeuf Link: https://lkml.kernel.org/r/20220419203807.596871927@infradead.org Signed-off-by: Greg Kroah-Hartman --- tools/objtool/check.c | 8 ++++---- tools/objtool/elf.c | 2 +- tools/objtool/include/objtool/elf.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -393,12 +393,12 @@ static int add_dead_ends(struct objtool_ else if (reloc->addend == reloc->sym->sec->sh.sh_size) { insn = find_last_insn(file, reloc->sym->sec); if (!insn) { - WARN("can't find unreachable insn at %s+0x%x", + WARN("can't find unreachable insn at %s+0x%lx", reloc->sym->sec->name, reloc->addend); return -1; } } else { - WARN("can't find unreachable insn at %s+0x%x", + WARN("can't find unreachable insn at %s+0x%lx", reloc->sym->sec->name, reloc->addend); return -1; } @@ -428,12 +428,12 @@ reachable: else if (reloc->addend == reloc->sym->sec->sh.sh_size) { insn = find_last_insn(file, reloc->sym->sec); if (!insn) { - WARN("can't find reachable insn at %s+0x%x", + WARN("can't find reachable insn at %s+0x%lx", reloc->sym->sec->name, reloc->addend); return -1; } } else { - WARN("can't find reachable insn at %s+0x%x", + WARN("can't find reachable insn at %s+0x%lx", reloc->sym->sec->name, reloc->addend); return -1; } --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -485,7 +485,7 @@ static struct section *elf_create_reloc_ int reltype); int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset, - unsigned int type, struct symbol *sym, int addend) + unsigned int type, struct symbol *sym, long addend) { struct reloc *reloc; --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -69,7 +69,7 @@ struct reloc { struct symbol *sym; unsigned long offset; unsigned int type; - int addend; + long addend; int idx; bool jump_table_start; }; @@ -131,7 +131,7 @@ struct elf *elf_open_read(const char *na struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr); int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset, - unsigned int type, struct symbol *sym, int addend); + unsigned int type, struct symbol *sym, long addend); int elf_add_reloc_to_insn(struct elf *elf, struct section *sec, unsigned long offset, unsigned int type, struct section *insn_sec, unsigned long insn_off);