All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
To: "Ning Ding" <dingning04@gmail.com>
Cc: <bpf@vger.kernel.org>, <ast@kernel.org>, <daniel@iogearbox.net>,
	<andrii@kernel.org>, <eddyz87@gmail.com>, <martin.lau@linux.dev>,
	<davem@davemloft.net>, <greg@kroah.com>
Subject: Re: [PATCH bpf v2 2/2] bpf: Reject untrusted pointers in refcount_acquire
Date: Mon, 03 Aug 2026 08:08:30 +0200	[thread overview]
Message-ID: <DKF31NEIMOOB.2CPM6KGVXD73K@gmail.com> (raw)
In-Reply-To: <CAJP4iuuYfqFChH1P2=3Q6WxHbMTNnAkCagR2k+Lr4W155gCj3A@mail.gmail.com>

On Mon Aug 3, 2026 at 7:57 AM CEST, Ning Ding wrote:
>> Same comment as the new set; split kernel commits and selftest commits into
>> separate ones. As for the fix, I think it would make more sense if
>> type_is_ptr_alloc_obj() was fixed to PTR_UNTRUSTED by definition, instead of
>> having to add extra checks on top.
>
> I tried this change on bpf-next 60781269e26c. It fixes the
> refcount_acquire case; the focused tests pass 43/43, and the
> list/rbtree tests pass 176/176.
>
> But here is one concern: type_is_ptr_alloc_obj() is also used by
> type_is_non_owning_ref() and reg_btf_record(). In particular,
> type_is_non_owning_ref() is defined in terms of it. After the final
> RCU unlock, a graph-object pointer has MEM_ALLOC | NON_OWN_REF |
> PTR_UNTRUSTED. Excluding PTR_UNTRUSTED from the shared helper makes
> type_is_non_owning_ref() return false.
>
> This also seems inconsistent with d8939cb0a03c, which allowed extra
> flags, including PTR_UNTRUSTED, for metadata lookup.

I would just disallow it. I don't even know how things would be correct if a
untrusted owning or non-owning ref is passed around. I think the case in patch 2
is demonstrating that it's a bogus type state for being passed around into the
kernel.

The only meaningful correct use seems to be reading from such a pointer, for
which PTR_UNTRUSTED downgrade instead of invalidating it completely should be
good enough.

  reply	other threads:[~2026-08-03  6:08 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-26 23:50 [PATCH bpf v2 0/2] bpf: Fix refcount_acquire handling for borrowed kptrs Ning Ding
2026-07-26 23:50 ` [PATCH bpf v2 1/2] bpf: Keep refcount_acquire nullable for borrowed RCU kptrs Ning Ding
2026-07-27  4:50   ` Greg KH
2026-07-26 23:50 ` [PATCH bpf v2 2/2] bpf: Reject untrusted pointers in refcount_acquire Ning Ding
2026-07-27  0:13   ` sashiko-bot
2026-07-27  0:40     ` Ning Ding
2026-07-27  4:50   ` Greg KH
2026-08-02 23:29   ` Kumar Kartikeya Dwivedi
2026-08-03  5:57     ` Ning Ding
2026-08-03  6:08       ` Kumar Kartikeya Dwivedi [this message]
2026-08-03  6:48         ` Ning Ding
2026-08-03  6:50           ` Kumar Kartikeya Dwivedi
2026-08-03  7:10             ` Ning Ding
2026-08-03  7:21               ` Kumar Kartikeya Dwivedi
2026-08-03  7:44                 ` Ning Ding
2026-08-03  7:48                   ` Kumar Kartikeya Dwivedi

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=DKF31NEIMOOB.2CPM6KGVXD73K@gmail.com \
    --to=memxor@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dingning04@gmail.com \
    --cc=eddyz87@gmail.com \
    --cc=greg@kroah.com \
    --cc=martin.lau@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.