From patchwork Sat Nov 5 10:36:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 15948 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp919068wru; Sat, 5 Nov 2022 03:37:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5YjKIeHkUOVh+oOn/G7CGdXFlof1F+UETIYHaXgt5vdEWxpNouzdA3b5WANXVNaGLb0igG X-Received: by 2002:a05:6a02:202:b0:42b:d711:f27c with SMTP id bh2-20020a056a02020200b0042bd711f27cmr33809757pgb.246.1667644658012; Sat, 05 Nov 2022 03:37:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667644658; cv=none; d=google.com; s=arc-20160816; b=SvKA/JDdSe9yf89OQm/LsqFz1HZ1/mxEz792aA9qJ9Eqk4uz1zwRMWYlYhXsPetHSe xIzzCIM/D3z7amarnzZsWwDR4fOBd3/EYSP079IsJRCEBxLA7eYpMkn20EpZhDZoNI4J kYARrP0OX8y9HtU3F1os7gwZTnjlqkP0F1CRNyP/1qNkFY+UTOrVXzYemqgzahAk0HFe 0+s3IcmcnenhUbjU4etUCFTw9fp9PFxLZQzvQbx+ZzEY7IRqq6C0zLIl2KeAK3zBU3q4 Qj0HEDiBXf/c8ce+UCeAse2P995TKfny++HMOYcsyxCsAc65FAiJM/uJR3RosqS1sgi5 54TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=1DAEXCKv31INkvBrmiYFmBxfqIyfg4r8BE7OR9TUi7U=; b=w7yYF13ns9ncJVwQOz18BggecNJUAt0+5jrt6u99wx/YqkIuH354qm+jWucbw6g123 Pbq5XZtieeOGM0Potei6EwhkH2xmDJvs9dQbM0zKErDJAjxzM9262lXIfe1nOJ0LjNI4 XtxoTGfqjXhxLOyTXse30ZTPbQciffSe06MLeeXMeCu9+H599RVSmc7hP4Bv12bOtbaf g2ay+OIEvlPxYPQbBtl1/msWy8dILWiu4x4zRS3TYXI86jxJuKAxls1y/nbMJEmw2IUN ufoaZ/onPVMCLedmARjLAfUt4XnXftdH83RitSS3RHTvHQ/QRaTx1DEvcHMV7F894bW/ KkQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=W2NNpFo8; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a14-20020a056a000c8e00b0056282b4a984si2422777pfv.126.2022.11.05.03.37.25; Sat, 05 Nov 2022 03:37:37 -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=@linutronix.de header.s=2020 header.b=W2NNpFo8; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229670AbiKEKgh (ORCPT + 99 others); Sat, 5 Nov 2022 06:36:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229479AbiKEKga (ORCPT ); Sat, 5 Nov 2022 06:36:30 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF94E2B18B; Sat, 5 Nov 2022 03:36:29 -0700 (PDT) Date: Sat, 05 Nov 2022 10:36:26 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1667644588; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1DAEXCKv31INkvBrmiYFmBxfqIyfg4r8BE7OR9TUi7U=; b=W2NNpFo8d0RGhmikvSY/jUyJcSQ8ijkiC1sJcAUV3BY/D78eLq2UWUfdbGgX0NTeXCuW23 2GopUjcPXwi7294Z6gGokiQ5wmnspc9Y7HbqCgj8UEV0Zwo5Yo3zxYLQefY241ave94RrG pYbrIpMHfI5AY3aB9i9LXuKJmeBbNYGZ74WpsEFdjtGc7UBKgYsVifR/+RAXba2ux8a8RX DMIXNyvqq4uoR8qMYc8fo+bqga1SnhnmvfETouH1G6tqRYqms9EqDZwzMm45hHw6qyNOTj fWto68z8+25889BVTAcN/H0UBAVUc5xVXrYj7ZXU/QIIHDGBUOBFxz4wmrmFPw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1667644588; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1DAEXCKv31INkvBrmiYFmBxfqIyfg4r8BE7OR9TUi7U=; b=pkRCGDKAu6cle/KR+FEgLAHIALxhzcXpq6cRd+cAx3Q8nUPm6WDmblv21Ig8hXaZhmhTMg Vq3B/hbkYYQh/nCg== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/core] objtool: Fix weak hole vs prefix symbol Cc: Borislav Petkov , kernel test robot , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <166764458700.4906.4772901868553171180.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748652164758746332?= X-GMAIL-MSGID: =?utf-8?q?1748652164758746332?= The following commit has been merged into the x86/core branch of tip: Commit-ID: 023f2340f053537cce170c31c430b0886c6f07ca Gitweb: https://git.kernel.org/tip/023f2340f053537cce170c31c430b0886c6f07ca Author: Peter Zijlstra AuthorDate: Thu, 03 Nov 2022 20:57:51 +01:00 Committer: Peter Zijlstra CommitterDate: Sat, 05 Nov 2022 11:28:02 +01:00 objtool: Fix weak hole vs prefix symbol Boris (and the robot) reported that objtool grew a new complaint about unreachable instructions. Upon inspection it was immediately clear the __weak zombie instructions struck again. For the unweary, the linker will simply remove the symbol for overriden __weak symbols but leave the instructions in place, creating unreachable instructions -- and objtool likes to report these. Commit 4adb23686795 ("objtool: Ignore extra-symbol code") was supposed to have dealt with that, but the new commit 9f2899fe36a6 ("objtool: Add option to generate prefix symbols") subtly broke that logic by created unvisited symbols. Fixes: 9f2899fe36a6 ("objtool: Add option to generate prefix symbols") Reported-by: Borislav Petkov Reported-by: kernel test robot Signed-off-by: Peter Zijlstra (Intel) --- tools/objtool/check.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 55066c4..4f1a738 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -4053,8 +4053,28 @@ static int add_prefix_symbol(struct objtool_file *file, struct symbol *func, offset = func->offset - prev->offset; if (offset >= opts.prefix) { - if (offset == opts.prefix) + if (offset == opts.prefix) { + /* + * Since the sec->symbol_list is ordered by + * offset (see elf_add_symbol()) the added + * symbol will not be seen by the iteration in + * validate_section(). + * + * Hence the lack of list_for_each_entry_safe() + * there. + * + * The direct concequence is that prefix symbols + * don't get visited (because pointless), except + * for the logic in ignore_unreachable_insn() + * that needs the terminating insn to be visited + * otherwise it will report the hole. + * + * Hence mark the first instruction of the + * prefix symbol as visisted. + */ + prev->visited |= VISITED_BRANCH; elf_create_prefix_symbol(file->elf, func, opts.prefix); + } break; } insn = prev;