RFC bpf: Add support to allocate user page
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest9 patches 5 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/9 | bpf: Add __srcptr kfunc argument suffixDocumentation/ kernel/ | +39 | 0 replies | |
| 2/9 | bpf: Add uprobe faultable user copy kfunckernel/ | +57 | 0 replies | |
| 3/9 | mm: Expose locked mprotect operationinclude/ mm/ | +18 | 2 replies | |
| 4/9 | bpf: Add kfuncs to allocate and seal user pageskernel/ | +127 | 0 replies | |
| 5/9 | selftests/bpf: Add __srcptr kfunc arguments testtools/ tools/ tools/ +2 more | +30 | 0 replies | |
| 6/9 | selftests/bpf: Add user page allocation testtools/ tools/ | +183 | 0 replies | |
| 7/9 | selftests/bpf: Add uprobe user page exec testtools/ tools/ | +80 | 0 replies | |
| 8/9 | selftests/bpf: Add faultable user page writes testtools/ tools/ | +32 | 0 replies | |
| 9/9 | selftests/bpf: Add user page failures testtools/ tools/ | +146 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RFC bpf-next 0/9] bpf: Add support to allocate user page
hi,
we have few use cases where having the ability to allocate normal or executable user space memory would help (like to replace function in live process or change environment variables)
They also need writes to user memory to handle page faults, while the existing bpf_probe_write_user() helper disables faults during the copy.
This patchset adds the following kfuncs for sleepable uprobe programs:
- long bpf_user_page_alloc(unsigned long nr_pages) allocate lazy anonymous pages in the current process
- int bpf_user_page_exec(unsigned long addr)
make a page readable and executable, provided it was allocated by bpf_user_page_alloc()
- int bpf_probe_write_user_faultable(void __user *unsafe_dst__ign, const void *src__srcptr, u32 src__sz) copy data to user memory while allowing page faults to resolve the destination mapping.
I'm not sure it's the best way how to do this, hence the RFC post.
thanks for comments,
jirka
---
Jiri Olsa (9):
bpf: Add __srcptr kfunc argument suffix
bpf: Add uprobe faultable user copy kfunc
mm: Expose locked mprotect operation
bpf: Add kfuncs to allocate and seal user pages selftests/bpf: Add __srcptr kfunc arguments test selftests/bpf: Add user page allocation test selftests/bpf: Add uprobe user page exec test selftests/bpf: Add faultable user page writes test selftests/bpf: Add user page failures test
Documentation/bpf/kfuncs.rst | 23 ++++ include/linux/mm.h | 3 + kernel/bpf/helpers.c | 178 +++++++++++++++++++++++++++ kernel/bpf/verifier.c | 18 ++- mm/mprotect.c | 20 ++- tools/testing/selftests/bpf/prog_tests/kfunc_call.c | 2 + tools/testing/selftests/bpf/prog_tests/user_page.c | 346 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/testing/selftests/bpf/progs/kfunc_call_fail.c | 10 ++ tools/testing/selftests/bpf/progs/kfunc_call_test.c | 12 ++ tools/testing/selftests/bpf/progs/user_page.c | 61 +++++++++ tools/testing/selftests/bpf/test_kmods/bpf_testmod.c | 5 + tools/testing/selftests/bpf/test_kmods/bpf_testmod_kfunc.h | 1 + 12 files changed, 672 insertions(+), 7 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/user_page.c create mode 100644 tools/testing/selftests/bpf/progs/user_page.c