Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp743396pxb; Mon, 25 Oct 2021 17:57:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+YBqQw+wKZJxox8WvUBQbRJy056cvG12t5XaFtjSR4MgzmtxbmhdxheOaT6rJ7Q7O3PyK X-Received: by 2002:aa7:8209:0:b0:47b:df8c:7ec5 with SMTP id k9-20020aa78209000000b0047bdf8c7ec5mr16854721pfi.7.1635209868838; Mon, 25 Oct 2021 17:57:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635209868; cv=none; d=google.com; s=arc-20160816; b=yCVCRAF00ohK/cSsEWoIBodv30mJh8v0BKA/dqYlOZsHFR6ZBDhFd0zGiFu90a/EI5 avz+jUokAVttW++kefmvCR1voWoy7eIIRoXInfEieHWcL8Q5GBs6p05njHY3fpQuKhRF gMNO6/+qZb3eJZUOVCG8xhoYW7JHbd/AlPCqN/G7WHXq6ejGl3m2AaaboUxm51dY74pZ 1qJ/yj4xuSqx5j2w1a/tYTWHteED1UedFClprKrRLgmUPJNrbwumPAFxgW+rps+0TIPf O93SRVpHsVs4o4F0wku1nGnbK+F2jw4RHqVVlzsuSfvQzZPAr+htJ25/MdEPAoqW28uy wHOQ== 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=JwcmjpPL5O1ohjHZ/2jQQKCokwtA46k3I5P0kKpPxpw=; b=C8T10QDbBd2l+81f3pWYAH5vQHJCfXSOWYjT3YbwO7swEc6dx9pHE7MDqscebLqaZ/ o7TLtWauBav4NaH0spAKFl8lJuwsID5eLA2z7ymiHFzHHLZ1UxNyHrbJca3HkjR3q7r/ ZSvOHP1XCIdGzi9r1adEzHyya9E3Shl1wIvh+vjBntK0C346Ql1mr6qpeI7zqS7sX6EV FTR3GMBr2SoaG/ECD4ohgelyTWDbZExS+jJwSXEoqulytrfIw6sRIXwBgOho6+dwUqX/ TIPdzZ4Q7aZngxZme0IWSOl6pNvBBfUtBSL3mOP6BTImXqVeVaV3e8dU1ofm4TMZLMwc Brhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MTrL2S9R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d15si3774970pfv.221.2021.10.25.17.57.36; Mon, 25 Oct 2021 17:57:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MTrL2S9R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S240202AbhJYT67 (ORCPT + 99 others); Mon, 25 Oct 2021 15:58:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:42706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237988AbhJYTxA (ORCPT ); Mon, 25 Oct 2021 15:53:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9C906611C0; Mon, 25 Oct 2021 19:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635191047; bh=iZsZt9Wfa6f0L6Q0b7KVcdTKMTJAy+npREB4ivJqzbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MTrL2S9R165l6fzMCyUkLTyUe6zVWUgMZHTGoWNVCN3wySLChmjoRu4Cp4zIVEptT DvTjxkdrB1amQWui9iufF1ehq/kS2BC/bRZ5VivuBzu99yJnL2U8wPj6EeqjanLxYq AyxEN2qaOit60NqHZEuFHY2peYXdGR+u60FXDCwM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Forney , Miroslav Benes , Josh Poimboeuf , Sasha Levin Subject: [PATCH 5.14 132/169] objtool: Check for gelf_update_rel[a] failures Date: Mon, 25 Oct 2021 21:15:13 +0200 Message-Id: <20211025191034.435499528@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211025191017.756020307@linuxfoundation.org> References: <20211025191017.756020307@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Forney [ Upstream commit b46179d6bb3182c020f2bf9bb4df6ba5463b0495 ] Otherwise, if these fail we end up with garbage data in the .rela.orc_unwind_ip section, leading to errors like ld: fs/squashfs/namei.o: bad reloc symbol index (0x7f16 >= 0x12) for offset 0x7f16d5c82cc8 in section `.orc_unwind_ip' Signed-off-by: Michael Forney Reviewed-by: Miroslav Benes Signed-off-by: Josh Poimboeuf Link: https://lore.kernel.org/r/20210509000103.11008-1-mforney@mforney.org Signed-off-by: Sasha Levin --- tools/objtool/elf.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 8676c7598728..6cf4c0f11906 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -1003,7 +1003,10 @@ static int elf_rebuild_rel_reloc_section(struct section *sec, int nr) list_for_each_entry(reloc, &sec->reloc_list, list) { reloc->rel.r_offset = reloc->offset; reloc->rel.r_info = GELF_R_INFO(reloc->sym->idx, reloc->type); - gelf_update_rel(sec->data, idx, &reloc->rel); + if (!gelf_update_rel(sec->data, idx, &reloc->rel)) { + WARN_ELF("gelf_update_rel"); + return -1; + } idx++; } @@ -1035,7 +1038,10 @@ static int elf_rebuild_rela_reloc_section(struct section *sec, int nr) reloc->rela.r_offset = reloc->offset; reloc->rela.r_addend = reloc->addend; reloc->rela.r_info = GELF_R_INFO(reloc->sym->idx, reloc->type); - gelf_update_rela(sec->data, idx, &reloc->rela); + if (!gelf_update_rela(sec->data, idx, &reloc->rela)) { + WARN_ELF("gelf_update_rela"); + return -1; + } idx++; } -- 2.33.0