BPF List
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@meta.com>
To: "Toke Høiland-Jørgensen" <toke@kernel.org>,
	"Yonghong Song" <yhs@fb.com>,
	bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	John Fastabend <john.fastabend@gmail.com>,
	kernel-team@fb.com, Martin KaFai Lau <martin.lau@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>
Subject: Re: [RFC PATCH bpf-next 0/3] bpf: Implement bpf_get_kern_btf_id() kfunc
Date: Tue, 15 Nov 2022 11:53:16 -0800	[thread overview]
Message-ID: <e0429016-ea8c-2ffa-698a-3a252eb4545a@meta.com> (raw)
In-Reply-To: <87edu4i3j7.fsf@toke.dk>



On 11/15/22 8:30 AM, Toke Høiland-Jørgensen wrote:
> Yonghong Song <yhs@fb.com> writes:
> 
>> Currenty, a non-tracing bpf program typically has a single 'context' argument
>> with predefined uapi struct type. Following these uapi struct, user is able
>> to access other fields defined in uapi header. Inside the kernel, the
>> user-seen 'context' argument is replaced with 'kernel context' (or 'kcontext'
>> in short) which can access more information than what uapi header provides.
>> To access other info not in uapi header, people typically do two things:
>>    (1). extend uapi to access more fields rooted from 'context'.
>>    (2). use bpf_probe_read_kernl() helper to read particular field based on
>>      kcontext.
>> Using (1) needs uapi change and using (2) makes code more complex since
>> direct memory access is not allowed.
>>
>> There are already a few instances trying to access more information from
>> kcontext:
>>    (1). trying to access some fields from perf_event kcontext.
>>    (2). trying to access some fields from xdp kcontext.
>>
>> This patch set tried to allow direct memory access for kcontext fields
>> by introducing bpf_get_kern_btf_id() kfunc.
> 
> I think the general idea is neat. However, I'm a bit concerned that with
> this we're allowing networking BPF programs (like XDP) to walk more or
> less arbitrary kernel structures, which has thus far been something only
> tracing programs have had access to. So we probably require programs to
> have CAP_PERFMON to use this kfunc, no?

Make sense, since the kfunc is to enable tracing, yes CAP_PERFMON is
a good idea. I will make the change in the next revision.

> 
> -Toke

      reply	other threads:[~2022-11-15 19:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-14 16:23 [RFC PATCH bpf-next 0/3] bpf: Implement bpf_get_kern_btf_id() kfunc Yonghong Song
2022-11-14 16:23 ` [RFC PATCH bpf-next 1/3] bpf: Add support for kfunc set with generic btf_ids Yonghong Song
2022-11-14 16:23 ` [RFC PATCH bpf-next 2/3] bpf: Implement bpf_get_kern_btf_id() kfunc Yonghong Song
2022-11-15 19:43   ` Alexei Starovoitov
2022-11-15 20:05     ` Kumar Kartikeya Dwivedi
2022-11-15 20:26       ` Yonghong Song
2022-11-17 18:24         ` Kumar Kartikeya Dwivedi
2022-11-17 22:52           ` Yonghong Song
2022-11-17 23:01             ` Kumar Kartikeya Dwivedi
2022-11-17 23:13               ` Yonghong Song
2022-11-14 16:23 ` [RFC PATCH bpf-next 3/3] bpf: Add bpf_get_kern_btf_id() tests Yonghong Song
2022-11-15 16:30 ` [RFC PATCH bpf-next 0/3] bpf: Implement bpf_get_kern_btf_id() kfunc Toke Høiland-Jørgensen
2022-11-15 19:53   ` Yonghong Song [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=e0429016-ea8c-2ffa-698a-3a252eb4545a@meta.com \
    --to=yhs@meta.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=kernel-team@fb.com \
    --cc=martin.lau@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=toke@kernel.org \
    --cc=yhs@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