Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3058445ybt; Sat, 4 Jul 2020 05:15:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykBkWFus9cN3XKvodLwmihLfGocL59OFbRLy/0ULmiHbYOUbyr+uef4O0CNQ1MvQkHS4W2 X-Received: by 2002:aa7:c2c5:: with SMTP id m5mr45807996edp.214.1593864909540; Sat, 04 Jul 2020 05:15:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593864909; cv=none; d=google.com; s=arc-20160816; b=Ep8levC6Ezhf6+tQoMNZ2pbAMuZIpGpucLBmJGHjdm+wcuOIXHG0fJAOqSsN8jIQPb n//2R7lpMexMLsztJuloENWB4ZtGQp4UwrEKOu/AeI0Nx+xKeqPwRXzn03uBvr/DGhCi ubmQVoRTG/MdZadcViKZH9IOkYijTlC/fcZJHET06fB5Thh/8v+bIiBPBNQMDI0V1yEm MyPYFGvkmPKf5kORFXteeSaMHCdVIpGjUFdRUAGYyx2lPsojXoRcVakuKNrf2sryJgV4 +D/Bf9uNO2dgFxN5MYXmwOu0TLzwbt7WBIq6Cih/4GhlB2hXGvXPd8zdAbWxXLgjzPt+ Q5dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:user-agent :in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:dkim-signature; bh=z39UiCuTT5dDf0N3Ht20nc6QILkC1wB3yKnxRVd0gmI=; b=iP3WGXyOI0rfBUxTLWsZLGiYRdFgo4yMUzq5N68oehmJND4TDhtY7xZ4HKDUxYqUoK 4ZvcO1Y9jNynOC5xdVAlx1K2+7bDGCtDh0pAa07ES8SFASiIW/F7myuJe6LJPH8u9Xhj Az+7aMBLN+gT+rHEYqvYmpg3oKJXE2Ibx6RPD5MfzMwEMAsk60GZEWnV/eG3+cYvUSQl DOXR/0ZJmoYsT1GmJBvqkuiKbOL613Lv/Puv6wDO5BWs0FC5INadbuu4zIRzIerPjeAr 2BIIwzX8j+i01QH7o6/XrapliE3EpMo2aHgTUMqSB4asi3rucre5h+MuY5cxJAWIlYTM dGQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=JUkMJUai; 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 i26si9462847ejx.372.2020.07.04.05.14.46; Sat, 04 Jul 2020 05:15:09 -0700 (PDT) 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=@gmx.net header.s=badeba3b8450 header.b=JUkMJUai; 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 S1727848AbgGDMOJ (ORCPT + 99 others); Sat, 4 Jul 2020 08:14:09 -0400 Received: from mout.gmx.net ([212.227.17.20]:38363 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726667AbgGDMOI (ORCPT ); Sat, 4 Jul 2020 08:14:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1593864784; bh=ntqtRXriEvlTQZX7E9tgu9xYlAp6y6JNcyiMi9Omzoc=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:References:In-Reply-To; b=JUkMJUai3QzWrXqWeQMRITAMx7R/NnfqOVFG3I/eAblyTfZcqnZfDhhN5uxnrYnj6 PD1dk/Zthh5vvRXSTl3SFcGggwHsyXTIVwbtuZGpZ0e9YE94oqnk3xTsAXEznlDJ4l H7U4NCPMEs+io6untnzXIA+3BRGJFaqLDlvUpC7s= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from ubuntu ([79.150.73.70]) by mail.gmx.com (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MLzBp-1k9V0T04DB-00HwEN; Sat, 04 Jul 2020 14:13:04 +0200 Date: Sat, 4 Jul 2020 14:12:36 +0200 From: Oscar Carter To: Helge Deller Cc: Oscar Carter , Kees Cook , Steven Rostedt , Ingo Molnar , "James E . J . Bottomley" , kernel-hardening@lists.openwall.com, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] parisc/kernel/ftrace: Remove function callback casts Message-ID: <20200704121236.GA3143@ubuntu> References: <20200627134348.30601-1-oscar.carter@gmx.com> <97375269-f6f1-6157-c8a8-3b925232f00c@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <97375269-f6f1-6157-c8a8-3b925232f00c@gmx.de> User-Agent: Mutt/1.10.1 (2018-07-13) X-Provags-ID: V03:K1:/qNr8bYfFud/XeUItqhmgkKVnnfxe46IOngSaoy6F0Qcr6uUaIc Tgljscv4oMiCP4kLp3uYe06SW9rXv5lRQMjr9C0q6HbdQanooc+Z07KPmfppUHLRZNG99n2 GPyUSy5I5OAZttmQrI1+V3i34fhg6yOS704KXOiebV+gtwcorRToTiEyVpGRBPqu7ytjhFw q+zGA+Z+KRwc26UH0t85A== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:co0hVsy69TI=:ANUkg5pptO4ssqtSkfsBjf SSolZ8XyQPs+cBQnZcJZ/p5PnlE8RJivOzLU/FrI/AUQa4xlX70G3zFEYK985+2TxWNcbUYHU PZSGx9pSTm7spZqJRJ5IbVVSTqg47tp11PMpSOOtvYSnIJhkrj+0fFlcoqLYa49SFdD5iVIQR 97RCnqhjwnIGzXEmNFSrtIlpIbfdwp+EI9V2mTihRRXgIuKMvsZO4Z2Go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encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 27, 2020 at 10:09:40PM +0200, Helge Deller wrote: > On 27.06.20 15:43, Oscar Carter wrote: > > In an effort to enable -Wcast-function-type in the top-level Makefile = to > > support Control Flow Integrity builds, remove all the function callbac= k > > casts. > > > > To do this remove the cast to a function pointer type in the compariso= n > > statement and add to the right and left operand a cast to unsigned lon= g > > type. This can be done since the comparison is against function addres= s > > (these operands are not function calls). > > On some architectures (namely ia64, ppc64 and parisc64) function pointer= s > actually refer to function descriptors, which in turn point to the real > function address. The compiler usually takes care of such comparism. > That said, casting to "unsigned long" might break this... Ok, thanks for the clarification. Today I have learned about function descriptors. > > Signed-off-by: Oscar Carter > > --- > > arch/parisc/kernel/ftrace.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/parisc/kernel/ftrace.c b/arch/parisc/kernel/ftrace.c > > index 1df0f67ed667..86b49a5fc049 100644 > > --- a/arch/parisc/kernel/ftrace.c > > +++ b/arch/parisc/kernel/ftrace.c > > @@ -64,7 +64,7 @@ void notrace __hot ftrace_function_trampoline(unsign= ed long parent, > > function_trace_op, regs); > > > > #ifdef CONFIG_FUNCTION_GRAPH_TRACER > > - if (ftrace_graph_return !=3D (trace_func_graph_ret_t) ftrace_stub || > > + if ((unsigned long)ftrace_graph_return !=3D (unsigned long)ftrace_st= ub || > > Untested, but maybe better use: > dereference_function_descriptor(ftrace_graph_return) !=3D > dereference_function_descriptor(ftrace_stub) Thanks for point me to the right direction about this theme. I will do a new version and I will resend. > ? > Helge Regards, Oscar Carter