Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp314763pxb; Wed, 18 Nov 2020 05:24:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxavSbx97h92FchM16mlVuvqVrQ/ZWYirUz29M9imqRZ2PMiitGGNAcAy0dKw9+4dpb6cnw X-Received: by 2002:a17:906:dbf4:: with SMTP id yd20mr23213423ejb.53.1605705856664; Wed, 18 Nov 2020 05:24:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605705856; cv=none; d=google.com; s=arc-20160816; b=GJMuiXWyCjBsJDdtV6t38eIh6cStb1MLctO+2+eMy92pLGX+rOj/ARR1jY7WirLMGu G6w0/1hED0Q7HVYGOCZRC3yxlY5IWd8F9PXya7FOGaaKk8ENke//UiuoskEdfcV17axu cpZ/pjcduttJpQnzOl/TDqSuC9MVtFYcrwZswAyIZ6X3PeJLTWNTe4kho0euWW5ba/Jk qEWHSpN3Ym+ijOVUNj0kzg01FJ4573g0AoSMNHDU1STQhuOe1ZPq4g+dhvLBQbAg6U0G IPulCKO+FhO9UR/cxxEgPGo7c0Woq7hU2QC8+JWfEfgT+le+yQjU5U6KQRtlsQbCGGSz 5AAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=304dWlgV4M2wRi89v82SUM37CJvIM8VxHmQweeYvBaI=; b=1J4H8dmUi6vM46hOFYJ0kzUwtIKOpspgbn9HZmmC+xutXLBYR7TRchk5FWQzmZ61ht 7SC5qUArhLxhNVD4LCIp0ggxaPnnjGrITz027wcL19Z+qSyCKrHssEQAQzteINxhNCOu dexsyXyNNihn6jmUkA4dI3rvD12XWHgMhbJ7UURPzzoZDZfaoCLybGGElSPhWKxsMEq3 KKb7l5JiI/n9FAG3IC+m2tYfO5cBrszYfutmRn1uyiJQUMXmtyHxkCvllo8jzovk4LwF 4lYT/hS8CTJ43DcHps9EXwH1FGeTnQZi4m235ph1RxgofoJi4yvTVDdbGsuecWk8vXJY r4YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="WJibo/P6"; 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 lu5si15051266ejb.544.2020.11.18.05.23.51; Wed, 18 Nov 2020 05:24:16 -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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="WJibo/P6"; 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 S1726163AbgKRNWO (ORCPT + 99 others); Wed, 18 Nov 2020 08:22:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725767AbgKRNWN (ORCPT ); Wed, 18 Nov 2020 08:22:13 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59CEBC0613D4; Wed, 18 Nov 2020 05:22:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=304dWlgV4M2wRi89v82SUM37CJvIM8VxHmQweeYvBaI=; b=WJibo/P6oUNW82KjoGVgCSC64B vgFXenT8KrfcbWPEy3tncLCkyu21yLHxG2PHoRAG+3g/hhE1hILFlYMS4ES9flVs4G6BCdU5Yqr7v kw5wjRgJusQVf3KCWQg+67hz9+OVvkN2xQ4U2GKoSFqrhOJmYegImZeIVfWFDy+5V60Pe6pDgsEy3 Cqf+zV10UPR0lMssdIi8ic+kHfv5b/2YX8aWcuCctA1SgQQebqvYTqCGNCY7jw6nHNuyNhOAl8H9R pjEQe3PFGzrYVzpggre8W0yZicwBGvO/P7DbbC2LOErQnywtsaNlvtkpr9dYuMLZ4SLj28w2jURt2 V5KFJk5g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfNP4-0008CO-0n; Wed, 18 Nov 2020 13:21:42 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 17D0D3012DC; Wed, 18 Nov 2020 14:21:37 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 002E5200E0A39; Wed, 18 Nov 2020 14:21:36 +0100 (CET) Date: Wed, 18 Nov 2020 14:21:36 +0100 From: Peter Zijlstra To: Steven Rostedt Cc: 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: violating function pointer signature Message-ID: <20201118132136.GJ3121378@hirez.programming.kicks-ass.net> References: <20201116175107.02db396d@gandalf.local.home> <47463878.48157.1605640510560.JavaMail.zimbra@efficios.com> <20201117142145.43194f1a@gandalf.local.home> <375636043.48251.1605642440621.JavaMail.zimbra@efficios.com> <20201117153451.3015c5c9@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201117153451.3015c5c9@gandalf.local.home> X-Bad-Reply: References and In-Reply-To but no 'Re:' in Subject. Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 17, 2020 at 03:34:51PM -0500, Steven Rostedt wrote: > > > Since all tracepoints callbacks have at least one parameter (__data), we > > > could declare tp_stub_func as: > > > > > > static void tp_stub_func(void *data, ...) > > > { > > > return; > > > } > > > > > > And now C knows that tp_stub_func() can be called with one or more > > > parameters, and had better be able to deal with it! > > > > AFAIU this won't work. > > > > C99 6.5.2.2 Function calls > > > > "If the function is defined with a type that is not compatible with the type (of the > > expression) pointed to by the expression that denotes the called function, the behavior is > > undefined." > > But is it really a problem in practice. I'm sure we could create an objtool > function to check to make sure we don't break anything at build time. I think that as long as the function is completely empty (it never touches any of the arguments) this should work in practise. That is: void tp_nop_func(void) { } can be used as an argument to any function pointer that has a void return. In fact, I already do that, grep for __static_call_nop(). I'm not sure what the LLVM-CFI crud makes of it, but that's their problem.