bpf: report arena faults to BPF streams
Status from this message: This series was applied to bpf/bpf-next.git (master)
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v7 Latest6 patches 5 repliesApplied 6/6
- v65 patches 5 repliesSuperseded
- v54 patches 7 repliesSuperseded
Earlier versions · 4
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v4 | 3 patches | 18 replies | Superseded | |
| v3 | 3 patches | 1 reply | Superseded | |
| v2 | 3 patches | 0 replies | Superseded | |
| v1 | 3 patches | 9 replies | Superseded |
Changes in v7 from the cover letter
v6: https://lore.kernel.org/all/[email protected]/
- Added comments about the usage of arena_reg in x86 and arm64 jits. (Alexei)
- Used clear_lo32() for clearing the lower 32-bits of user_vm_start. (Alexei)
- Moved update of the old tests to use __stderr to a separate commit (Eduard)
- Used test__skip() in prog_tests/stream.c (Eduard)
- Start a sub-test for read / write
Patches in v7 All 6 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/6 | bpf: arm64: simplify exception table handlingarch/ | +3 | 0 replies | Applied |
| 2/6 | bpf: core: introduce main_prog_aux for stream accessinclude/ kernel/ kernel/ | +5 | 1 reply | Applied |
| 3/6 | bpf: Report arena faults to BPF stderrarch/ arch/ include/ +1 more | +176 | 0 replies | Applied |
| 4/6 | selftests: bpf: introduce __stderr and __stdouttools/ tools/ | +100 | 1 reply | Applied |
| 5/6 | selftests: bpf: use __stderr in stream error teststools/ tools/ | +17 | 1 reply | Applied |
| 6/6 | selftests/bpf: Add tests for arena fault reportingtools/ tools/ | +190 | 2 replies | Applied |
Reviews trailers per patch
All 6 patches have a Reviewed-by or Acked-by.
| Patch | Yonghong Song | Kumar Kartikeya Dwivedi | Xu Kuohai | Eduard Zingerman |
|---|---|---|---|---|
| 1/6 | A-b | A-b | A-b | |
| 2/6 | A-b | |||
| 3/6 | A-b | |||
| 4/6 | A-b | |||
| 5/6 | A-b | |||
| 6/6 | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.
Cover letter [PATCH bpf-next v7 0/6] bpf: report arena faults to BPF streams
Changes in v6->v7:
v6: https://lore.kernel.org/all/[email protected]/
- Added comments about the usage of arena_reg in x86 and arm64 jits. (Alexei)
- Used clear_lo32() for clearing the lower 32-bits of user_vm_start. (Alexei)
- Moved update of the old tests to use __stderr to a separate commit (Eduard)
- Used test__skip() in prog_tests/stream.c (Eduard)
- Start a sub-test for read / write
Changes in v5->v6:
v5: https://lore.kernel.org/all/[email protected]/
- Introduces __stderr and __stdout for easy testing of bpf streams (Eduard)
- Add more test cases for arena fault reporting (subprog and callback)
- Fix main_prog_aux usage and return main_prog from find_from_stack_cb (Kumar)
- Properly fix the build issue reported by kernel test robot
Changes in v4->v5:
v4: https://lore.kernel.org/all/[email protected]/
- Added patch 2 to introducing main_prog_aux for easier access to streams.
- Fixed bug in fault handlers when arena_reg == dst_reg
- Updated selftest to check test above edge case.
- Added comments about the usage of barrier_var() in code and commit message.
Changes in v3->v4:
v3: https://lore.kernel.org/all/[email protected]/
- Fixed a build issue when CONFIG_BPF_JIT=y and # CONFIG_BPF_SYSCALL is not set
Changes in v2->v3:
v2: https://lore.kernel.org/all/[email protected]/
- Improved the selftest to check the exact fault address
- Dropped BPF_NO_KFUNC_PROTOTYPES and bpf_arena_alloc/free_pages() usage
- Rebased on bpf-next/master
Changes in v1->v2:
v1: https://lore.kernel.org/all/[email protected]/
- Changed variable and mask names for consistency (Yonghong)
- Added Acked-by: Yonghong Song <[email protected]> on two patches
This set adds the support of reporting page faults inside arena to BPF stderr stream. The reported address is the one that a user would expect to see if they pass it to bpf_printk();
Here is an example output from the stderr stream and bpf_printk()
ERROR: Arena WRITE access at unmapped address 0xdeaddead0000
CPU: 9 UID: 0 PID: 502 Comm: test_progs Call trace: bpf_stream_stage_dump_stack+0xc0/0x150 bpf_prog_report_arena_violation+0x98/0xf0 ex_handler_bpf+0x5c/0x78 fixup_exception+0xf8/0x160 __do_kernel_fault+0x40/0x188 do_bad_area+0x70/0x88 do_translation_fault+0x54/0x98 do_mem_abort+0x4c/0xa8 el1_abort+0x44/0x70 el1h_64_sync_handler+0x50/0x108 el1h_64_sync+0x6c/0x70 bpf_prog_a64a9778d31b8e88_stream_arena_write_fault+0x84/0xc8 *(page) = 1; @ stream.c:100 bpf_prog_test_run_syscall+0x100/0x328 __sys_bpf+0x508/0xb98 __arm64_sys_bpf+0x2c/0x48 invoke_syscall+0x50/0x120 el0_svc_common.constprop.0+0x48/0xf8 do_el0_svc+0x28/0x40 el0_svc+0x48/0xf8 el0t_64_sync_handler+0xa0/0xe8 el0t_64_sync+0x198/0x1a0
Same address is printed by bpf_printk():
1389.078831: bpf_trace_printk: Read Address: 0xdeaddead0000
To make this possible, some extra metadata has to be passed to the bpf exception handler, so the bpf exception handling mechanism for both x86-64 and arm64 have been improved in this set.
The streams selftest has been updated to test this new feature.
Puranjay Mohan (6):
bpf: arm64: simplify exception table handling
bpf: core: introduce main_prog_aux for stream access
bpf: Report arena faults to BPF stderr
selftests: bpf: introduce __stderr and __stdout
selftests: bpf: use __stderr in stream error tests selftests/bpf: Add tests for arena fault reporting
arch/arm64/net/bpf_jit_comp.c | 85 +++++++--- arch/x86/net/bpf_jit_comp.c | 85 +++++++++- include/linux/bpf.h | 7 + kernel/bpf/arena.c | 30 ++++ kernel/bpf/core.c | 6 +- kernel/bpf/verifier.c | 1 + .../testing/selftests/bpf/prog_tests/stream.c | 131 ++++++--------- tools/testing/selftests/bpf/progs/bpf_misc.h | 10 ++ tools/testing/selftests/bpf/progs/stream.c | 158 ++++++++++++++++++ tools/testing/selftests/bpf/test_loader.c | 90 ++++++++++ 10 files changed, 491 insertions(+), 112 deletions(-)
Signature · 1 line
2.47.3