Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3375imw; Tue, 12 Jul 2022 13:20:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1somT8MnJ+sJtUt1ifTLNfodRNZePgSKICKEVatsrrJ8l1znQAv6cip50ZV0jzVtOEEscFo X-Received: by 2002:a05:6402:5cb:b0:434:eb48:754f with SMTP id n11-20020a05640205cb00b00434eb48754fmr34830721edx.421.1657657108753; Tue, 12 Jul 2022 13:18:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657657108; cv=none; d=google.com; s=arc-20160816; b=Mi/Vr47nakrSJu5dzzRATKa4vOJHWjpvgJreW3P21EEp3bIhMoUwtiu3Iqncleklbk 77/dLjMYMNWce//T2WqDP9T/MD8fkGzDGJIcY2FCoUgWKzqGiFqw8fsyK84EwaYo3cXT LZV/uofiNgo/enCIvXbD6I8bX1zP85mXIzDhcWSGv/UK9i5hu+B93qjD7ZV68Wxq+lB5 zm2bfVDQ+rkz1z15hE2vgh7p0nlqe0JEiHuvXBdt1HF994KDjTLz1eKXGiWYZHVhUkEF ZMzOnSv5BVnlpkb9zxuXCeSnCLxuyMs4/jTBt75Qr4rQO4qk/pQqewpBphLjGMm3raYE n3uA== 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=aTS3URL4O6s0hyNv1kuuuS5RQkd4pLLOT6AfNNgzT3w=; b=oGsUMVKs9M4809facl43H4ON4oqt2GQ9qdgEsliMadmPZRwhdIAJ1qQhoG9xZlpfCT sslq57jiyXjo4M3G8JbQGxLsBO9zNH9AEb03h9fF8hp4XQ4GwbMSXeIJrKowwocjlt+n Fm127SecsLvuoa3AwOyDH9AEoNC57/ZHoDDBV01qpqY9lqnsIaseNlz3EmXgUgpmeUoA VxPUEIaUi6Yl1jZ1SGJdGARmEdsajqISrOdnDvFDNKTplvV70j4ZTUguS4HzQLgGGpU8 dt5KGqF10dzX2r0279TM3rJXevPur7MA/k4N5xmd4q5Ub0cmg8tkkz1gT9qlCNLIA/HD EIYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tUrsly+J; 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 z2-20020aa7d402000000b0042bd2c39f07si13769208edq.596.2022.07.12.13.18.02; Tue, 12 Jul 2022 13:18:28 -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=tUrsly+J; 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 S234567AbiGLSt4 (ORCPT + 99 others); Tue, 12 Jul 2022 14:49:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234626AbiGLStX (ORCPT ); Tue, 12 Jul 2022 14:49:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92C553139D; Tue, 12 Jul 2022 11:43:50 -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 092C461AC9; Tue, 12 Jul 2022 18:43:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCE39C3411E; Tue, 12 Jul 2022 18:43:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657651427; bh=v2jQRb/cwYZnNJNo6P3W1xJ1OpzzWBGK68XPPMII0hA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tUrsly+J265bbTu6V59u9lBmuL5VefTyjVzkIfkYQQTB2zxzlG7XS9qaBpoVBgT9A 9SAdYZvQiwGTRGJ0SEFy6vGswerljc+HZ+tFZ5L/VXZDBmFJBXBSQIKqhFwWfJ1W8U n0WR3tG9paQ5bfcARlUI6gMLdxyLINsnOs2EXyBE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , Sasha Levin , Ben Hutchings Subject: [PATCH 5.10 071/130] objtool: Fix SLS validation for kcov tail-call replacement Date: Tue, 12 Jul 2022 20:38:37 +0200 Message-Id: <20220712183249.741563131@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220712183246.394947160@linuxfoundation.org> References: <20220712183246.394947160@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 7a53f408902d913cd541b4f8ad7dbcd4961f5b82 upstream. Since not all compilers have a function attribute to disable KCOV instrumentation, objtool can rewrite KCOV instrumentation in noinstr functions as per commit: f56dae88a81f ("objtool: Handle __sanitize_cov*() tail calls") However, this has subtle interaction with the SLS validation from commit: 1cc1e4c8aab4 ("objtool: Add straight-line-speculation validation") In that when a tail-call instrucion is replaced with a RET an additional INT3 instruction is also written, but is not represented in the decoded instruction stream. This then leads to false positive missing INT3 objtool warnings in noinstr code. Instead of adding additional struct instruction objects, mark the RET instruction with retpoline_safe to suppress the warning (since we know there really is an INT3). Fixes: 1cc1e4c8aab4 ("objtool: Add straight-line-speculation validation") Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20220323230712.GA8939@worktop.programming.kicks-ass.net Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- tools/objtool/check.c | 11 +++++++++++ 1 file changed, 11 insertions(+) --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -961,6 +961,17 @@ static void annotate_call_site(struct ob : arch_nop_insn(insn->len)); insn->type = sibling ? INSN_RETURN : INSN_NOP; + + if (sibling) { + /* + * We've replaced the tail-call JMP insn by two new + * insn: RET; INT3, except we only have a single struct + * insn here. Mark it retpoline_safe to avoid the SLS + * warning, instead of adding another insn. + */ + insn->retpoline_safe = true; + } + return; } }