lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 1 Apr 2020 13:42:50 +0300
From:   Adrian Hunter <adrian.hunter@...el.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Ingo Molnar <mingo@...hat.com>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        Borislav Petkov <bp@...en8.de>,
        "H . Peter Anvin" <hpa@...or.com>, x86@...nel.org,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Mathieu Poirier <mathieu.poirier@...aro.org>,
        Leo Yan <leo.yan@...aro.org>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Jiri Olsa <jolsa@...hat.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH V4 08/13] ftrace: Add perf text poke events for ftrace
 trampolines

On 1/04/20 1:09 pm, Peter Zijlstra wrote:
> On Wed, Mar 04, 2020 at 11:06:28AM +0200, Adrian Hunter wrote:
>> Add perf text poke events for ftrace trampolines when created and when
>> freed.
> 
> If I'm not mistaken that ends up like so:
> 
> static void ftrace_update_trampoline(struct ftrace_ops *ops)
> {
> +       unsigned long trampoline = ops->trampoline;
> +
> 	arch_ftrace_update_trampoline(ops);
> +       if (ops->trampoline && ops->trampoline != trampoline &&
>> +	    (ops->flags & FTRACE_OPS_FL_ALLOC_TRAMP)) {
>> +		/* Add to kallsyms before the perf events */
> +               ftrace_add_trampoline_to_kallsyms(ops);
>> +		perf_event_ksymbol(PERF_RECORD_KSYMBOL_TYPE_OOL,
>> +				   ops->trampoline, ops->trampoline_size, false,
>> +				   FTRACE_TRAMPOLINE_SYM);
>> +		/*
>> +		 * Record the perf text poke event after the ksymbol register
>> +		 * event.
>> +		 */
>> +		perf_event_text_poke((void *)ops->trampoline, NULL, 0,
>> +				     (void *)ops->trampoline,
>> +				     ops->trampoline_size);
> 	}
> }
> 
> And afaict, that is wrong.
> 
> The thing is; arch_ftrace_update_trampoline() can actually *update* an
> existing trampoline, as per the name. Yes it also creates a trampoline
> if there isn't one already, but if there already is one, it will modify
> it in-place.
> 
> I see the appeal of having this event in generic code; but I'm thinking
> you'll need the update even in arch code anyway, at which point it'd
> probably be easier to do all of this in arch code.

For x86, we use text_poke_bp for updates which already does text_poke events
via text_poke_bp_batch.

It might be reasonable to assume other architectures will also need to put
updates through a common text poker which will take care of text_poke events.

The V3 patch had it in arch code but Steven Rostedt asked why it couldn't be
in ftrace_update)trampoline, so I moved it.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ