Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1367092imi; Sat, 23 Jul 2022 03:50:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t8EEjR/PC7S3c4HoiiefqJZlE/pZIP5s+a5Gy4YQeM0X6xOQzTw4A5xaGaZIc8qeznXESw X-Received: by 2002:aa7:dc17:0:b0:43b:6c14:8bf with SMTP id b23-20020aa7dc17000000b0043b6c1408bfmr3894614edu.190.1658573437582; Sat, 23 Jul 2022 03:50:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658573437; cv=none; d=google.com; s=arc-20160816; b=rxaMjypUbHet8fJwg41fFaJSoXNFYM01ls5m6PA5mVq6fyzmD2sYiM2vvt/BFfPz4j 8PSCg41xJnw/DvS/gf9MnOtln6WweaNSEed2AM/ieTdCLKeEJeTKuGAJQUNmnyZcyxr/ xr/EcDwAedrlKqD329Ihg9zq49A98w6XGrOQe8AFPWLFKZ755ZZpsNHrToiC3Opyn4kX 1uwhsN0yToYsGw+i68OSbryv5MhoFQrKPGWqugXAHqENKo2m1pIsyFkd2hOhDF4Ev/g3 K204D1ZROc5kyf1znujBAxsOzjVBOw6m5J15q+h5eNy0wcL0HW8f1ulhzXSrEVzGr12Z nETQ== 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=Mcv5CU9e9qOAXZbfF4ACDnWXf+DXsTLNMaRwTAlMbbjejxzcBRNEToguqgkf3Qir2d G2BbAaWLWKvJvja+hTaBtyDx8KUmyoKwWWnrL9gB0bOdu7UkAt2AueleTR/nRpwLwEnk v3FsUfmkZb3KBA4tHqRZrnWsT6mZZkNf5DJP7BJJT9OAT/RmIwFrB0QxzQQLCJ/sG4/a nXJMM+xwVvP9fVoqJuBf3horTjeQ1STbyCmz7fMcuaGMtIr1NdQEwVBFH0Gqt0ktf3FN tVrFg8kefvCLz3ajQ8774sbsDdZdTgXtfMeDmCs4M8yowmIRpwEszmNIwn9dupmd8Ksf 0YGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=S2JjE2os; 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 w23-20020a1709062f9700b0072a4b4fb1e0si2343354eji.911.2022.07.23.03.50.07; Sat, 23 Jul 2022 03:50: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=@linuxfoundation.org header.s=korg header.b=S2JjE2os; 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 S238262AbiGWKDw (ORCPT + 99 others); Sat, 23 Jul 2022 06:03:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238105AbiGWKDY (ORCPT ); Sat, 23 Jul 2022 06:03:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB5CC88F0A; Sat, 23 Jul 2022 02:59:28 -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 ams.source.kernel.org (Postfix) with ESMTPS id 619FDB82C1B; Sat, 23 Jul 2022 09:59:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81151C341C0; Sat, 23 Jul 2022 09:59:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658570364; bh=v2jQRb/cwYZnNJNo6P3W1xJ1OpzzWBGK68XPPMII0hA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S2JjE2osv5Vzw8YU+AAwf84S+N/wjxQxQJD7lznZ8SjmQ0kxIJ5mR7GhmFbdp8/vy 3C52MhcSO25N91GaqUbJdDOz/JDtG4jaSOXRHbcih1md0ga5ggKxfd/1MWxmN0B/41 NVUNhql//TGL1bCmThYbvckmV80nUpHiJIF5gtqs= 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/148] objtool: Fix SLS validation for kcov tail-call replacement Date: Sat, 23 Jul 2022 11:54:43 +0200 Message-Id: <20220723095244.084751710@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220723095224.302504400@linuxfoundation.org> References: <20220723095224.302504400@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.8 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 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; } }