From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754346AbbFJOpD (ORCPT ); Wed, 10 Jun 2015 10:45:03 -0400 Received: from mail.kernel.org ([198.145.29.136]:52446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751308AbbFJOo5 (ORCPT ); Wed, 10 Jun 2015 10:44:57 -0400 Date: Wed, 10 Jun 2015 11:44:52 -0300 From: Arnaldo Carvalho de Melo To: Li Zhang 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. Message-ID: <20150610144452.GM3136@kernel.org> References: <1433905293-16176-1-git-send-email-zhlcindy@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433905293-16176-1-git-send-email-zhlcindy@linux.vnet.ibm.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. - Arnaldo > This patch is to check access permission when reading kcore file. > > Signed-off-by: Li Zhang > --- > 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