Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3712413pxb; Wed, 13 Oct 2021 11:19:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3DyJF1cwgifVVXiBSiLss4Qr9r1OtKUFEl0Ic8JZ3NJMNcLLTowcTkocIU0MiTxSNse4T X-Received: by 2002:a17:907:1b1f:: with SMTP id mp31mr892544ejc.319.1634149199064; Wed, 13 Oct 2021 11:19:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634149199; cv=none; d=google.com; s=arc-20160816; b=F0UGH3ZH7nSmny/wc1GvySCK5rrJed2QFyGF470dZ7fD6XbLo0SiPxsQG2o9f+G+qR x3cZcdcT0l6fmDuAeEsCTFDvptexpiEOeCIQfWHsDPS6pp/bBztB4HRSbp3ZpW20xLfb FAd1fLaNrARTqnbOVQ7uhSgenvUKrOPwFMj3mEBbLBPCu5beNVWsLGd8PfV4M6HtIVWx ETzNpkLLVqtWIlkX4K1RxMGuzRl8cxHYeNTTI3ZSLWFqvgQvA3LRDN60ZbxIskeKuxsJ LXCWGRDhY6Z8vHALYy/xsp98dwxoVsG7FG5nUSWPed2FIUVFuoMPDz6Cy+pok3JZruzf /myw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=pwc+FjCPki+pUsdoZo4XtJgdpZmZm/wSJdGRGya5uYY=; b=zMK0uROy9Vh5tGDgS1VLWOSp79g4I4GjLmtOV7DNFY8m658xA4iOTz+aOezMQAzgKo 9UmAmKyACKZ2l75CPr3l/2QfjPr/VTkJZ+agRqxkDDTsJf8naXSLolr9XKG0APSp8rdp 9kg3raPDLUm7hzQDVh3Y0GgOxu4e1hmeXgdBj+VKis94Gmm5LGBnHdfVdk6Nal+fEVIU z4oIh+lr3hsTzkH6rYtxYlmB7/xHQZM+qshFOaNM/VDlvhj2RvPoMAQbtTAmVlebz69R ROyBFyZ/T9v6Wh9BdbHXSJuj2B1fBCSi0yTAMioObHjkyrvT6yzqguy/3GOIa4PkhWyl UQwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=gOF7RA7u; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n15si283227edy.244.2021.10.13.11.19.35; Wed, 13 Oct 2021 11:19:59 -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=@google.com header.s=20210112 header.b=gOF7RA7u; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238697AbhJMSTc (ORCPT + 99 others); Wed, 13 Oct 2021 14:19:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238565AbhJMSTR (ORCPT ); Wed, 13 Oct 2021 14:19:17 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89571C06174E for ; Wed, 13 Oct 2021 11:17:13 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id t7-20020a258387000000b005b6d7220c79so4031608ybk.16 for ; Wed, 13 Oct 2021 11:17:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=pwc+FjCPki+pUsdoZo4XtJgdpZmZm/wSJdGRGya5uYY=; b=gOF7RA7uIlhQH2y6fpTZ/eYAsnv1UDVeHBdG5Kz1y5KjInfhB/skiCNuMhYaz6eYMP 6GeQ2qks2JCVGdaRZGOZLkvn8C/4B/RAaTLcXXC2JWDx4WcSdWIwcHfkX81YLVBXmS23 QztXIV6wFQRws60P9NG88hizCJNTlWFUA/gCLyntCxc2YYRnSw0HQb0eY9wLpXIUaetJ /3F+yRlpTuztm2JCTPrGCw4izcPp406dteS3fYtJaRbRREtcpZV02aA5BiXGg9J8FHPl 5Ik8sgKoc95K5v9HO3PCu+zEclGvM0zPjV1HMq6Vuhjg/uV+pgU1gcZEO5PHwQhx0fOh qsdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=pwc+FjCPki+pUsdoZo4XtJgdpZmZm/wSJdGRGya5uYY=; b=ZDS52Vpsjz/r43Wv5+2qSed7q0s7owS3LhCbavzzhzf9mwnKg0+9h0d6boaVBgQQim scptfVV07NSPqFp49eaBvdqVAs/14jn9lUVNfkqE2BI1fkGr3iKHrUES5FgkbHhtwU/B 4a8lQ8I0LLasdN8YLlPjqzlaMv4IhUvd1tgAC9xVNWZe3K9oo4pyUoFs7J+BKPTzOfrI m4JVpKNO/B/YydCHdcT2792i5+GcR5VsfzyeuzlSCmqIZhjcdiGXav0WkqZmZ5MbY8pe mCubjsHuPxk4scA/npYnyDvV5z06MC0IIckVGefuAyxBeB0es7mwArt3qZmZxHkNLi2m fUew== X-Gm-Message-State: AOAM531NwW3We6FczPkYdH21/OMX8df+O3MRzURBUI1qoXwL2Ovr0xNV oeo2AqANDvVqe2ShTo9ZaKA8IFAvRLisQMHbOsA= X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:9ea6:6c27:1876:926c]) (user=samitolvanen job=sendgmr) by 2002:a25:3444:: with SMTP id b65mr1043658yba.14.1634149032759; Wed, 13 Oct 2021 11:17:12 -0700 (PDT) Date: Wed, 13 Oct 2021 11:16:48 -0700 In-Reply-To: <20211013181658.1020262-1-samitolvanen@google.com> Message-Id: <20211013181658.1020262-6-samitolvanen@google.com> Mime-Version: 1.0 References: <20211013181658.1020262-1-samitolvanen@google.com> X-Developer-Key: i=samitolvanen@google.com; a=openpgp; fpr=35CCFB63B283D6D3AEB783944CB5F6848BBC56EE X-Developer-Signature: v=1; a=openpgp-sha256; l=1309; h=from:subject; bh=BL9K7dUCONXE4VvXTqnjSPxrA+FUfOmovuNFxXJ8MRk=; b=owEB7QES/pANAwAKAUy19oSLvFbuAcsmYgBhZyKZY/qhtY/5gujF/wKD5yM9Ja1YB+6s4Oesturj aO9VY8yJAbMEAAEKAB0WIQQ1zPtjsoPW0663g5RMtfaEi7xW7gUCYWcimQAKCRBMtfaEi7xW7jcGDA CpV1/NduuFcm3XECRF3c5hFL6tJA8OCSbz+U3Zgb1RZh2f0MRl+klpd04bXkPbEBdveq6mfleQeGGH gbW51ynVOOFQ8jhVJRwWaf0TKudEr46kKi9XrXPPz81eIatGXP5tFmYpV8hwLX1fjQw9xy94z66T0s U8SJzEYszjKtbHIfP+IDX0BcdEl/zd67ZgvmepKwivvX/1B11iC8rSN8iEzO167nOHET7Q3d9b6yYV baaovxkM36P3Lo4LuWtwO1zfcb1Qq9Yfgn3QpOqDAKT0RkXWhoH45GZfYB0yi1EOOQbrXeHi7XWANV ArCGDunFiLdLhFt9VWvmPGqBcb5YHmllurJe+UxIKtSBWmqIAeUVAEt0WFuXnJ3Otx+ahNYyFo7Djk LimIQquwgKSfEXEYUl9NwfcbZ0jSccnFx5n1D3CVFuCV3QDrchxDrl1VXorvxRdsqDc4Cg4tbUP7qo 4RS4vYNlusrgwq/ARKH95rzQ7yvYLG7UObThxGmXXX4P8= X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog Subject: [PATCH v5 05/15] tracepoint: Exclude tp_stub_func from CFI checking From: Sami Tolvanen To: x86@kernel.org Cc: Kees Cook , Josh Poimboeuf , Peter Zijlstra , Nathan Chancellor , Nick Desaulniers , Sedat Dilek , Steven Rostedt , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Sami Tolvanen Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If allocate_probes fails, func_remove replaces the old function with a pointer to tp_stub_func, which is called using a mismatching function pointer that will always trip indirect call checks with CONFIG_CFI_CLANG. Use DEFINE_CFI_IMMEDATE_RETURN_STUB to define tp_stub_func to allow it to pass CFI checking. Signed-off-by: Sami Tolvanen Reviewed-by: Nick Desaulniers Tested-by: Nick Desaulniers Tested-by: Sedat Dilek --- kernel/tracepoint.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c index 64ea283f2f86..8a0d463c8507 100644 --- a/kernel/tracepoint.c +++ b/kernel/tracepoint.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -99,10 +100,7 @@ struct tp_probes { }; /* Called in removal of a func but failed to allocate a new tp_funcs */ -static void tp_stub_func(void) -{ - return; -} +static DEFINE_CFI_IMMEDIATE_RETURN_STUB(tp_stub_func); static inline void *allocate_probes(int count) { -- 2.33.0.1079.g6e70778dc9-goog