From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757808AbbFQGKm (ORCPT ); Wed, 17 Jun 2015 02:10:42 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:47895 "EHLO e34.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753627AbbFQGKf (ORCPT ); Wed, 17 Jun 2015 02:10:35 -0400 X-Helo: d03dlp03.boulder.ibm.com X-MailFrom: sukadev@linux.vnet.ibm.com X-RcptTo: linux-kernel@vger.kernel.org Date: Tue, 16 Jun 2015 23:09:46 -0700 From: Sukadev Bhattiprolu To: Li Zhang Cc: acme@kernel.org, mingo@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/1] perf tools: Check access permission when reading /proc/kcore file. Message-ID: <20150617060946.GA18162@us.ibm.com> References: <1434350500-32342-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: <1434350500-32342-1-git-send-email-zhlcindy@linux.vnet.ibm.com> X-Operating-System: Linux 2.0.32 on an i486 User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15061706-0017-0000-0000-00000BB710BE Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Li Zhang [zhlcindy@linux.vnet.ibm.com] wrote: | 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. | | This patch is to check access permission when reading kcore file. | | Signed-off-by: Li Zhang | --- | v2 -> v1: | * Report one useful message to users about the access permision, | then go back to the tools. Suggested by Arnaldo Carvalho de Melo. | | tools/perf/util/symbol.c | 4 ++++ | 1 file changed, 4 insertions(+) | | diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c | index 201f6c4c..1bcd8dc 100644 | --- a/tools/perf/util/symbol.c | +++ b/tools/perf/util/symbol.c | @@ -1125,6 +1125,10 @@ 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)) | + ui__warning("Insufficient permission to access %s.\n", | + kcore_filename); | + Couple of comments. For consistency with rest of the file, use pr_warning() or pr_err(). Also, we could drop the access() call and report the error when open() fails below? | fd = open(kcore_filename, O_RDONLY); | if (fd < 0) | return -EINVAL; Further, if user specifies the file with --kallsyms and we are not able to read it, we should treat it as a fatal error and exit - this would be easer when parsing command line args. If user did not specify the option and we are proactively trying to use /proc/kcore, we should not treat errors as fatal? i.e report a warning message and continue without symbols? | -- | 2.1.0