From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Kicinski Subject: Re: [PATCH bpf v3] tools/bpftool: fix a bug in bpftool perf Date: Tue, 12 Jun 2018 11:15:08 -0700 Message-ID: <20180612111508.5c85a54c@cakuba.netronome.com> References: <20180612053548.901931-1-yhs@fb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: , , , To: Yonghong Song Return-path: Received: from mail-pf0-f193.google.com ([209.85.192.193]:46724 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754028AbeFLSPM (ORCPT ); Tue, 12 Jun 2018 14:15:12 -0400 Received: by mail-pf0-f193.google.com with SMTP id q1-v6so12514515pff.13 for ; Tue, 12 Jun 2018 11:15:12 -0700 (PDT) In-Reply-To: <20180612053548.901931-1-yhs@fb.com> Sender: netdev-owner@vger.kernel.org List-ID: On Mon, 11 Jun 2018 22:35:48 -0700, Yonghong Song wrote: > Commit b04df400c302 ("tools/bpftool: add perf subcommand") > introduced bpftool subcommand perf to query bpf program > kuprobe and tracepoint attachments. > > The perf subcommand will first test whether bpf subcommand > BPF_TASK_FD_QUERY is supported in kernel or not. It does it > by opening a file with argv[0] and feeds the file descriptor > and current task pid to the kernel for querying. > > Such an approach won't work if the argv[0] cannot be opened > successfully in the current directory. This is especially > true when bpftool is accessible through PATH env variable. > The error below reflects the open failure for file argv[0] > at home directory. > > [yhs@localhost ~]$ which bpftool > /usr/local/sbin/bpftool > [yhs@localhost ~]$ bpftool perf > Error: perf_query_support: No such file or directory > > To fix the issue, let us open root directory ("/") > which exists in every linux system. With the fix, the > error message will correctly reflect the permission issue. > > [yhs@localhost ~]$ which bpftool > /usr/local/sbin/bpftool > [yhs@localhost ~]$ bpftool perf > Error: perf_query_support: Operation not permitted > HINT: non root or kernel doesn't support TASK_FD_QUERY > > Fixes: b04df400c302 ("tools/bpftool: add perf subcommand") > Reported-by: Alexei Starovoitov > Signed-off-by: Yonghong Song Reviewed-by: Jakub Kicinski FWIW :)