Re: yet another approach Was: [PATCH bpf-next v3 4/5] bpf, x86: Add jit support for private stack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 8, 2024 at 3:10 PM Alexei Starovoitov
<alexei.starovoitov@xxxxxxxxx> wrote:
>
> We need to scrap this idea.
> Let's go back to push/pop r11 around calls :(

I didn't give up :)

Here is a new idea that seems to work:

[  131.472066]  dump_stack_lvl+0x53/0x70
[  131.472066]  bpf_task_storage_get+0x3e/0x2f0
[  131.472066]  ? bpf_task_storage_get+0x231/0x2f0
[  131.472066]  bpf_prog_ed7a5f33cc9fefab_foo+0x30/0x32
[  131.472066]  bpf_prog_8c4f9bc79da6c27e_socket_post_create+0x68/0x6d
...
[  131.417145]  dump_stack_lvl+0x53/0x70
[  131.417145]  bpf_task_storage_get+0x3e/0x2f0
[  131.417145]  ? selinux_netlbl_socket_post_create+0xab/0x150
[  131.417145]  bpf_prog_8c4f9bc79da6c27e_socket_post_create+0x60/0x6d


The stack dump works fine out of main prog and out of subprog.

The key difference it to pretend to have stack_depth=0,
so there is no adjustment to %rsp,
but point %rbp to per-cpu private stack and grow it _up_.

For the main prog %rbp points to the bottom of priv stack
plus stack_depth it needs,
so all bpf insns that do r10-off access the bottom of that priv stack.
When subprog is called it does 'add %rbp, its_stack_depth' and
in turn it's using memory above the bottom of the priv stack.

That seems to work, but exceptions and tailcalls are broken.
I ran out of time today to debug.
Pls see the attached patch.

Attachment: 0001-bpf-Private-stack-via-rbp.patch
Description: Binary data


[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux