Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp557012pxb; Wed, 18 Nov 2020 11:06:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJzHcxM6bU8npy1eBk0xrT1CwHXUnAaALeYT5jjJyta7ObQAaIwNVx5JUHLiQaTA7KyPN0dO X-Received: by 2002:a17:906:76d3:: with SMTP id q19mr24622512ejn.162.1605726415268; Wed, 18 Nov 2020 11:06:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605726415; cv=none; d=google.com; s=arc-20160816; b=qs0n57/ASW6qPQuIsrTT3L0YqbXCHvoq1dYtHJLRtsyJzElr4aMBduB7Z6acBmTDwh VXdxS1bt0g9l5pibzG08mcmjmcBHwvv4uJlmyU41szffN0e9h+t0IitBcz3/50oh5xb9 7SDeo7fO5tHUUV92ubTx8JABWTJoghP6sE/8RBryiYjcQHr7zKLcprof808I0vOeGZp6 Q90yxlJTDAH8i4AQgFLG9V6c7FWMK7at12oV6SL8NTuD94Dn/vVv3xE9tRkFwQ/h+W8o h8hlXwf+iwAZD6IGAzrPvy7LmdoDKHjaDWM0+F15Rp9Du7Uu5O6c/GOx+gvS3f4bJwIZ XhbQ== 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=f58KEPGwFcQ6hwLm/trY0G2bCBsErzYJDqT+Sr7c/kc=; b=nufeqVjqhwCkomnIh1+S6INxDj7CLwLzmUMhRu9UxQhBgqxjd3xpeVV9Kg52TQPIVj 8ewSMMuFKFjOtGcXFt47RIhx1pSk9Z7L90sGyeX6dohZ5J1UHdvxPzzfmAlHSu5xVnvg Crmkz7XsAyXw9WZVTmrTOqLlBeiXKot67nIscR6jmMKBB2m1N0RGQKTtuC5J7faUlzsP Wf16GUVOYkZ1yUaONjsodd8HjNYyTQmdMlHbkmGrwf2kJjzpsao2oZhhOnp6trsHzsuZ ROEGFmT03HnB5fEILAOVI+9RyFHTvaZ/iEw182Fd/Og/Q3MRgsWxuOY5qHuQjvF/aktr oY0w== 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 j20si16853840edt.219.2020.11.18.11.06.31; Wed, 18 Nov 2020 11:06:55 -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 S1726761AbgKRTFF (ORCPT + 99 others); Wed, 18 Nov 2020 14:05:05 -0500 Received: from gate.crashing.org ([63.228.1.57]:54376 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726163AbgKRTFF (ORCPT ); Wed, 18 Nov 2020 14:05:05 -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 0AIIthGu019175; Wed, 18 Nov 2020 12:55:43 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 0AIIteOV019174; Wed, 18 Nov 2020 12:55:40 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 18 Nov 2020 12:55:40 -0600 From: Segher Boessenkool To: Florian Weimer Cc: Steven Rostedt , 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: <20201118185540.GL2672@gate.crashing.org> 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> <20201118121730.12ee645b@gandalf.local.home> <20201118181226.GK2672@gate.crashing.org> <87o8jutt2h.fsf@mid.deneb.enyo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87o8jutt2h.fsf@mid.deneb.enyo.de> 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 07:31:50PM +0100, Florian Weimer wrote: > * Segher Boessenkool: > > > On Wed, Nov 18, 2020 at 12:17:30PM -0500, Steven Rostedt wrote: > >> I could change the stub from (void) to () if that would be better. > > > > Don't? In a function definition they mean exactly the same thing (and > > the kernel uses (void) everywhere else, which many people find clearer). > > And I think () functions expected a caller-provided parameter save > area on powerpc64le, while (void) functions do not. Like I said (but you cut off, didn't realise it matters I guess): > > In a function declaration that is not part of a definition it means no > > information about the arguments is specified, a quite different thing. Since the caller does not know if the callee will need a save area, it has to assume it does. Similar is true for many ABIs. > It does not > matter for an empty function, but GCC prefers to use the parameter > save area instead of setting up a stack frame if it is present. So > you get stack corruption if you call a () function as a (void) > function. (The other way round is fine.) If you have no prototype for a function, you have to assume worst case, yes. Calling things "a () function" can mean two things (a declaration that is or isn't a definition, two very different things), so it helps to be explicit about it. Just use (void) and do not worry :-) Segher