Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp621524pxb; Wed, 18 Nov 2020 12:46:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzY9iEucz3C8TW57ZT5RzZVJUK9d3CGFtBNSPjmx894MiGLIexlg2sk2sEuIOMnUZkDQeyZ X-Received: by 2002:a17:906:9448:: with SMTP id z8mr3162690ejx.105.1605732406933; Wed, 18 Nov 2020 12:46:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605732406; cv=none; d=google.com; s=arc-20160816; b=dsfZJYugdD2mqyqnAaDQexcVnJDHgalY5tDZBep3PuvA0Lk5XaZAG5xvVidPYfi9Ua V90tgezAXx5rPOG9MCdoqwQ5865T/tfBe60VQ+Ox9wsa5B3uugixecUcziL/H5HrWk+d 8kiae/FDSqbP76nQAKF4vYuqUUMKnrjRLQl5J6wJMdjAkOsw7zUkQV47/X5T4oAron4k EbSEPwBemh+TxsJnvdTuG4+TrI74O6E90gEaDuhCGmc+I/VMs1+OSKMBEPBRk+RqfW2P QWuh5M1qh9Ax2gdkvdSOpe74WpOveCBwY1981VBZkOx4pfhhNP0qWuL4H2ChG4TyVqCW 2gig== 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=onZ1sbHWNuyda5EX5s7FmneHPGQLaY679o17h1oY/+Y=; b=anlishq5BDQ3VgFcqf7Vw5v5jApB4cDAfRLWYsU/jpCx9pY1D7ALSDGy4oXZIHXAO7 aOdfAucXj7Ju7es3hQxwlNzcAMeCIW5bJl+JsEnruQlvvfjN4OY26r7qL6VMAG0mdaHU BwwxdXZPOPTs5NO5WVJe7S4qt52Bo3iqAuWogmBpdF93cEyRZdJwGAlBUQa9tBLffe2w uN3kzr5h59mDiBQp3K3O/YRSza/G64KTvZl4yIunNYVtw2usJCwVimMty8cGSHQvFeJA sazL70NCxXfV8El7lWqxEu3MAT52PQ2L25cW6cbL2S6W4FnFh+FIzpztLhYkzq7Il6im aPnw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c21si16301729ejr.483.2020.11.18.12.46.23; Wed, 18 Nov 2020 12:46:46 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727220AbgKRUoi (ORCPT + 99 others); Wed, 18 Nov 2020 15:44:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:52212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726416AbgKRUoi (ORCPT ); Wed, 18 Nov 2020 15:44:38 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AB5CD24686; Wed, 18 Nov 2020 20:44:34 +0000 (UTC) Date: Wed, 18 Nov 2020 15:44:32 -0500 From: Steven Rostedt To: Segher Boessenkool Cc: Florian Weimer , Nick Desaulniers , Peter Zijlstra , Sami Tolvanen , Mathieu Desnoyers , linux-kernel , Matt Mullins , Ingo Molnar , Alexei Starovoitov , Daniel Borkmann , Dmitry Vyukov , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , netdev , bpf , Kees Cook , Josh Poimboeuf , linux-toolchains@vger.kernel.org Subject: Re: violating function pointer signature Message-ID: <20201118154432.3e6e9c80@gandalf.local.home> In-Reply-To: <20201118194837.GO2672@gate.crashing.org> References: <375636043.48251.1605642440621.JavaMail.zimbra@efficios.com> <20201117153451.3015c5c9@gandalf.local.home> <20201118132136.GJ3121378@hirez.programming.kicks-ass.net> <20201118121730.12ee645b@gandalf.local.home> <20201118181226.GK2672@gate.crashing.org> <87o8jutt2h.fsf@mid.deneb.enyo.de> <20201118135823.3f0d24b7@gandalf.local.home> <20201118191127.GM2672@gate.crashing.org> <20201118143343.4e86e79f@gandalf.local.home> <20201118194837.GO2672@gate.crashing.org> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 18 Nov 2020 13:48:37 -0600 Segher Boessenkool wrote: > > With it_func being the func from the struct tracepoint_func, which is a > > void pointer, it is typecast to the function that is defined by the > > tracepoint. args is defined as the arguments that match the proto. > > If you have at most four or so args, what you wnat to do will work on > all systems the kernel currently supports, as far as I can tell. It > is not valid C, and none of the compilers have an extension for this > either. But it will likely work. Well, unfortunately, there's tracepoints with many more than 4 arguments. I think there's one with up to 13! > > > The problem we are solving is on the removal case, if the memory is tight, > > it is possible that the new array can not be allocated. But we must still > > remove the called function. The idea in this case is to replace the > > function saved with a stub. The above loop will call the stub and not the > > removed function until another update happens. > > > > This thread is about how safe is it to call: > > > > void tp_stub_func(void) { return ; } > > > > instead of the function that was removed? > > Exactly as safe as calling a stub defined in asm. The undefined > behaviour happens if your program has such a call, it doesn't matter > how the called function is defined, it doesn't have to be C. > > > Thus, we are indeed calling that stub function from a call site that is not > > using the same parameters. > > > > The question is, will this break? > > It is unlikely to break if you use just a few arguments, all of simple > scalar types. Just hope you will never encounter a crazy ABI :-) But in most cases, all the arguments are of scaler types, as anything else is not recommended, because copying is always slower than just passing a pointer, especially since it would need to be copied for every instance of that loop. I could do an audit to see if there's any that exist, and perhaps even add some static checker to make sure they don't. -- Steve