Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp340007pxb; Wed, 18 Nov 2020 06:03:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJx1TqPnTEjQZPevWa/Zv8XC15VktJtvGDHEeH1vGkC74vA/N9q9usvr7iDHV8+LzHgRQZKR X-Received: by 2002:a17:906:e96:: with SMTP id p22mr6510517ejf.451.1605708204209; Wed, 18 Nov 2020 06:03:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605708204; cv=none; d=google.com; s=arc-20160816; b=fwhlUPE1+KLQ7jdHtb35B/p84ORZxvVN2pXnytGZ0FW6PjDf+NmXChNZWRwMXxvJfG K38WuMf7fFO1yaCCbiBsfw3m663POYPZg0WKyp1xBOuDbcvc5AshTmT3q8Q5a8jH2YFj lmHxqefHFk0SOvu4jQ7A5WxWQ7QaucXLixBsKlW5LwLdIeU6Z7I6nAcuqdQTGoNcr5Wh yTxe5KSdxBDbVtIZaB/eYFZN3TWPC9U9RTYXDvu1ZBLVMTsxVknJXMPF9xRJQC87RuNc c5GzTaAtUGV0i4FCQr2pG0WvCbxY6MnblAAxWpFLjMcNkjSVZmeD5HnoDOHYe/66SOPQ v1Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:in-reply-to:date :references:subject:cc:to:from; bh=GAhMtAfn0C0Lrwrh6baqKxoBPx5OKs+TO4ffNwxk4Yo=; b=dfmufV+7sns+2b5DKLgtA+UGDPKeFa8eqRNOvH0boigKFOOMFTINjiShqdX8e/bki4 f6Rog/NbIOMjvTYJfoRqJq9DP5JXIC7Co5hm8UgrF6lHNKIccX8pcvtfaGVZ3Xysy/7d HM1QeLjqqdQsZmicYf4cnKRKsZfslYgEonG/hJLTpWGrCcNdWYiTs9jnLN6GNeUbmTzt 9C8rNUxvpfoBE4NBO6oHlr6yPSFw8f+gKV4QMtIRxn8bFkMtkkQ2ajcWDbrGv80bLQJk vstfFLn6bAk8jNF2lQtPtl3We5StJkxYy0MKTfPa0+qj9zdEK08+HycEQNTnoP57dxlv 5lbQ== 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 x65si69529ede.526.2020.11.18.06.03.00; Wed, 18 Nov 2020 06:03:24 -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 S1726743AbgKRN7p (ORCPT + 99 others); Wed, 18 Nov 2020 08:59:45 -0500 Received: from albireo.enyo.de ([37.24.231.21]:37686 "EHLO albireo.enyo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726274AbgKRN7o (ORCPT ); Wed, 18 Nov 2020 08:59:44 -0500 Received: from [172.17.203.2] (helo=deneb.enyo.de) by albireo.enyo.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) id 1kfNzd-00007x-Om; Wed, 18 Nov 2020 13:59:29 +0000 Received: from fw by deneb.enyo.de with local (Exim 4.92) (envelope-from ) id 1kfNzd-00024M-Lt; Wed, 18 Nov 2020 14:59:29 +0100 From: Florian Weimer To: Peter Zijlstra Cc: Steven Rostedt , 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 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> <20201118132136.GJ3121378@hirez.programming.kicks-ass.net> Date: Wed, 18 Nov 2020 14:59:29 +0100 In-Reply-To: <20201118132136.GJ3121378@hirez.programming.kicks-ass.net> (Peter Zijlstra's message of "Wed, 18 Nov 2020 14:21:36 +0100") Message-ID: <87h7pmwyta.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Peter Zijlstra: > 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(). You can pass it as a function parameter, but in general, you cannot call the function with a different prototype. Even trivial differences such as variadic vs non-variadic prototypes matter. The default Linux calling conventions are all of the cdecl family, where the caller pops the argument off the stack. You didn't quote enough to context to tell whether other calling conventions matter in your case. > I'm not sure what the LLVM-CFI crud makes of it, but that's their > problem. LTO can cause problems as well, particularly with whole-program optimization.