From: Yonghong Song <yonghong.song@linux.dev>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Kernel Team <kernel-team@fb.com>,
Martin KaFai Lau <martin.lau@kernel.org>,
Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH bpf-next v12 4/7] bpf, x86: Support private stack in jit
Date: Tue, 12 Nov 2024 20:32:27 -0800 [thread overview]
Message-ID: <94e85972-ec2f-4231-bf0a-fcdda0ebde57@linux.dev> (raw)
In-Reply-To: <CAADnVQJ0Hzfn8rUtOPCUy+qFjMMQiyPFpLRr6fN+8gRzh9wsPw@mail.gmail.com>
On 11/12/24 5:13 PM, Alexei Starovoitov wrote:
> On Tue, Nov 12, 2024 at 8:41 AM Yonghong Song <yonghong.song@linux.dev> wrote:
>> +
>> +static void priv_stack_check_guard(void __percpu *priv_stack_ptr, int alloc_size,
>> + struct bpf_prog *prog)
>> +{
>> + int cpu, underflow_idx = (alloc_size - PRIV_STACK_GUARD_SZ) >> 3;
>> + u64 *stack_ptr;
>> +
>> + for_each_possible_cpu(cpu) {
>> + stack_ptr = per_cpu_ptr(priv_stack_ptr, cpu);
>> + if (stack_ptr[0] != PRIV_STACK_GUARD_VAL ||
>> + stack_ptr[underflow_idx] != PRIV_STACK_GUARD_VAL) {
>> + pr_err("BPF private stack overflow/underflow detected for prog %sx\n",
>> + bpf_get_prog_name(prog));
>> + break;
>> + }
>> + }
>> +}
> I was tempted to change pr_err() to WARN() to make sure this kinda bug
> is very obvious, but left it as-is.
> I think kasan-ing JITed load/stores and adding poison to guards
> will be a bigger win.
> The bpf prog/verifier bug will be spotted right away instead of
> later during jit_free.
Agree. I will work on this as a follow-up.
next prev parent reply other threads:[~2024-11-13 4:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-12 16:39 [PATCH bpf-next v12 0/7] bpf: Support private stack for bpf progs Yonghong Song
2024-11-12 16:39 ` [PATCH bpf-next v12 1/7] bpf: Find eligible subprogs for private stack support Yonghong Song
2024-11-12 16:39 ` [PATCH bpf-next v12 2/7] bpf: Enable private stack for eligible subprogs Yonghong Song
2024-11-12 16:39 ` [PATCH bpf-next v12 3/7] bpf, x86: Avoid repeated usage of bpf_prog->aux->stack_depth Yonghong Song
2024-11-12 16:39 ` [PATCH bpf-next v12 4/7] bpf, x86: Support private stack in jit Yonghong Song
2024-11-13 1:13 ` Alexei Starovoitov
2024-11-13 4:32 ` Yonghong Song [this message]
2024-11-12 16:39 ` [PATCH bpf-next v12 5/7] selftests/bpf: Add tracing prog private stack tests Yonghong Song
2024-11-12 16:39 ` [PATCH bpf-next v12 6/7] bpf: Support private stack for struct_ops progs Yonghong Song
2024-11-12 16:39 ` [PATCH bpf-next v12 7/7] selftests/bpf: Add struct_ops prog private stack tests Yonghong Song
2024-11-13 1:20 ` [PATCH bpf-next v12 0/7] bpf: Support private stack for bpf progs patchwork-bot+netdevbpf
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=94e85972-ec2f-4231-bf0a-fcdda0ebde57@linux.dev \
--to=yonghong.song@linux.dev \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=martin.lau@kernel.org \
--cc=tj@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.