BPF List
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Xu Yunxiang" <xyx2021@mail.ustc.edu.cn>, <bpf@vger.kernel.org>
Cc: <daniel@iogearbox.net>, <andrii@kernel.org>, <eddyz87@gmail.com>,
	<memxor@gmail.com>, <ameryhung@gmail.com>,
	<yonghong.song@linux.dev>, <puranjay@kernel.org>
Subject: Re: [PATCH bpf-next v4 1/2] bpf: Track iterator-owned BTF pointer lifetimes
Date: Thu, 17 Sep 2026 14:45:02 +0000	[thread overview]
Message-ID: <DLHO7NCJVWJV.1K8VWK8LFIKGD@gmail.com> (raw)
In-Reply-To: <20260917051948.1588826-2-xyx2021@mail.ustc.edu.cn>

On Thu, Sep 17, 2026 at 01:19 PM Xu Yunxiang <xyx2021@mail.ustc.edu.cn> wrote:

> @@ -6219,9 +6231,14 @@ static int check_ptr_to_btf_access(struct bpf_verifier_env *env,
>  	}
>
>  	if (atype == BPF_READ && value_regno >= 0) {
> +		u32 parent_id = reg_lifetime_id(env, reg);
> +
>  		ret = mark_btf_ld_reg(env, regs, value_regno, ret, reg->btf, btf_id, flag);
>  		if (ret < 0)
>  			return ret;
> +		if ((regs[value_regno].type & PTR_TRUSTED) &&
> +		    !(regs[value_regno].type & (MEM_RCU | MEM_PERCPU | MEM_USER)))
> +			regs[value_regno].parent_id = parent_id;
>  	}

Any trusted field walked from a
referenced pointer now dies with that reference, e.g.

  file = bpf_get_task_exe_file(task);
  inode = file->f_inode;
  bpf_put_file(file);
  ... inode->i_ino ...

loads today and is rejected after this patch, since
release_reference() on bpf_put_file() invalidates every reg with
parent_id == file's ref id. That's the right thing to do in file case
and vma iter case
, but likely not the case for many other iters.

We need either opt-in or opt-out. Not sure which is better.
Certainly some flag.
Blank reject for all is probably overkill that might break valid progs.

pw-bot: cr

  parent reply	other threads:[~2026-09-17 14:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17  5:19 [PATCH bpf-next v4 0/2] bpf: Track iterator-owned BTF pointer lifetimes Xu Yunxiang
2026-09-17  5:19 ` [PATCH bpf-next v4 1/2] " Xu Yunxiang
2026-09-17  5:44   ` sashiko-bot
2026-09-17  6:48   ` bot+bpf-ci
2026-09-17 14:45   ` Alexei Starovoitov [this message]
2026-09-17  5:19 ` [PATCH bpf-next v4 2/2] selftests/bpf: Test iterator " Xu Yunxiang

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=DLHO7NCJVWJV.1K8VWK8LFIKGD@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=ameryhung@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=memxor@gmail.com \
    --cc=puranjay@kernel.org \
    --cc=xyx2021@mail.ustc.edu.cn \
    --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