From: Daniel Borkmann <daniel@iogearbox.net>
To: Song Liu <songliubraving@fb.com>, netdev@vger.kernel.org
Cc: kernel-team@fb.com, ast@kernel.org, sandipan@linux.vnet.ibm.com
Subject: Re: [PATCH bpf 2/3] bpf: show real jited address in bpf_prog_info->jited_ksyms
Date: Fri, 2 Nov 2018 11:19:40 +0100 [thread overview]
Message-ID: <a35ece7a-d958-dbe3-4f03-6fe7eab42e06@iogearbox.net> (raw)
In-Reply-To: <e779db0e-7933-c11b-5068-d919897d15ec@iogearbox.net>
On 11/02/2018 11:09 AM, Daniel Borkmann wrote:
> On 11/01/2018 08:00 AM, Song Liu wrote:
>> Currently, jited_ksyms in bpf_prog_info shows page addresses of jited
>> bpf program. This is not ideal for detailed profiling (find hot
>> instructions from stack traces). This patch replaces the page address
>> with real prog start address.
>>
>> Signed-off-by: Song Liu <songliubraving@fb.com>
>> ---
>> kernel/bpf/syscall.c | 1 -
>> 1 file changed, 1 deletion(-)
>>
>> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
>> index ccb93277aae2..34a9eef5992c 100644
>> --- a/kernel/bpf/syscall.c
>> +++ b/kernel/bpf/syscall.c
>> @@ -2172,7 +2172,6 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
>> user_ksyms = u64_to_user_ptr(info.jited_ksyms);
>> for (i = 0; i < ulen; i++) {
>> ksym_addr = (ulong) prog->aux->func[i]->bpf_func;
>> - ksym_addr &= PAGE_MASK;
>
> Note that the masking was done on purpose here and in patch 1/3 in order to
> not expose randomized start address to kallsyms at least. I suppose it's
> okay to change it here and for kallsyms given bpf_prog_get_info_by_fd() dump
> is for root only, and in each of the two cases we additionally apply
> kallsyms_show_value() logic, so for unpriv this is zeroed out plus only root
> loaded programs are added under kallsyms (capable(CAP_SYS_ADMIN)) anyway.
(Btw, something like above should have been in changelog to provide some more
historical context of why we used to do it like that and explaining why it is
okay to change it this way.)
>> if (put_user((u64) ksym_addr, &user_ksyms[i]))
>> return -EFAULT;
>> }
>>
>
next prev parent reply other threads:[~2018-11-02 19:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-01 7:00 [PATCH bpf 0/3] show more accurrate bpf program address Song Liu
2018-11-01 7:00 ` [PATCH bpf 1/3] bpf: show real jited prog address in /proc/kallsyms Song Liu
2018-11-01 7:00 ` [PATCH bpf 2/3] bpf: show real jited address in bpf_prog_info->jited_ksyms Song Liu
2018-11-02 10:09 ` Daniel Borkmann
2018-11-02 10:19 ` Daniel Borkmann [this message]
2018-11-02 16:07 ` Song Liu
2018-11-01 7:00 ` [PATCH bpf 3/3] bpf: show main program " Song Liu
2018-11-02 9:57 ` Daniel Borkmann
2018-11-01 23:15 ` [PATCH bpf 0/3] show more accurrate bpf program address Alexei Starovoitov
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=a35ece7a-d958-dbe3-4f03-6fe7eab42e06@iogearbox.net \
--to=daniel@iogearbox.net \
--cc=ast@kernel.org \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
--cc=sandipan@linux.vnet.ibm.com \
--cc=songliubraving@fb.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox