Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp567229pxb; Wed, 18 Nov 2020 11:23:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4q5xNNIIvW9K/mrtD1YguP8jlUDP0Mj9im31YWGAMYq1h1297SEAisXW7ZzScxB0jFntN X-Received: by 2002:a17:906:b0f:: with SMTP id u15mr25583259ejg.109.1605727384918; Wed, 18 Nov 2020 11:23:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605727384; cv=none; d=google.com; s=arc-20160816; b=Nk4oDsiXXrzyUXE0W+U7NEM8kaG8G5Qw1DeEK9+8Rv2gkBiYq670Y5LDR3EeTKX8yS uvHiCkk6yXufy+7lON7kjUV4Jzg9IwtzuSSjXm+I+9gpOfkB9bwAgeqC1iCNbBtWdr1I 5QlQZEVkPw61O9ptO1sy3M8OZ8lsmcsn+NmCvqhIIxZ10ofhX3CopFrmAL9O+q3su18s 3u14AJ5VFJpQh09fDq2g3Qxf4ZxGiZibKyPS3IwkVxJkY4rZy4gUIJTzmvtSTmjYs4Sq 9mYbQE6lt/oz/gy3xCtwzOIXHFh7jKFKz2K+hkRrPCf8GO4KBn2ZmAmQ5XwvlJGDO3dk oHDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=N0eDDe+8zd1MeiEQkpa6SxPTLLBbB7fUoCiibppLLOc=; b=1FL7+3JlqjK8/6M/2eDY2PqXuO82W+SqdmrzUlG74jGq/Qgp5mRycYd97hrwkLWRtQ Os1izwoBy+RerKB522osSxffXEXoPNH2F4xVQ5RQK5C3UfmGjeqQY2OduXpkI4vvvD6G avaC+IcxH33oKLJXdLSubDYleNxEAr7LoCAf3/WOr7qa+0TIV0/Y3Frsn2YHaetEmmay 1rEFCJY0jj+SGi5jgi/yycIq73JyrmYhSthqB5g8pVE3HNV8o/5AS1ZykKvSWVfjFoVX 3wNKa+l7nWMVf4QNohEFVuWlz3pFCf5F5Wj0lUnIHOqBXe8wWWvL7sEeEUDKdNZOGBvK vUvQ== 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 r9si15938042ejo.134.2020.11.18.11.22.41; Wed, 18 Nov 2020 11:23:04 -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 S1727433AbgKRTU1 (ORCPT + 99 others); Wed, 18 Nov 2020 14:20:27 -0500 Received: from gate.crashing.org ([63.228.1.57]:43809 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725948AbgKRTU0 (ORCPT ); Wed, 18 Nov 2020 14:20:26 -0500 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 0AIJBT7B020479; Wed, 18 Nov 2020 13:11:29 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 0AIJBR35020478; Wed, 18 Nov 2020 13:11:27 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 18 Nov 2020 13:11:27 -0600 From: Segher Boessenkool To: Steven Rostedt 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: <20201118191127.GM2672@gate.crashing.org> References: <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> <20201118121730.12ee645b@gandalf.local.home> <20201118181226.GK2672@gate.crashing.org> <87o8jutt2h.fsf@mid.deneb.enyo.de> <20201118135823.3f0d24b7@gandalf.local.home> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201118135823.3f0d24b7@gandalf.local.home> User-Agent: Mutt/1.4.2.3i Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 18, 2020 at 01:58:23PM -0500, Steven Rostedt wrote: > I wonder if we should define on all architectures a void void_stub(void), > in assembly, that just does a return, an not worry about gcc messing up the > creation of the stub function. > > On x86_64: > > GLOBAL(void_stub) > retq > > > And so on. I don't see how you imagine a compiler to mess this up? void void_stub(void) { } will do fine? .globl void_stub .type void_stub, @function void_stub: .LFB0: .cfi_startproc ret .cfi_endproc .LFE0: .size void_stub, .-void_stub 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! Segher