BPF List
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	bpf@vger.kernel.org, linux-mm@kvack.org,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Lorenzo Stoakes <ljs@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	Federico Di Pierro <nierro92@gmail.com>
Subject: Re: [PATCH bpf-next 2/8] bpf: Add user memory kfuncs
Date: Fri, 30 Oct 2026 12:08:47 +0100	[thread overview]
Message-ID: <auR6v7rEVTlEALJ-@krava> (raw)
In-Reply-To: <CAEf4BzaAbWxWfjn4u8vieaWzhjE+Af+KV8sLFH9kfgGT5PtAGw@mail.gmail.com>

On Thu, Oct 29, 2026 at 03:00:50PM -0700, Andrii Nakryiko wrote:
> On Thu, Oct 29, 2026 at 2:26 PM Jiri Olsa <jolsa@kernel.org> wrote:
> >
> > Add sleepable kfuncs to copy data into a task's address space and to map
> > or unmap private anonymous memory in the current process.
> >
> > Require a usable user mm for mmap and munmap. Register the kfuncs for
> > KPROBE programs and gate them on CAP_SYS_ADMIN BPF token capability and
> > the BPF_WRITE_USER lockdown check.
> >
> > Use FOLL_FORCE | FOLL_WRITE for task memory copies and return -EFAULT
> > when a copy is incomplete.
> >
> > Rename the syscall info-copy helper to bpf_copy_to_user_buf to avoid
> > the name collision.
> >
> > Assisted-by: Codex:GPT-6
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> >  kernel/bpf/helpers.c | 102 +++++++++++++++++++++++++++++++++++++++++++
> >  kernel/bpf/syscall.c |  10 ++---
> >  2 files changed, 107 insertions(+), 5 deletions(-)
> >
> 
> [...]
> 
> > +/**
> > + * bpf_user_mmap() - Map private anonymous memory into the current process
> > + * @len:  Length of the mapping
> > + * @prot: PROT_* flags of mmap(2), including PROT_EXEC
> > + *
> > + * This maps memory by calling vm_mmap() directly. It does not invoke the
> > + * mmap(2) syscall, so seccomp filters do not mediate this mapping.
> > + *
> > + * Return: The address of the mapping on success, -EPERM if the caller has no
> > + * user mm, or an unsigned-long encoded negative error code, as returned by
> > + * vm_mmap().
> > + */
> > +__bpf_kfunc unsigned long bpf_user_mmap(unsigned long len, unsigned long prot)
> 
> bpf_user_anon_mmap(), so we can conceivably have a more generic
> bpf_user_mmap(struct file*, ...) in the future?

yes, will change

thanks,
jirka

  reply	other threads:[~2026-10-30 11:08 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 21:25 [PATCH bpf-next 0/8] bpf: Add user memory kfuncs Jiri Olsa
2026-10-29 21:25 ` [PATCH bpf-next 1/8] bpf: Add __srcptr kfunc argument suffix Jiri Olsa
2026-10-29 21:49   ` Andrii Nakryiko
2026-10-30 10:50     ` Jiri Olsa
2026-10-30 16:26   ` Alexei Starovoitov
2026-10-29 21:25 ` [PATCH bpf-next 2/8] bpf: Add user memory kfuncs Jiri Olsa
2026-10-29 22:00   ` Andrii Nakryiko
2026-10-30 11:08     ` Jiri Olsa [this message]
2026-10-29 22:12   ` bot+bpf-ci
2026-10-30 13:07     ` Jiri Olsa
2026-10-30 13:08     ` Jiri Olsa
2026-10-29 21:25 ` [PATCH bpf-next 3/8] selftests/bpf: Add get_procmap_info helper Jiri Olsa
2026-10-29 21:25 ` [PATCH bpf-next 4/8] selftests/bpf: Test __srcptr kfunc arguments Jiri Olsa
2026-10-29 21:25 ` [PATCH bpf-next 5/8] selftests/bpf: Test user memory mmap kfuncs Jiri Olsa
2026-10-29 21:59   ` bot+bpf-ci
2026-10-30 13:08     ` Jiri Olsa
2026-10-29 21:25 ` [PATCH bpf-next 6/8] selftests/bpf: Test user memory page exec Jiri Olsa
2026-10-29 21:25 ` [PATCH bpf-next 7/8] selftests/bpf: Test bpf_copy_to_user kfunc Jiri Olsa
2026-10-29 21:25 ` [PATCH bpf-next 8/8] selftests/bpf: Test user memory kfunc errors Jiri Olsa
2026-10-29 21:59   ` bot+bpf-ci
2026-10-30 13:08     ` Jiri Olsa

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=auR6v7rEVTlEALJ-@krava \
    --to=olsajiri@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --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=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=memxor@gmail.com \
    --cc=nierro92@gmail.com \
    /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