Netdev List
 help / color / mirror / Atom feed
From: Song Liu <songliubraving@fb.com>
To: Martin Lau <kafai@fb.com>
Cc: "bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <Kernel-team@fb.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH bpf-next 2/3] bpf: Allow using bpf_sk_storage in FENTRY/FEXIT/RAW_TP
Date: Sat, 7 Nov 2020 00:20:38 +0000	[thread overview]
Message-ID: <0394ED25-D8FB-4FA4-A021-98A403A248EA@fb.com> (raw)
In-Reply-To: <20201106231639.ipyrsxjj3jduw7f6@kafai-mbp.dhcp.thefacebook.com>



> On Nov 6, 2020, at 3:18 PM, Martin Lau <kafai@fb.com> wrote:
> 
> On Fri, Nov 06, 2020 at 02:59:14PM -0800, Song Liu wrote:
>> 
>> 
>>> On Nov 6, 2020, at 2:08 PM, Martin KaFai Lau <kafai@fb.com> wrote:
>>> 

[...]

>>> +static bool bpf_sk_storage_tracing_allowed(const struct bpf_prog *prog)
>>> +{
>>> +	const struct btf *btf_vmlinux;
>>> +	const struct btf_type *t;
>>> +	const char *tname;
>>> +	u32 btf_id;
>>> +
>>> +	if (prog->aux->dst_prog)
>>> +		return false;
>>> +
>>> +	/* Ensure the tracing program is not tracing
>>> +	 * any *sk_storage*() function and also
>>> +	 * use the bpf_sk_storage_(get|delete) helper.
>>> +	 */
>>> +	switch (prog->expected_attach_type) {
>>> +	case BPF_TRACE_RAW_TP:
>>> +		/* bpf_sk_storage has no trace point */
>>> +		return true;
>>> +	case BPF_TRACE_FENTRY:
>>> +	case BPF_TRACE_FEXIT:
>>> +		btf_vmlinux = bpf_get_btf_vmlinux();
>>> +		btf_id = prog->aux->attach_btf_id;
>>> +		t = btf_type_by_id(btf_vmlinux, btf_id);
>> 
>> What happens to fentry/fexit attach to other BPF programs? I guess
>> we should check for t == NULL?
> It does not support tracing BPF program and using bpf_sk_storage
> at the same time for now, so there is a "if (prog->aux->dst_prog)" test earlier.
> It could be extended to do it later as a follow up.
> I missed to mention that in the commit message.  
> 
> "t" should not be NULL here when tracing a kernel function.
> The verifier should have already checked it and ensured "t" is a FUNC.

Ah, I missed the dst_prog check. Thanks for the explanation. 

Acked-by: Song Liu <songliubraving@fb.com>


  reply	other threads:[~2020-11-07  0:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-06 22:07 [PATCH bpf-next 0/3] bpf: Enable bpf_sk_storage for FENTRY/FEXIT/RAW_TP Martin KaFai Lau
2020-11-06 22:07 ` [PATCH bpf-next 1/3] bpf: Folding omem_charge() into sk_storage_charge() Martin KaFai Lau
2020-11-06 22:44   ` Song Liu
2020-11-06 22:08 ` [PATCH bpf-next 2/3] bpf: Allow using bpf_sk_storage in FENTRY/FEXIT/RAW_TP Martin KaFai Lau
2020-11-06 22:59   ` Song Liu
2020-11-06 23:18     ` Martin KaFai Lau
2020-11-07  0:20       ` Song Liu [this message]
2020-11-07  1:14   ` Andrii Nakryiko
2020-11-07  1:52     ` Martin KaFai Lau
2020-11-09 18:09       ` Andrii Nakryiko
2020-11-09 20:32         ` John Fastabend
2020-11-10 22:01           ` KP Singh
2020-11-10 23:43             ` Martin KaFai Lau
2020-11-10 23:53               ` Andrii Nakryiko
2020-11-11  0:07                 ` Martin KaFai Lau
2020-11-11  0:17                   ` Andrii Nakryiko
2020-11-11  0:20                     ` Martin KaFai Lau
2020-11-06 22:08 ` [PATCH bpf-next 3/3] bpf: selftest: Use " Martin KaFai Lau

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=0394ED25-D8FB-4FA4-A021-98A403A248EA@fb.com \
    --to=songliubraving@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=netdev@vger.kernel.org \
    /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