kernel-hardening.lists.openwall.com archive mirror
 help / color / mirror / Atom feed
From: Oscar Carter <oscar.carter@gmx.com>
To: Helge Deller <deller@gmx.de>
Cc: Oscar Carter <oscar.carter@gmx.com>,
	Kees Cook <keescook@chromium.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ingo Molnar <mingo@redhat.com>,
	"James E . J . Bottomley" <James.Bottomley@HansenPartnership.com>,
	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
Date: Sat, 4 Jul 2020 14:12:36 +0200	[thread overview]
Message-ID: <20200704121236.GA3143@ubuntu> (raw)
In-Reply-To: <97375269-f6f1-6157-c8a8-3b925232f00c@gmx.de>

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 callback
> > casts.
> >
> > To do this remove the cast to a function pointer type in the comparison
> > statement and add to the right and left operand a cast to unsigned long
> > type. This can be done since the comparison is against function address
> > (these operands are not function calls).
>
> On some architectures (namely ia64, ppc64 and parisc64) function pointers
> 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 <oscar.carter@gmx.com>
> > ---
> >  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(unsigned long parent,
> >  				function_trace_op, regs);
> >
> >  #ifdef CONFIG_FUNCTION_GRAPH_TRACER
> > -	if (ftrace_graph_return != (trace_func_graph_ret_t) ftrace_stub ||
> > +	if ((unsigned long)ftrace_graph_return != (unsigned long)ftrace_stub ||
>
> Untested, but maybe better use:
> 	dereference_function_descriptor(ftrace_graph_return) !=
> 		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

      reply	other threads:[~2020-07-04 12:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-27 13:43 [PATCH] parisc/kernel/ftrace: Remove function callback casts Oscar Carter
2020-06-27 20:09 ` Helge Deller
2020-07-04 12:12   ` Oscar Carter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200704121236.GA3143@ubuntu \
    --to=oscar.carter@gmx.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=deller@gmx.de \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).