BPF List
 help / color / mirror / Atom feed
From: Song Liu <songliubraving@meta.com>
To: Jiri Olsa <olsajiri@gmail.com>
Cc: Song Liu <songliubraving@meta.com>, Song Liu <song@kernel.org>,
	bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <martin.lau@kernel.org>,
	Kernel Team <kernel-team@meta.com>,
	Ilya Leoshkevich <iii@linux.ibm.com>
Subject: Re: [PATCH v4 bpf-next 6/7] bpf: Use arch_bpf_trampoline_size
Date: Tue, 24 Oct 2023 22:16:14 +0000	[thread overview]
Message-ID: <CAB927C7-5EED-4A5F-B7C7-847DA99B46EA@fb.com> (raw)
In-Reply-To: <ZTg3i4FeZQnfTVC7@krava>



> On Oct 24, 2023, at 2:30 PM, Jiri Olsa <olsajiri@gmail.com> wrote:
> 
> On Tue, Oct 24, 2023 at 09:08:32PM +0000, Song Liu wrote:
> 
> SNIP
> 
>>>> @@ -349,7 +349,7 @@ static void bpf_tramp_image_put(struct bpf_tramp_image *im)
>>>> call_rcu_tasks_trace(&im->rcu, __bpf_tramp_image_put_rcu_tasks);
>>>> }
>>>> 
>>>> -static struct bpf_tramp_image *bpf_tramp_image_alloc(u64 key)
>>>> +static struct bpf_tramp_image *bpf_tramp_image_alloc(u64 key, int size)
>>>> {
>>>> struct bpf_tramp_image *im;
>>>> struct bpf_ksym *ksym;
>>>> @@ -360,12 +360,13 @@ static struct bpf_tramp_image *bpf_tramp_image_alloc(u64 key)
>>>> if (!im)
>>>> goto out;
>>>> 
>>>> - err = bpf_jit_charge_modmem(PAGE_SIZE);
>>>> + err = bpf_jit_charge_modmem(size);
>>>> if (err)
>>>> goto out_free_im;
>>>> + im->size = size;
>>>> 
>>>> err = -ENOMEM;
>>>> - im->image = image = arch_alloc_bpf_trampoline(PAGE_SIZE);
>>>> + im->image = image = arch_alloc_bpf_trampoline(size);
>>>> if (!image)
>>>> goto out_uncharge;
>>>> 
>>> 
>>> hi,
>>> there's call in here to add the image symbol
>>> 
>>> bpf_image_ksym_add(image, ksym);
>>> 
>>> which sets:
>>> 
>>> ksym->end = ksym->start + PAGE_SIZE;
>>> 
>>> we should set it to 'ksym->start + size' now
>> 
>> Great catch! Fixing this in v5. 
>> 
>>> 
>>> and I think that can probably screw up the bpf_prog_ksym_find
>>> and it might be the reason why I'm getting now the crash below
>> 
>> How easy is it to trigger the crash?
> 
> I hit that by running whole test_progs easily.. I'm assuming it's the
> exceptions test case, but I could not trigger it just with '-t exceptions'
> 
> attaching the .config


I can reproduce it with: 
 
    ./test_progs -j   -t except,fentry,fexit,tcp

and fixing ksym fixes it. 

I will send v5 with the fix. 

Thanks,
Song



  reply	other threads:[~2023-10-24 22:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-18 18:03 [PATCH v4 bpf-next 0/7] Allocate bpf trampoline on bpf_prog_pack Song Liu
2023-10-18 18:03 ` [PATCH v4 bpf-next 1/7] bpf: Let bpf_prog_pack_free handle any pointer Song Liu
2023-10-18 18:03 ` [PATCH v4 bpf-next 2/7] bpf: Adjust argument names of arch_prepare_bpf_trampoline() Song Liu
2023-10-18 18:03 ` [PATCH v4 bpf-next 3/7] bpf: Add helpers for trampoline image management Song Liu
2023-10-24 14:45   ` Daniel Borkmann
2023-10-24 15:45     ` Song Liu
2023-10-18 18:03 ` [PATCH v4 bpf-next 4/7] bpf, x86: Adjust arch_prepare_bpf_trampoline return value Song Liu
2023-10-18 18:03 ` [PATCH v4 bpf-next 5/7] bpf: Add arch_bpf_trampoline_size() Song Liu
2023-10-24 14:50   ` Daniel Borkmann
2023-10-18 18:03 ` [PATCH v4 bpf-next 6/7] bpf: Use arch_bpf_trampoline_size Song Liu
2023-10-24 21:01   ` Jiri Olsa
2023-10-24 21:08     ` Song Liu
2023-10-24 21:30       ` Jiri Olsa
2023-10-24 22:16         ` Song Liu [this message]
2023-10-18 18:03 ` [PATCH v4 bpf-next 7/7] x86, bpf: Use bpf_prog_pack for bpf trampoline Song Liu

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=CAB927C7-5EED-4A5F-B7C7-847DA99B46EA@fb.com \
    --to=songliubraving@meta.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=iii@linux.ibm.com \
    --cc=kernel-team@meta.com \
    --cc=martin.lau@kernel.org \
    --cc=olsajiri@gmail.com \
    --cc=song@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