Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2304863pxb; Fri, 5 Feb 2021 14:29:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJydYFncYb9tpqkaYtQXPV6g8KmCHw+qRs3pjkuEng7Zv0MgD0ndlnUbjGqJE3hrfE6AX2w+ X-Received: by 2002:a05:6402:b8c:: with SMTP id cf12mr5653167edb.320.1612564155625; Fri, 05 Feb 2021 14:29:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612564155; cv=none; d=google.com; s=arc-20160816; b=Gp34uz8zU2qwWv8gAkPKn8v4pxpfI0jejLCe1WMT20gkES/ekBAPmhC7bngkGMwGB4 16/5L4efLhBhZ0X2GGpSKRgg1mhqI23uWt2GFeL0o8bGZymoedeSQk7qp0T+u2lti+Hs YwNm2Bp2ZHklbNnifoVolZHXllSlwMhGmDkjO95D+wGgq8Wa1lqgTJMbZgztKhKi6jRM +EvHVx/i5AEIJtGbB6HFDxEb/j7zbwL6JSuvdANXkALFudDNX01BphPd0IW4iOZYQqB0 39LHZX8YURl/HFP/MBt83bOPZ/OI3ajBu0mdETVhow/CbNygeNN30OWywDFDfVODzJ95 uVXw== 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=pwxo6f2AhBZQYPntUR9yWgac+/KTyBvy0vAB3HfBXa4=; b=P5WnJnrEHq9m1V+xUzMuLzkMJNVY6GQ5HC86p4WCAU87XaBQzSb9Eo81+tVnVCpqYl j1EEVE9VM18VbhEXzYyoO/enzFJnFbBtwdVQNIisMwDi4YxHvcSBQsI1P8nT/vVFORlM tGi7rFN6Rbcgdl7KDbgwHSgD7qtl5rcACrynKB2p5S7drM0hfuBacjuAcclm8UFGLzz9 F/4X+R+rTQT6ckDMm7xjVs5ak6FZ6CtSiXlCKVKC/sC6g1Kmn5IVTz1l4Num8PzNYo1R /JSkZRXTvUDQ+WJgV0PGRUAcg+SkEU9JY5kRXrEdIFarVfaaoz/CfUMAIUpJNzGMV9zn +LTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f4bGe+Hi; 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 y16si6238935edq.174.2021.02.05.14.28.51; Fri, 05 Feb 2021 14:29:15 -0800 (PST) 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=f4bGe+Hi; 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 S231284AbhBEW1H (ORCPT + 99 others); Fri, 5 Feb 2021 17:27:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:44684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232837AbhBEOye (ORCPT ); Fri, 5 Feb 2021 09:54:34 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id BC31465028; Fri, 5 Feb 2021 14:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612534296; bh=Vc+XaFPpPgaKd/O8Zcj/k/f9jRzHIKNPTFM6D9De5Ys=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f4bGe+HiPIrSHCiruTncsok8iYuOQ12E8M2bl0pc3sRlthIaShtubZw4Ct41K+vP+ B9i8vpMpzJN5a3uGHRDl10MBkF0vSLEF+Hs7aTFJ9phDhUhnpJvanqTgTQ/hRfA/DW bPhZtgKtqw2ALdQBremAacIp1g/UAnl8TibPJhIU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , "Peter Zijlstra (Intel)" , Josh Poimboeuf , Sasha Levin Subject: [PATCH 5.10 31/57] objtool: Dont add empty symbols to the rbtree Date: Fri, 5 Feb 2021 15:06:57 +0100 Message-Id: <20210205140657.300782881@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210205140655.982616732@linuxfoundation.org> References: <20210205140655.982616732@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: Josh Poimboeuf [ Upstream commit a2e38dffcd93541914aba52b30c6a52acca35201 ] Building with the Clang assembler shows the following warning: arch/x86/kernel/ftrace_64.o: warning: objtool: missing symbol for insn at offset 0x16 The Clang assembler strips section symbols. That ends up giving objtool's find_func_containing() much more test coverage than normal. Turns out, find_func_containing() doesn't work so well for overlapping symbols: 2: 000000000000000e 0 NOTYPE LOCAL DEFAULT 2 fgraph_trace 3: 000000000000000f 0 NOTYPE LOCAL DEFAULT 2 trace 4: 0000000000000000 165 FUNC GLOBAL DEFAULT 2 __fentry__ 5: 000000000000000e 0 NOTYPE GLOBAL DEFAULT 2 ftrace_stub The zero-length NOTYPE symbols are inside __fentry__(), confusing the rbtree search for any __fentry__() offset coming after a NOTYPE. Try to avoid this problem by not adding zero-length symbols to the rbtree. They're rare and aren't needed in the rbtree anyway. One caveat, this actually might not end up being the right fix. Non-empty overlapping symbols, if they exist, could have the same problem. But that would need bigger changes, let's see if we can get away with the easy fix for now. Reported-by: Arnd Bergmann Acked-by: Peter Zijlstra (Intel) Signed-off-by: Josh Poimboeuf Signed-off-by: Sasha Levin --- tools/objtool/elf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 9452cfb01ef19..f4f3e8d995930 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -425,6 +425,13 @@ static int read_symbols(struct elf *elf) list_add(&sym->list, entry); elf_hash_add(elf->symbol_hash, &sym->hash, sym->idx); elf_hash_add(elf->symbol_name_hash, &sym->name_hash, str_hash(sym->name)); + + /* + * Don't store empty STT_NOTYPE symbols in the rbtree. They + * can exist within a function, confusing the sorting. + */ + if (!sym->len) + rb_erase(&sym->node, &sym->sec->symbol_tree); } if (stats) -- 2.27.0