All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Jackie Liu <jackieliu2113@gmail.com>
Cc: linux-kernel@vger.kernel.org, Jackie Liu <liuyun01@kylinos.cn>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Namhyung Kim <namhyung@kernel.org>
Subject: Re: [PATCH] perf tools: check perf_event_paranoid and kptr_restrict on 'perf top'
Date: Tue, 23 Feb 2021 15:38:04 +0100	[thread overview]
Message-ID: <YDUTTKCScLhRZfYF@krava> (raw)
In-Reply-To: <20210223062440.15848-1-liuyun01@kylinos.cn>

On Tue, Feb 23, 2021 at 02:24:40PM +0800, Jackie Liu wrote:
> Perf top will segfault, we should give prompt information like perf
> record instead of crashing directly.
> 
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Cc: Jiri Olsa <jolsa@redhat.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
> ---
>  tools/perf/builtin-top.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
> index 3673c04d16b6..b257fadba3bd 100644
> --- a/tools/perf/builtin-top.c
> +++ b/tools/perf/builtin-top.c
> @@ -1239,6 +1239,14 @@ static int __cmd_top(struct perf_top *top)
>  			return ret;
>  	}
>  
> +	if (symbol_conf.kptr_restrict && !evlist__exclude_kernel(top->evlist)) {
> +		pr_warning(
> +"Kernel address maps (/proc/{kallsyms,modules}) are restricted.\n\n"
> +"Check /proc/sys/kernel/kptr_restrict and /proc/sys/kernel/perf_event_paranoid.\n\n"
> +"Kernel samples will not be resolved.\n");
> +		return -1;
> +	}
> +

hm, why not fix that crash by checking prog_addrs != NULL before using it

  perf_event__synthesize_one_bpf_prog:
  ...
     __u64 *prog_addrs = (__u64 *)(uintptr_t)(info->jited_ksyms);

it looks like we're already checking on kptr_restrict in
perf_event__process_sample and allow it on some level

jirka

>  	ret = callchain_param__setup_sample_type(&callchain_param);
>  	if (ret)
>  		return ret;
> -- 
> 2.25.1
> 


      reply	other threads:[~2021-02-23 14:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-23  6:24 [PATCH] perf tools: check perf_event_paranoid and kptr_restrict on 'perf top' Jackie Liu
2021-02-23 14:38 ` Jiri Olsa [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=YDUTTKCScLhRZfYF@krava \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jackieliu2113@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuyun01@kylinos.cn \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.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 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.