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] [day] [month] [year] [list]
Message-Id: <20200910094923.42a09f8f75f84cdbeac743c8@kernel.org>
Date:   Thu, 10 Sep 2020 09:49:23 +0900
From:   Masami Hiramatsu <mhiramat@...nel.org>
To:     Masami Hiramatsu <mhiramat@...nel.org>
Cc:     Steven Rostedt <rostedt@...dmis.org>,
        Jonathan Corbet <corbet@....net>, linux-kernel@...r.kernel.org,
        linux-doc@...r.kernel.org, Randy Dunlap <rdunlap@...radead.org>,
        Ingo Molnar <mingo@...nel.org>, Oleg Nesterov <oleg@...hat.com>
Subject: Re: [PATCH v2 4/6] tracing/kprobes: Support perf-style return probe

On Tue,  1 Sep 2020 16:57:10 +0900
Masami Hiramatsu <mhiramat@...nel.org> wrote:

> Support perf-style return probe ("SYMBOL%return") in kprobe events.
> This will allow boot-time tracing user to define a return probe event.
> 

Hmm, I think I should add this for uprobe event too.
I'll update the series.

Thank you,

> Signed-off-by: Masami Hiramatsu <mhiramat@...nel.org>
> ---
>  kernel/trace/trace_kprobe.c |   21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> index aefb6065b508..391361b67c8f 100644
> --- a/kernel/trace/trace_kprobe.c
> +++ b/kernel/trace/trace_kprobe.c
> @@ -709,6 +709,18 @@ static inline void sanitize_event_name(char *name)
>  			*name = '_';
>  }
>  
> +static inline bool split_return_suffix(char *symbol)
> +{
> +	char *p = strchr(symbol, '%');
> +
> +	if (p && !strcmp(p, "%return")) {
> +		*p = '\0';
> +		return true;
> +	}
> +
> +	return false;
> +}
> +
>  static int trace_kprobe_create(int argc, const char *argv[])
>  {
>  	/*
> @@ -717,6 +729,9 @@ static int trace_kprobe_create(int argc, const char *argv[])
>  	 *      p[:[GRP/]EVENT] [MOD:]KSYM[+OFFS]|KADDR [FETCHARGS]
>  	 *  - Add kretprobe:
>  	 *      r[MAXACTIVE][:[GRP/]EVENT] [MOD:]KSYM[+0] [FETCHARGS]
> +	 *    Or
> +	 *      p:[GRP/]EVENT] [MOD:]KSYM[+0]%return [FETCHARGS]
> +	 *
>  	 * Fetch args:
>  	 *  $retval	: fetch return value
>  	 *  $stack	: fetch stack address
> @@ -746,7 +761,6 @@ static int trace_kprobe_create(int argc, const char *argv[])
>  	switch (argv[0][0]) {
>  	case 'r':
>  		is_return = true;
> -		flags |= TPARG_FL_RETURN;
>  		break;
>  	case 'p':
>  		break;
> @@ -804,12 +818,17 @@ static int trace_kprobe_create(int argc, const char *argv[])
>  		symbol = kstrdup(argv[1], GFP_KERNEL);
>  		if (!symbol)
>  			return -ENOMEM;
> +
> +		is_return = split_return_suffix(symbol) || is_return;
> +
>  		/* TODO: support .init module functions */
>  		ret = traceprobe_split_symbol_offset(symbol, &offset);
>  		if (ret || offset < 0 || offset > UINT_MAX) {
>  			trace_probe_log_err(0, BAD_PROBE_ADDR);
>  			goto parse_error;
>  		}
> +		if (is_return)
> +			flags |= TPARG_FL_RETURN;
>  		if (kprobe_on_func_entry(NULL, symbol, offset))
>  			flags |= TPARG_FL_FENTRY;
>  		if (offset && is_return && !(flags & TPARG_FL_FENTRY)) {
> 


-- 
Masami Hiramatsu <mhiramat@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ