From: Jiri Olsa <jolsa@kernel.org>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>
Cc: bpf@vger.kernel.org, Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
"Liam R. Howlett" <liam@infradead.org>,
Lorenzo Stoakes <ljs@kernel.org>,
linux-kselftest@vger.kernel.org, Shuah Khan <shuah@kernel.org>,
John Fastabend <john.fastabend@gmail.com>
Subject: [RFC bpf-next 0/9] bpf: Add support to allocate user page
Date: Wed, 21 Oct 2026 21:57:49 +0200 [thread overview]
Message-ID: <20261021195759.119421-1-jolsa@kernel.org> (raw)
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
next reply other threads:[~2026-10-21 19:58 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 19:57 Jiri Olsa [this message]
2026-10-21 19:57 ` [RFC bpf-next 1/9] bpf: Add __srcptr kfunc argument suffix Jiri Olsa
2026-10-21 19:57 ` [RFC bpf-next 2/9] bpf: Add uprobe faultable user copy kfunc Jiri Olsa
2026-10-21 20:30 ` bot+bpf-ci
2026-10-21 19:57 ` [RFC bpf-next 3/9] mm: Expose locked mprotect operation Jiri Olsa
2026-10-21 20:30 ` bot+bpf-ci
2026-10-22 10:25 ` Lorenzo Stoakes (ARM)
2026-10-22 19:39 ` Jiri Olsa
2026-10-21 19:57 ` [RFC bpf-next 4/9] bpf: Add kfuncs to allocate and seal user pages Jiri Olsa
2026-10-21 20:41 ` bot+bpf-ci
2026-10-21 19:57 ` [RFC bpf-next 5/9] selftests/bpf: Add __srcptr kfunc arguments test Jiri Olsa
2026-10-21 19:57 ` [RFC bpf-next 6/9] selftests/bpf: Add user page allocation test Jiri Olsa
2026-10-21 19:57 ` [RFC bpf-next 7/9] selftests/bpf: Add uprobe user page exec test Jiri Olsa
2026-10-21 19:57 ` [RFC bpf-next 8/9] selftests/bpf: Add faultable user page writes test Jiri Olsa
2026-10-21 19:57 ` [RFC bpf-next 9/9] selftests/bpf: Add user page failures test Jiri Olsa
2026-10-21 20:30 ` bot+bpf-ci
2026-10-21 21:53 ` [RFC bpf-next 0/9] bpf: Add support to allocate user page Alexei Starovoitov
2026-10-22 10:01 ` Jiri Olsa
2026-10-22 10:27 ` Lorenzo Stoakes (ARM)
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=20261021195759.119421-1-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=liam@infradead.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=memxor@gmail.com \
--cc=shuah@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