[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQLWjSA9W0Hr2QsQo=L38fyg5r3q4BE799KuJYPGhGinqA@mail.gmail.com>
Date: Wed, 1 Oct 2025 09:55:24 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Brahmajit Das <listout@...tout.xyz>, Song Liu <song@...nel.org>, Eduard <eddyz87@...il.com>
Cc: syzbot+d36d5ae81e1b0a53ef58@...kaller.appspotmail.com,
Andrii Nakryiko <andrii@...nel.org>, Alexei Starovoitov <ast@...nel.org>, bpf <bpf@...r.kernel.org>,
Daniel Borkmann <daniel@...earbox.net>, Hao Luo <haoluo@...gle.com>,
John Fastabend <john.fastabend@...il.com>, Jiri Olsa <jolsa@...nel.org>,
KP Singh <kpsingh@...nel.org>, LKML <linux-kernel@...r.kernel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>, Stanislav Fomichev <sdf@...ichev.me>,
syzkaller-bugs <syzkaller-bugs@...glegroups.com>, Yonghong Song <yonghong.song@...ux.dev>,
KaFai Wan <kafai.wan@...ux.dev>
Subject: Re: [PATCH v3 1/2] bpf: Skip scalar adjustment for BPF_NEG if dst is
a pointer
On Wed, Oct 1, 2025 at 2:56 AM Brahmajit Das <listout@...tout.xyz> wrote:
>
> In check_alu_op(), the verifier currently calls check_reg_arg() and
> adjust_scalar_min_max_vals() unconditionally for BPF_NEG operations.
> However, if the destination register holds a pointer, these scalar
> adjustments are unnecessary and potentially incorrect.
>
> This patch adds a check to skip the adjustment logic when the destination
> register contains a pointer.
>
> Reported-by: syzbot+d36d5ae81e1b0a53ef58@...kaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=d36d5ae81e1b0a53ef58
> Fixes: aced132599b3 ("bpf: Add range tracking for BPF_NEG")
> Suggested-by: KaFai Wan <kafai.wan@...ux.dev>
> Signed-off-by: Brahmajit Das <listout@...tout.xyz>
> ---
> kernel/bpf/verifier.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index e892df386eed..4b0924c38657 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -15645,7 +15645,8 @@ static int check_alu_op(struct bpf_verifier_env *env, struct bpf_insn *insn)
> }
>
> /* check dest operand */
> - if (opcode == BPF_NEG) {
> + if (opcode == BPF_NEG &&
> + !__is_pointer_value(false, ®s[insn->dst_reg])) {
> err = check_reg_arg(env, insn->dst_reg, DST_OP_NO_MARK);
The fix makes sense.
Song,
Eduard,
please take a look.
Powered by blists - more mailing lists