Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp283010pxb; Thu, 19 Nov 2020 00:39:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzIr8MfHs1PCScbok5S94SbRzGnzzaaDvxdQlMI7G22IPIxsZ1AlFr2JYSTnPx0CNFXkk3q X-Received: by 2002:aa7:df89:: with SMTP id b9mr30161060edy.335.1605775156972; Thu, 19 Nov 2020 00:39:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605775156; cv=none; d=google.com; s=arc-20160816; b=EYUS+EPgxrTjSV9CNJ0GIt+yGmlPX7kghRPltZwb0ya3bMswzxcssTag12tuTwc0BO 2VrEnGer6fFAPfaj0TUeW1qMix7Jxi5meSn05eBicH1cj+Bb6Cq24A92Uf3vJusOMno8 gKSxFHOFVpBUQSqyNS0lIQzZ/2+ZL7NeuaFT5xiatdhRgeVMPgzrB3MnMlxzAU0WL6Jk uVlnu1gt/zCrrIqPXqxnGdTqjD7oUfvUM/P3oWisjXZ3/lykbdWdLurGfSHqaPBFRqyA Z3IDTKY1Ao8V7nd1L1i1J99bZFkSDgK9G3SBe+itApm9vlukM1z1SvKCV29szpgWJ1D8 9GaQ== 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=EQ5bBRTWq6ELqPUgP7TVxM2lYlJzPItyKiYHy5i08tU=; b=uJtgWAETYctXrgkr6sWADUJdQFspSoKUSGB1367qPxSIV9ayrw89OfHq0hoCfCb/1V Ff5UJi/w6stK5SV0mx26u3BmxuTHXnUFpZ6pADpscAIFgNIaJqP/mLaFpVQAuu1NVmEK S1r4qeeQTZs0dPgIpK8SOTgMa4xA3i7HpfEfoCbpMHLjYOkvPoy8Jbwx4DSBXicREq64 3DlHY5+mWNF+HeGV9OANZ3uuqsYUvFtmmSg6xdEYTUybcd9AOPSbEs+bgJU++oTovAdw io+6QFC7LhV87l5NXEHCqTw9+4c6Ewfhfzfgt+gYQeykilevDGjbHo+EN7xPS5gMIIj7 CIdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=RUZctQwc; 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 v4si16976204ejq.582.2020.11.19.00.38.54; Thu, 19 Nov 2020 00:39: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=RUZctQwc; 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 S1726575AbgKSIhN (ORCPT + 99 others); Thu, 19 Nov 2020 03:37:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726457AbgKSIhN (ORCPT ); Thu, 19 Nov 2020 03:37:13 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95E8BC0613CF; Thu, 19 Nov 2020 00:37:12 -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=EQ5bBRTWq6ELqPUgP7TVxM2lYlJzPItyKiYHy5i08tU=; b=RUZctQwcZN8oIJJn+j5hHOtuSI VGVegOMV0ogh8QHOuimZalpzMAMUxd/bbKIMQ3cKPZY5hbgrX0m3yeQb+nnhYGfqmWp59lXpBdtcI 8vcEMQj+9ww5i60gcb8L+08RM5hyKPBmNFjwVgPH5Lgz9FZLpfwGR4O/Rb4LdSUDZELcT1nHvoqJL WTCuAMFsuIwOkDpXDbsMqIoC5HmJVjYbmClOhHrBpgFPP8+tO4lWZEwu4ivix9tFfAun0JGr2Zj1v N+dWrdYRyavq3WpDcyXIhsfhuc7zkWZjs76X8C5WpX40AR08FnRq0PzY71Brso55d7WfDM9eq2i/e f3idustw==; 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 1kffQv-0003tZ-JT; Thu, 19 Nov 2020 08:36:49 +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 5A4F0300F7A; Thu, 19 Nov 2020 09:36:48 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 3604B200DF1AB; Thu, 19 Nov 2020 09:36:48 +0100 (CET) Date: Thu, 19 Nov 2020 09:36:48 +0100 From: Peter Zijlstra To: Segher Boessenkool Cc: Steven Rostedt , Florian Weimer , Nick Desaulniers , 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: <20201119083648.GE3121392@hirez.programming.kicks-ass.net> References: <20201117142145.43194f1a@gandalf.local.home> <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201118191127.GM2672@gate.crashing.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 18, 2020 at 01:11:27PM -0600, Segher Boessenkool wrote: > Calling this via a different declared function type is undefined > behaviour, but that is independent of how the function is *defined*. > Your program can make ducks appear from your nose even if that function > is never called, if you do that. Just don't do UB, not even once! Ah, see, here I think we disagree. UB is a flaw of the spec, but the real world often has very sane behaviour there (sometimes also very much not). In this particular instance the behaviour is UB because the C spec doesn't want to pin down the calling convention, which is something I can understand. But once you combine the C spec with the ABI(s) at hand, there really isn't two ways about it. This has to work, under the premise that the ABI defines a caller cleanup calling convention. So in the view that the compiler is a glorified assembler, I'll take UB every day if it means I can get the thing to do what I want it to. Obviously in the interest of co-operation and longer term viability, it would be nice if we can agree on the behaviour and get a language extention covering it. Note that we have a fairly extensive tradition of defining away UB with language extentions, -fno-strict-overflow, -fno-strict-aliasing, -fno-delete-null-pointer-checks etc..