BPF List
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Anton Protopopov" <a.s.protopopov@gmail.com>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
	"Alan Maguire" <almagui@kernel.org>,
	"John Fastabend" <john.fastabend@gmail.com>,
	<bpf@vger.kernel.org>
Subject: Re: [PATCH v1 bpf-next 4/7] selftests/bpf: Test fmod_ret on a declared function that returns a pointer
Date: Sun, 29 Nov 2026 01:21:29 +0000	[thread overview]
Message-ID: <DN7AU6CJ9I9Y.JICC3ELDIMQN@gmail.com> (raw)
In-Reply-To: <awbj1OVca5Ep-wuN@mail.gmail.com>

On Wed Nov 25, 2026 at 1:34 PM UTC, Anton Protopopov wrote:
> On 26/11/25 10:28AM, Anton Protopopov wrote:
>> Add bpf_testmod_modify_return_ptr() to the error injection list.
>> Check that a program on it may return an error pointer but not
>> another value, and that an extension of a global function of such a
>> program loads.
>
> Once the https://lore.kernel.org/bpf/20261125032938.670542-1-alexei.starovoitov@gmail.com/

it's in bpf-next now.

> series loads this selftest will fail. So I will send v2 later. Just
> in case, the new patch is (after removing freplace piece):

Applied patches 1,2,3,5.
I'm not sure we need this selftest. I feel the numbers of selftest is growing too fast.

re: patch 6 and inet_frag_find()...

> Its callers check the pointer with IS_ERR() and get the error with PTR_ERR().

Not for the functions that got the tag by mistake, and that's not the same
problem as with integers. Their callers test only for NULL, so any injected
error is dereferenced. One injection each on x86-64:

  inet_frag_find()                 clang      oops
  xfrm_policy_inexact_alloc_bin()  gcc,clang  oops
  __kmem_cache_create_args()       clang      oops

Please fix it in this set instead of a follow-up. Don't count an error
that the function itself compares with -MAX_ERRNO before it returns:

  inet_frag_find:   mov $-12, %rbp; ...; cmp $-0xfff, %rbp;
                    mov %rbp, %rax; cmovae %r14, %rax

seq_file calls ->stop() after ->start() failed. kernfs_seq_start() returns
-ENODEV with of->mutex held, so after a skip kernfs_seq_stop() unlocks a
mutex that nobody took. ipmr_vif_seq_start() does the same with RCU and
warns. Skip functions that take struct seq_file * and return void *.

These have a correct tag, but a skip breaks the caller.
Add them to excluded_by_name():

  vfs_mkdir()              error path unlocks the parent        hang
  lock_two_directories()   -EXDEV drops s_vfs_rename_mutex      hang
  btrfs_lookup_csum()      caller uses path after -ENOENT       oops
  ipc_obtain_object_idr()  do_shmat() doesn't check 2nd lookup  oops

Add them to denylist.

  reply	other threads:[~2026-11-29  1:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 10:27 [PATCH v1 bpf-next 0/7] Tag fmod_ret functions that return ERR_PTR() Anton Protopopov
2026-11-25 10:27 ` [PATCH v1 bpf-next 1/7] bpf: Require the JIT for fmod_ret programs on 64-bit functions Anton Protopopov
2026-11-25 10:27 ` [PATCH v1 bpf-next 2/7] bpf: Remove a wrong comment about fmod_ret targets Anton Protopopov
2026-11-25 10:28 ` [PATCH v1 bpf-next 3/7] bpf: Allow only NULL or ERR_PTR() from fmod_ret on pointer functions Anton Protopopov
2026-11-25 10:47   ` bot+bpf-ci
2026-11-25 13:14     ` Anton Protopopov
2026-11-25 13:38   ` Anton Protopopov
2026-11-25 10:28 ` [PATCH v1 bpf-next 4/7] selftests/bpf: Test fmod_ret on a declared function that returns a pointer Anton Protopopov
2026-11-25 13:34   ` Anton Protopopov
2026-11-29  1:21     ` Alexei Starovoitov [this message]
2026-11-25 10:28 ` [PATCH v1 bpf-next 5/7] bpf: Check fmod_ret return values of tagged pointer targets in 64 bits Anton Protopopov
2026-11-25 10:28 ` [PATCH v1 bpf-next 6/7] resolve_btfids: Tag the functions that return ERR_PTR() Anton Protopopov
2026-11-25 10:28 ` [PATCH v1 bpf-next 7/7] selftests/bpf: Test fmod_ret on functions that return a pointer Anton Protopopov

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=DN7AU6CJ9I9Y.JICC3ELDIMQN@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=a.s.protopopov@gmail.com \
    --cc=almagui@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=john.fastabend@gmail.com \
    --cc=memxor@gmail.com \
    /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