Netdev List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: bot+bpf-ci@kernel.org, ameryhung@gmail.com, bpf@vger.kernel.org
Cc: netdev@vger.kernel.org, alexei.starovoitov@gmail.com,
	andrii@kernel.org, daniel@iogearbox.net, memxor@gmail.com,
	martin.lau@kernel.org,  mykyta.yatsenko5@gmail.com,
	kernel-team@meta.com, ast@kernel.org,  yonghong.song@linux.dev,
	clm@meta.com, ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v1 2/3] bpf: Compare parent_id in refsafe() for REF_TYPE_PTR
Date: Thu, 04 Jun 2026 16:21:17 -0700	[thread overview]
Message-ID: <b4302a13ccae77b304a09b47c58565c8ff1970c2.camel@gmail.com> (raw)
In-Reply-To: <a5988106169c7350f39a4d07b36b679a5fb39cda49ca371cb79c23da7b63971d@mail.kernel.org>

On Thu, 2026-06-04 at 22:59 +0000, bot+bpf-ci@kernel.org wrote:
> > commit 89f2be9817e074d02702d22068104fb9fd9aa103
> > Author: Amery Hung <ameryhung@gmail.com>
> > Date:   Thu Jun 4 15:09:03 2026 -0700
> > 
> >     bpf: Compare parent_id in refsafe() for REF_TYPE_PTR
> > 
> >     refsafe() compared each reference's id and type but not its parent_id,
> >     so two states whose PTR references differ only in the parent object they
> >     were derived from could be wrongly treated as equivalent and pruned. Fix
> >     it by checking parent_id too.
> > 
> >     Signed-off-by: Amery Hung <ameryhung@gmail.com>
> 
> This looks like a bug fix for parent_id tracking support. Should this
> include:
> 
>   Fixes: 308c7a0ae885 ("bpf: Refactor object relationship tracking and fix dynptr UAF bug")
> 
> When commit 308c7a0ae885 added parent_id tracking, it updated several
> safety-checking functions to compare parent_id but missed adding the
> parent_id check in refsafe() for the REF_TYPE_PTR case. This caused states
> with different parent objects to be incorrectly treated as equivalent
> during state pruning.
> 
> > diff --git a/kernel/bpf/states.c b/kernel/bpf/states.c
> > index 5945956a7573..06d9ae24f006 100644
> > --- a/kernel/bpf/states.c
> > +++ b/kernel/bpf/states.c
> > @@ -890,6 +890,9 @@ static bool refsafe(struct bpf_verifier_state *old, struct bpf_verifier_state *c
> >  			return false;
> >  		switch (old->refs[i].type) {
> >  		case REF_TYPE_PTR:
> > +			if (!check_ids(old->refs[i].parent_id, cur->refs[i].parent_id, idmap))
> > +				return false;
> > +			break;
> >  		case REF_TYPE_IRQ:
> >  			break;
> >  		case REF_TYPE_LOCK:
> 
> This adds an extra check_ids() call for parent_id. Could this make it
> easier to trigger the WARN_ON_ONCE() in check_ids() via BPF_ID_MAP_SIZE
> exhaustion?

I think the bot has the point here. Let's switch to reallocating idmap
or failing check_ids() if there are to many ids (probably an
unrealistic scenario).

  reply	other threads:[~2026-06-04 23:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-04 22:09 [PATCH bpf-next v1 0/3] Object relationship refactor followup Amery Hung
2026-06-04 22:09 ` [PATCH bpf-next v1 1/3] bpf: Fix dead error check on acquire_reference() in check_kfunc_call Amery Hung
2026-06-04 22:43   ` bot+bpf-ci
2026-06-04 23:16   ` Eduard Zingerman
2026-06-04 22:09 ` [PATCH bpf-next v1 2/3] bpf: Compare parent_id in refsafe() for REF_TYPE_PTR Amery Hung
2026-06-04 22:59   ` bot+bpf-ci
2026-06-04 23:21     ` Eduard Zingerman [this message]
2026-06-04 23:27       ` Amery Hung
2026-06-04 22:09 ` [PATCH bpf-next v1 3/3] selftests/bpf: Use bpf_dynptr_slice() to read file dynptr in leak test Amery Hung
2026-06-04 23:22   ` Eduard Zingerman
2026-06-04 22:14 ` [PATCH bpf-next v1 0/3] Object relationship refactor followup Kumar Kartikeya Dwivedi
2026-06-04 23:20   ` Amery Hung

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=b4302a13ccae77b304a09b47c58565c8ff1970c2.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=ameryhung@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bot+bpf-ci@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=clm@meta.com \
    --cc=daniel@iogearbox.net \
    --cc=ihor.solodrai@linux.dev \
    --cc=kernel-team@meta.com \
    --cc=martin.lau@kernel.org \
    --cc=memxor@gmail.com \
    --cc=mykyta.yatsenko5@gmail.com \
    --cc=netdev@vger.kernel.org \
    --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