All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Zhang <zhlcindy@linux.vnet.ibm.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: mingo@redhat.com, sukadev@linux.vnet.ibm.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] perf tools: Check access permission when reading /proc/kcore file.
Date: Mon, 15 Jun 2015 10:24:31 +0800	[thread overview]
Message-ID: <557E375F.2000104@linux.vnet.ibm.com> (raw)
In-Reply-To: <20150610144452.GM3136@kernel.org>

On 2015年06月10日 22:44, Arnaldo Carvalho de Melo wrote:
> Em Wed, Jun 10, 2015 at 11:01:33AM +0800, Li Zhang escreveu:
>> When using command perf report --kallsyms=/proc/kallsyms with a non-root
>> user, symbols are resolved. Then select one symbol and annotate it, it
>> reports the error as the following:
>> Can't annotate __clear_user: No vmlinux file with build id xxx was found.
>>
>> The problem is caused by reading /proc/kcore without access permission.
>> It needs to change access permission to allow a specific user to read
>> /proc/kcore or use root to execute the perf command.
> But then only if the user tries it again, using -v to enable verbose
> mode is that the message will be presented, how about instead return
> -EPERM, or -errno, so that this error is propagated back and we
> eventually emit a more meaningful message to the user, such as:
>
>    "Insufficient permission to access %s.", kcore_filename
>
> Trying to check if that is possible by going to the dso__load_kcore()
> callers and on back to the tools.

This sounds much better. I will check whether it can deliver this 
message to user.

Thanks Li

>
> - Arnaldo
>
>> This patch is to check access permission when reading kcore file.
>>
>> Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
>> ---
>>   tools/perf/util/symbol.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
>> index 201f6c4c..8255556 100644
>> --- a/tools/perf/util/symbol.c
>> +++ b/tools/perf/util/symbol.c
>> @@ -1125,6 +1125,11 @@ static int dso__load_kcore(struct dso *dso, struct map *map,
>>   	md.type = map->type;
>>   	INIT_LIST_HEAD(&md.maps);
>>   
>> +	if (access(kcore_filename, R_OK)) {
>> +		pr_debug("Can't access file %s.\n", kcore_filename);
>> +		return -EINVAL;
>> +	}
>> +
>>   	fd = open(kcore_filename, O_RDONLY);
>>   	if (fd < 0)
>>   		return -EINVAL;
>> -- 
>> 2.1.0
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>


-- 

Li Zhang
IBM China Linux Technology Centre


      reply	other threads:[~2015-06-15  2:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1433905293-16176-1-git-send-email-zhlcindy@linux.vnet.ibm.com>
2015-06-10 14:44 ` [PATCH 1/1] perf tools: Check access permission when reading /proc/kcore file Arnaldo Carvalho de Melo
2015-06-15  2:24   ` Li Zhang [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=557E375F.2000104@linux.vnet.ibm.com \
    --to=zhlcindy@linux.vnet.ibm.com \
    --cc=acme@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=sukadev@linux.vnet.ibm.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.