Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp463340pxb; Wed, 18 Nov 2020 08:53:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwI2XePsFFaRD2C2QO9aKoZMNvgvnqGvbvu2Iso0QYe6g8L5u4XWHCj/3yg9smvPUiu49Zn X-Received: by 2002:a17:907:d1e:: with SMTP id gn30mr25564100ejc.148.1605718423501; Wed, 18 Nov 2020 08:53:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605718423; cv=none; d=google.com; s=arc-20160816; b=cEm9PYq05aNJ+GdSiKL1Lg7BF7TARZ/adHUwamul+82DLWFhuRnlFy1MzdKUi+q/vC wa+VOxSXn8j5v7tKkjmdEiaShQgZ7fHNRpJzcW4oukpc7eOLtj7BrCIEV6DSw2UTAEd7 WKpaQUsEXpP2xFRYpsLrE+lC7Sso77Cz06V3JvQr5Uq4nKlMw14WCUsXkYJ1uQC4rLLt zdwbpnqYxPFnk00SBoKrFw4pOGAxMkd0Xto99Sxgb3UKqgI3WevdhwqfvsPII7OEjtCZ ZcL9RvgF6xxzXrQdAvmdIwkVaons+dL2JNsMaqI2zxuvsMJQy0mGvsEURrZ/YdRo2HGF Nn8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=G9I3t8aN7L1xly0yUdg8yWu3OFUJdCn4z7Buna0vemo=; b=Xk/Gc2FCmiKoStnyuna9E/JcAYsN1ZDEVawAO93SsFVoTc5ac00pYOHNu1kMZb0Ha+ CLD4Ng3lzKfxPhH3PF4ghPkXhT2d6hypFNgp0pv2vlsxNwC8GtWd3NTITFpkZFsrv5V6 D2Dja94y/F7sCHJv0/aujgtw3cZv8vUwh+vWASTYIR64MIvJdr5+gMRzX3Ci2WMkzPro 9f7sAOr2JRhOToluHKbSX5ZYtSEOJmVBhRW2rdoEJpe+QB4EVKHwuVQwHHhq4vbTV3lT SGhwszetzWOguZH/ZYr/5CNG6VwlCZ5EIvLAIRZmB3GC/KHH/NUa11Mh+Q+ndb1Yfiw9 NEpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jkwC9oZ9; 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 a9si17096178edq.466.2020.11.18.08.53.20; Wed, 18 Nov 2020 08:53:43 -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=@google.com header.s=20161025 header.b=jkwC9oZ9; 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 S1727983AbgKRQuu (ORCPT + 99 others); Wed, 18 Nov 2020 11:50:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727977AbgKRQut (ORCPT ); Wed, 18 Nov 2020 11:50:49 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D379AC061A4D for ; Wed, 18 Nov 2020 08:50:49 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id j5so1292588plk.7 for ; Wed, 18 Nov 2020 08:50:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=G9I3t8aN7L1xly0yUdg8yWu3OFUJdCn4z7Buna0vemo=; b=jkwC9oZ9Upku7sbUkXC7BIfgX2KZ0ZxyHa6bNFDCZYHvGnVO88kTnC0w4u/F4ezXnc GREsN/hIh3RnrYa8SD6a6CDC7MAJu4ed+jIwT1rNlu0k8plP0MOlxSgBN1JzWmUewZep fvMI1gACSgiaaDnX6igKVeag6vhyjjjsSGa7q/E0k/j04aT6VwIz+wlQ/FYSAx7bNqUj ssOnPGUtQ+e1ISYv323ocUT9TNcNCN0ChCc11tGc6cWmjlzvFxFi8YjvV1G+u+9PQcan GfOW3i++5NOzBPcvHLHyqTw5BRpaQGfh3JSfFl21svfNJbFlG5JAmExP38mfBSiNtcje cJzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=G9I3t8aN7L1xly0yUdg8yWu3OFUJdCn4z7Buna0vemo=; b=ClP8rNprCDC/rsbnMFck1E8DudQf67/KBxBOGbbcLeRUU2H8Vi5BH4H10yGv02Ym9X YOjwcVPbxjriy7CATH3JBsTCB+HNPlF87m56G4dfsnBl67mDIstgKFs/JcLL2x7NOpz5 l77v8WEO6swslx7qqm9QrysdraaqhAXgUSu312dE+GjJP4Ik7Dm0hyacs6TAB6TIIy4v Qw7Oks2FeoXgsp0X+hc/YqU15fs2a5f28SbpI5PuMNZz+TmwJUTKIm+DBIBG9FknaEab EkVClaGPxh1Up0/t+XT/MRij9/rcRBkPWbNMlql34ATUDIwtowsz/WTCkJw+gNrEwthN ZxMw== X-Gm-Message-State: AOAM531MM5uABB63IApaDL6ihnTHxLtUdygKU/bDNVxnxb0s0onxoCBo vu5R+XLxcfpsqFEM85UCD92ixS7D20aWLhcnW9591A== X-Received: by 2002:a17:90a:6b04:: with SMTP id v4mr736163pjj.101.1605718249147; Wed, 18 Nov 2020 08:50:49 -0800 (PST) MIME-Version: 1.0 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> In-Reply-To: <20201118132136.GJ3121378@hirez.programming.kicks-ass.net> From: Nick Desaulniers Date: Wed, 18 Nov 2020 08:50:37 -0800 Message-ID: Subject: Re: violating function pointer signature To: Peter Zijlstra , Sami Tolvanen 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 18, 2020 at 5:23 AM Peter Zijlstra wrote: > > 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) { } or `void tp_nop_func()` if you plan to call it with different parameter types that are all unused in the body. If you do plan to use them, maybe a pointer to a tagged union would be safer? > > 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. If you have instructions on how to exercise the code in question, we can help test it with CFI. Better to find any potential issues before they get committed. -- Thanks, ~Nick Desaulniers