All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Oscar Carter <oscar.carter@gmx.com>
Cc: Kees Cook <keescook@chromium.org>, Ingo Molnar <mingo@redhat.com>,
	kernel-hardening@lists.openwall.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kernel/trace: Remove function callback casts
Date: Mon, 15 Jun 2020 16:22:45 -0400	[thread overview]
Message-ID: <20200615162245.13d3feff@oasis.local.home> (raw)
In-Reply-To: <20200615161738.18d07ce6@oasis.local.home>

On Mon, 15 Jun 2020 16:17:38 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Sun, 14 Jun 2020 09:01:54 +0200
> Oscar Carter <oscar.carter@gmx.com> 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, use the ftrace_ops_list_func function as a wrapper when the
> > arch not supports ftrace ops instead of the use of a function cast.
> >   
> 
> We need more tricker than this.
> 
> > Signed-off-by: Oscar Carter <oscar.carter@gmx.com>
> > ---
> >  kernel/trace/ftrace.c | 11 ++++++++---
> >  1 file changed, 8 insertions(+), 3 deletions(-)
> > 
> > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> > index c163c3531faf..ed1efc0e3a25 100644
> > --- a/kernel/trace/ftrace.c
> > +++ b/kernel/trace/ftrace.c
> > @@ -119,13 +119,12 @@ struct ftrace_ops __rcu *ftrace_ops_list __read_mostly = &ftrace_list_end;
> >  ftrace_func_t ftrace_trace_function __read_mostly = ftrace_stub;
> >  struct ftrace_ops global_ops;
> > 
> > -#if ARCH_SUPPORTS_FTRACE_OPS
> >  static void ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
> >  				 struct ftrace_ops *op, struct pt_regs *regs);
> > -#else
> > +
> > +#if !ARCH_SUPPORTS_FTRACE_OPS
> >  /* See comment below, where ftrace_ops_list_func is defined */
> >  static void ftrace_ops_no_ops(unsigned long ip, unsigned long parent_ip);
> > -#define ftrace_ops_list_func ((ftrace_func_t)ftrace_ops_no_ops)  
> 
> The reason for the typecast is because this gets called from asm with only two parameters.

[ Some how hit a short cut key that sent this before I was finished! :-p ]

As I was saying. This typecast is being paranoid, as archs will call
the ftrace_ops_list_func directly, and only pass in two parameters.

Now one way around this is to instead of having the typecast, I could
use linker magic to create another function that I can define without
the typecast to get the same effect. Similar to what I did in commit:

46f9469247c6f ("ftrace: Rename ftrace_graph_stub to ftrace_stub_graph")

-- Steve



> 
> >  #endif
> > 
> >  static inline void ftrace_ops_init(struct ftrace_ops *ops)
> > @@ -6860,6 +6859,12 @@ static void ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
> >  }
> >  NOKPROBE_SYMBOL(ftrace_ops_list_func);
> >  #else
> > +static void ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
> > +				 struct ftrace_ops *op, struct pt_regs *regs)
> > +{
> > +	ftrace_ops_no_ops(ip, parent_ip);
> > +}
> > +
> >  static void ftrace_ops_no_ops(unsigned long ip, unsigned long parent_ip)
> >  {
> >  	__ftrace_ops_list_func(ip, parent_ip, NULL, NULL);
> > --
> > 2.20.1  
> 


  reply	other threads:[~2020-06-15 20:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-14  7:01 [PATCH] kernel/trace: Remove function callback casts Oscar Carter
2020-06-15 20:17 ` Steven Rostedt
2020-06-15 20:22   ` Steven Rostedt [this message]
2020-06-17 20:28     ` Steven Rostedt
2020-06-20 14:23       ` Oscar Carter

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=20200615162245.13d3feff@oasis.local.home \
    --to=rostedt@goodmis.org \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=oscar.carter@gmx.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.