Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp7868217rwl; Thu, 23 Mar 2023 09:34:29 -0700 (PDT) X-Google-Smtp-Source: AKy350ZwNOB3kB6dn7D9Kyqp/+MLEBm9Xc3jlkn1zY4EgQ11+aD+sy7Ru3OPGf998H77mX7pKDxa X-Received: by 2002:a05:6402:10d7:b0:4fd:2675:3783 with SMTP id p23-20020a05640210d700b004fd26753783mr59651edu.1.1679589269384; Thu, 23 Mar 2023 09:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679589269; cv=none; d=google.com; s=arc-20160816; b=rLNUSJjTfPbIQ2FtxXQnW7ALZxF1KZFfcNo6ob/vtf/N0Yp/2+kPs0d2puq5ti2oZa uyXlGraPs003tq3dmxcmDDnd8T6Sq+FF0tGDec0N2wMP7YMwKkKUtEmuPg6DdhItNlDU Pl9KKeEL/v8zsJhFhD15CGSGuafy/IhX4lspKIGOD1b/VQlMBMsa5uqp7z2L2NMVxpV0 p5Z7a7WIe4xpbMtbGP3SHDjfJfpJK6QLrJdmIrqhibrITFHuq/VQ004OkAS8Ww5y+0vB Y/Yb61r34a32yBexrttCkNG7IQRviWdxp4TmQVTDSX+6KHp3sk2Z7Qwg2pj7+EMeYZN/ lHqA== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=7TbpzhYbBZDpaPlLXdx+xDNq0gtZkfbBaOXa9sJSzHU=; b=em7G8wTgVczlyL4t7+1c9sOg3ktOfTV4xjBPsznSXN5DTComad/UWgAyO5/5T3Hvy8 S4FLgKtOucsSwheFk0Gv3F//B2k/x25fS4wsBvhkdZ4gxJvPbwg9Vi6bYsyhiXDakEN0 2nO4E9uUqzCSz6lJwtqbYs1DfEZM8T8V0QQ1TTHMabmypkIgaxRSJHTGgv4q8FIJRRw2 o6EBKiJYrsnEj4ldGPPkUW9uplXe6mLN+OhqAwYFKrSXyA3VPw6u1MIeHhWhiyw2+jXx +fFkqnC9l/1I4MZGbUNkOQf1hN5+uHLk9IlMr/c03L8DDx2p+WQ8T70okoY7TIqlWN3O EalA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v18-20020aa7cd52000000b004fd29e926fasi19725225edw.559.2023.03.23.09.34.04; Thu, 23 Mar 2023 09:34:29 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232036AbjCWQ04 (ORCPT + 99 others); Thu, 23 Mar 2023 12:26:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231537AbjCWQ0z (ORCPT ); Thu, 23 Mar 2023 12:26:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CEAE2706 for ; Thu, 23 Mar 2023 09:26:53 -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 CC96B627D5 for ; Thu, 23 Mar 2023 16:26:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6EF9C433D2; Thu, 23 Mar 2023 16:26:51 +0000 (UTC) Date: Thu, 23 Mar 2023 12:26:50 -0400 From: Steven Rostedt To: Mark Rutland Cc: linux-kernel@vger.kernel.org, mhiramat@kernel.org, "Jose E. Marchesi" , Nick Desaulniers Subject: Re: [PATCH] tracepoint: Fix CFI failures with tp_stub_func Message-ID: <20230323122650.5a1f2db7@gandalf.local.home> In-Reply-To: <20230323085321.0f8d1b98@gandalf.local.home> References: <20230323114012.2162285-1-mark.rutland@arm.com> <20230323085321.0f8d1b98@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 On Thu, 23 Mar 2023 08:53:21 -0400 Steven Rostedt wrote: > > --- a/include/linux/tracepoint.h > > +++ b/include/linux/tracepoint.h > > @@ -303,6 +303,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) > > __section("__tracepoints_strings") = #_name; \ > > extern struct static_call_key STATIC_CALL_KEY(tp_func_##_name); \ > > int __traceiter_##_name(void *__data, proto); \ > > + void __tracestub_##_name(void *, proto); \ > > struct tracepoint __tracepoint_##_name __used \ > > __section("__tracepoints") = { \ > > .name = __tpstrtab_##_name, \ > > @@ -310,6 +311,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) > > .static_call_key = &STATIC_CALL_KEY(tp_func_##_name), \ > > .static_call_tramp = STATIC_CALL_TRAMP_ADDR(tp_func_##_name), \ > > .iterator = &__traceiter_##_name, \ > > + .stub = &__tracestub_##_name, \ > > .regfunc = _reg, \ > > .unregfunc = _unreg, \ > > .funcs = NULL }; \ > > @@ -330,6 +332,9 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) > > } \ > > return 0; \ > > } \ > > + void __tracestub_##_name(void *__data, proto) \ > > + { \ > > + } \ > > I purposely did not do this because this adds over a thousand stub > functions! It adds one for *every* tracepoint (and that is a superset of > trace events). And the commit that added this code: befe6d946551 ("tracepoint: Do not fail unregistering a probe due to memory failure") Has this in the change log: [ Note, this version does use undefined compiler behavior (assuming that a stub function with no parameters or return, can be called by a location that thinks it has parameters but still no return value. Static calls do the same thing, so this trick is not without precedent. There's another solution that uses RCU tricks and is more complex, but can be an alternative if this solution becomes an issue. Link: https://lore.kernel.org/lkml/20210127170721.58bce7cc@gandalf.local.home/ ] -- Steve