BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Anton Protopopov" <a.s.protopopov@gmail.com>, bpf@vger.kernel.org
Subject: Re: [PATCH v2 bpf-next 1/5] resolve_btfids: Do not count errors translated to NULL
Date: Mon, 30 Nov 2026 18:06:32 +0000	[thread overview]
Message-ID: <sashiko-outbox-241770@kernel.org> (raw)
In-Reply-To: <20261130180425.150703-2-a.s.protopopov@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] resolve_btfids: transfer() drops errors returned via IS_ERR()
  and PTR_ERR()
--

commit e1c82f8bb3175c33c159c6be7643d5ac46f3da7d
Author: Anton Protopopov <a.s.protopopov@gmail.com>

resolve_btfids: Do not count errors translated to NULL

This commit decodes 64-bit immediate comparisons on x86-64 and arm64 so
the fmodret scanner can ignore error values in a register tested by
IS_ERR(), while still tracking -EINPROGRESS across the whole function.

> diff --git a/tools/bpf/resolve_btfids/text_flow.c b/tools/bpf/resolve_btfids/text_flow.c
> index d7d3f9d1c6c1a..44e772e2deb26 100644
> --- a/tools/bpf/resolve_btfids/text_flow.c
> +++ b/tools/bpf/resolve_btfids/text_flow.c
[ ... ]
> @@ -156,6 +158,12 @@ static struct text_facts transfer(const struct text_flow *flow, u32 i)
>  		if (insn->kind == TEXT_SELECT)
>  			copy(&in, &out, insn->dst, insn->src2, cast);
>  		break;
> +	case TEXT_CMP_IMM:
> +		/* IS_ERR(src) ? NULL : src. Count no error which the function tests itself */
> +		if (!insn->is32 &&
> +		    (insn->imm == -(u64)MAX_ERRNO || insn->imm == -(u64)MAX_ERRNO - 1))
> +			kill(&in, BIT(insn->src));
> +		break;
>  	}
>  	return in;
>  }

[Severity: Medium]
Does killing insn->src on every 64-bit -MAX_ERRNO comparison also drop
errors that the function actually returns when the error branch returns
PTR_ERR(src) instead of NULL?

tools/testing/selftests/bpf/test_kmods/bpf_testmod_retval.c:bpf_testmod_retval_err_ptr() {
	int *slot = bpf_testmod_retval_slot(buf, idx);

	if (IS_ERR(slot))
		return PTR_ERR(slot);
	*slot = 1;
	return 0;
}

When built with Clang, the inlined ternary in bpf_testmod_retval_slot()
(idx > 8 ? ERR_PTR(-EFAULT) : &buf[idx]) is lowered to a 64-bit
conditional select into slot, followed by a 64-bit compare against -4096
for IS_ERR(slot). Killing insn->src at TEXT_CMP_IMM drops -EFAULT (-14)
from bpf_testmod_retval_err_ptr's tag, causing the fmodret_retval
selftest to fail.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130180425.150703-1-a.s.protopopov@gmail.com?part=1

  reply	other threads:[~2026-11-30 18:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 18:04 [PATCH v2 bpf-next 0/5] Tag fmod_ret functions that return ERR_PTR() Anton Protopopov
2026-11-30 18:04 ` [PATCH v2 bpf-next 1/5] resolve_btfids: Do not count errors translated to NULL Anton Protopopov
2026-11-30 18:06   ` sashiko-bot [this message]
2026-11-30 18:04 ` [PATCH v2 bpf-next 2/5] resolve_btfids: Tag the functions that return ERR_PTR() Anton Protopopov
2026-11-30 18:04 ` [PATCH v2 bpf-next 3/5] resolve_btfids: Do not tag seq_file operations Anton Protopopov
2026-11-30 18:04 ` [PATCH v2 bpf-next 4/5] resolve_btfids: Do not tag functions whose callers break on a skip Anton Protopopov
2026-11-30 18:02   ` sashiko-bot
2026-11-30 18:04 ` [PATCH v2 bpf-next 5/5] 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=sashiko-outbox-241770@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=a.s.protopopov@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.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