mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: bot+bpf-ci@kernel.org
To: tasos.papagiannnis@gmail.com,bpf@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,linux-mm@kvack.org,linux-fsdevel@vger.kernel.org,viro@zeniv.linux.org.uk,brauner@kernel.org,akpm@linux-foundation.org,david@kernel.org,ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,eddyz87@gmail.com,memxor@gmail.com,kpsingh@kernel.org,matt@bobrowski.net,song@kernel.org,utilityemal77@gmail.com,tasos.papagiannnis@gmail.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v3 4/7] bpf: Allow reads through trusted-or-null BTF pointers
Date: Mon, 31 Aug 2026 10:43:19 +0000 (UTC)	[thread overview]
Message-ID: <5a28fcf46a2cf6d16bbfc7b814c323b846c8774111393ad02c1b30cac2e66493@mail.kernel.org> (raw)
In-Reply-To: <20260831092305.42062-5-tasos.papagiannnis@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2367 bytes --]

> bpf: Allow reads through trusted-or-null BTF pointers
>
> Currently, a trusted-or-null pointer
> (i.e. PTR_TO_BTF_ID|PTR_TRUSTED|PTR_MAYBE_NULL) has to be checked
> for NULL before it can be dereferenced. Marking a field from
> PTR_TO_BTF_ID typing to trusted-or-null can reject programs that
> previously dereferenced the pointer directly. This is useful as we
> need to mark new fields as trusted in order to pass those as arguments
> to kfuncs.
>
> This patch adds support to dereference pointers marked as
> PTR_TO_BTF_ID|PTR_TRUSTED|PTR_MAYBE_NULL without the need for a NULL
> check. We define that those pointers can fault on dereference, so
> reads need to happen through BPF_PROBE_MEM. If the dereferenced pointer
> is another BTF pointer, we clear trusted flags and mark the result as
> PTR_UNTRUSTED.
>
> This applies only to reads. Other cases still require an explicit NULL
> check. After such a check, the pointer retains PTR_TRUSTED and can be
> used normally.
>
> To summarise, before that patch, reads to PTR_TO_BTF_ID|PTR_UNTRUSTED
> are allowed through BPF_PROBE_MEM and reads to
> PTR_TO_BTF_ID|PTR_TRUSTED are normal loads. This patch allows
> PTR_TO_BTF_ID|PTR_TRUSTED|PTR_MAYBE_NULL to happen through
> BPF_PROBE_MEM.
>
> The unchecked read path has two consequences:
>
> 1. It uses BPF_PROBE_MEM, which is slower than a normal load. An
>    explicit NULL check refines the pointer to PTR_TRUSTED and allows a
>    normal load.
>
> 2. A faulting read returns zero, which is indistinguishable from a
>    legitimately zero-valued field. Programs that need to distinguish
>    those cases must check the pointer before reading the field.
>
> The next patch updates current tests and also introduces more checks to
> ensure this change does not break anything.
>
> Signed-off-by: Anastasios Papagiannis <tasos.papagiannnis@gmail.com>

This isn't a bug, but could the changelog use the imperative mood here
("Allow reads through PTR_TO_BTF_ID|PTR_TRUSTED|PTR_MAYBE_NULL without a
NULL check") and drop the "To summarise" paragraph, since the preceding
paragraph already states the before/after behaviour?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/33379004067

  reply	other threads:[~2026-08-31 10:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31  9:22 [PATCH bpf-next v3 0/7] bpf: Add user memory access kfuncs for mm_struct Anastasios Papagiannis
2026-08-31  9:22 ` [PATCH bpf-next v3 1/7] mm: Add copy_remote_mm_str() Anastasios Papagiannis
2026-08-31  9:23 ` [PATCH bpf-next v3 2/7] bpf: Add user memory access kfuncs for mm_struct Anastasios Papagiannis
2026-08-31 10:43   ` bot+bpf-ci
2026-08-31  9:23 ` [PATCH bpf-next v3 3/7] exec: Clear bprm->mm before dropping its reference Anastasios Papagiannis
2026-08-31 10:30   ` bot+bpf-ci
2026-09-01  3:19   ` sun jian
2026-09-01  8:56   ` sun jian
2026-08-31  9:23 ` [PATCH bpf-next v3 4/7] bpf: Allow reads through trusted-or-null BTF pointers Anastasios Papagiannis
2026-08-31 10:43   ` bot+bpf-ci [this message]
2026-08-31  9:23 ` [PATCH bpf-next v3 5/7] selftests/bpf: Cover trusted-or-null BTF pointer reads Anastasios Papagiannis
2026-08-31 10:43   ` bot+bpf-ci
2026-08-31  9:23 ` [PATCH bpf-next v3 6/7] bpf: Mark linux_binprm->mm as trusted-or-null Anastasios Papagiannis
2026-08-31 10:43   ` bot+bpf-ci
2026-09-01  3:50   ` sun jian
2026-08-31  9:23 ` [PATCH bpf-next v3 7/7] selftests/bpf: Test mm_struct user memory kfuncs with linux_binprm Anastasios Papagiannis

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=5a28fcf46a2cf6d16bbfc7b814c323b846c8774111393ad02c1b30cac2e66493@mail.kernel.org \
    --to=bot+bpf-ci@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brauner@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=david@kernel.org \
    --cc=eddyz87@gmail.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=kpsingh@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=martin.lau@kernel.org \
    --cc=mason@kernel.org \
    --cc=matt@bobrowski.net \
    --cc=memxor@gmail.com \
    --cc=song@kernel.org \
    --cc=tasos.papagiannnis@gmail.com \
    --cc=utilityemal77@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=yonghong.song@linux.dev \
    /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

all inboxes | Powered by JetHome®