BPF List
 help / color / mirror / Atom feed
From: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
To: "Ning Ding" <dingning04@gmail.com>, <paulmck@kernel.org>
Cc: "Puranjay Mohan" <puranjay@kernel.org>, <bpf@vger.kernel.org>,
	"Puranjay Mohan" <puranjay12@gmail.com>
Subject: Re: [PATCH bpf-next v2 0/2] bpf: Invalidate RCU pointers after final spin unlock
Date: Thu, 06 Aug 2026 11:02:52 +0200	[thread overview]
Message-ID: <DKHQMSFIMQHR.1JSO9S9ZSZ5PY@gmail.com> (raw)
In-Reply-To: <CAJP4iuthyUKs5wYMpjGLyQKW8syiHm6pub+9rMMo7wsw-w6G+Q@mail.gmail.com>

On Wed Aug 5, 2026 at 9:00 AM CEST, Ning Ding wrote:
>> > 1. Disabling preemption
>> > 2. Disabling bottom halves
>> > 3. Disabling interrupts
>> > 4. Acquiring a spin lock
>> >
>> > As you are doing it for 4, can you also do it for 1 and 3? I don't think
>> > BPF can disable bottom halves right now.
>
> Hi, I have written the follow-up patch to account for
> preemption-disabled and irq-disabled regions. But still working on the
> selftests.
> While checking rcu gaps, I also found what looks like a separate issue
> for state pruning also regarding the MEM_RCU and PTR_UNTRUSTED. A
> sample example is:
>
>   bpf_rcu_read_lock();
>   bpf_iter_task_new(&it, NULL, BPF_TASK_ITER_ALL_PROCS);
>
>   if (condition) {
>   /* Safe: the outer RCU lock remains active. */
>   bpf_rcu_read_lock();
>   bpf_rcu_read_unlock();
>   } else {
>   /* Unsafe: protection reaches zero, creating an unguarded gap. */
>   bpf_rcu_read_unlock();
>   bpf_rcu_read_lock();
>   }
>
>   /* Both branches have one active RCU lock here. */
>   bpf_iter_task_next(&it);
>   bpf_rcu_read_unlock();
>
> But STACK_ITER comparison in stacksafe() does not compare
> spilled_ptr.type. So the verifier considers the trusted and untrusted
> iterator states are equivalent. It can possibly prune the unsafe path
> before is_iter_reg_valid_init() rejects it.
>

Sounds plausible. Once you have a fix and test that triggers bad pruning
behavior reliably, please send it as a patch set.

> https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/tree/kernel/bpf/states.c?id=6655c409707ec8ce9ce0850ffe4fe02331fd4d9c#n806


      reply	other threads:[~2026-08-06  9:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03 11:26 [PATCH bpf-next v2 0/2] bpf: Invalidate RCU pointers after final spin unlock Ning Ding
2026-08-03 11:26 ` [PATCH bpf-next v2 1/2] " Ning Ding
2026-08-04  9:30   ` Kumar Kartikeya Dwivedi
2026-08-03 11:26 ` [PATCH bpf-next v2 2/2] selftests/bpf: Test RCU pointer invalidation after " Ning Ding
2026-08-04  9:40 ` [PATCH bpf-next v2 0/2] bpf: Invalidate RCU pointers after final " patchwork-bot+netdevbpf
2026-08-04 10:50 ` Puranjay Mohan
2026-08-04 16:28   ` Paul E. McKenney
2026-08-05  7:00     ` Ning Ding
2026-08-06  9:02       ` Kumar Kartikeya Dwivedi [this message]

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=DKHQMSFIMQHR.1JSO9S9ZSZ5PY@gmail.com \
    --to=memxor@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=dingning04@gmail.com \
    --cc=paulmck@kernel.org \
    --cc=puranjay12@gmail.com \
    --cc=puranjay@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