BPF List
 help / color / mirror / Atom feed
From: Jiayuan Chen <jiayuan.chen@linux.dev>
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>, bpf@vger.kernel.org
Cc: syzbot+3544d9b2a9206be8ba37@syzkaller.appspotmail.com,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	kkd@meta.com, kernel-team@meta.com
Subject: Re: [PATCH bpf-next v1 1/2] bpf: Reject invalid LDSX instruction in disassembly
Date: Thu, 20 Aug 2026 13:23:29 +0800	[thread overview]
Message-ID: <abc32187-a946-46b2-8be5-8b61c5c58abc@linux.dev> (raw)
In-Reply-To: <20260820022020.3450479-2-memxor@gmail.com>


On 8/20/26 10:20 AM, Kumar Kartikeya Dwivedi wrote:
> The signed-load mnemonic table has entries for byte, half-word, and word
> loads because BPF_MEMSX does not support double-word loads. A BPF_MEMSX
> | BPF_DW instruction nevertheless selects index 3, past the end of this
> table.
>
> Program Structure diagnostics can disassemble a malformed instruction
> before check_and_resolve_insns() rejects its opcode. Placing the invalid
> signed double-word load at the end of a program therefore triggers an
> out-of-bounds access while reporting subprogram fallthrough.
>
> Treat signed double-word loads as invalid in the disassembler and use
> the existing BUG_ldx fallback instead.
>
> Fixes: a8f427835394 ("bpf: Report Program Structure CFG errors")
> Reported-by: syzbot+3544d9b2a9206be8ba37@syzkaller.appspotmail.com
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>


Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>

Sign-extending a 64-bit load is truly meaningless for printing

and this opcode is already treated as invalid in bpf_opcode_in_insntable()


> ---
>   kernel/bpf/disasm.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/disasm.c b/kernel/bpf/disasm.c
> index 50b3ca5149a0..b1a3fbe3fda5 100644
> --- a/kernel/bpf/disasm.c
> +++ b/kernel/bpf/disasm.c
> @@ -295,7 +295,8 @@ void print_bpf_insn(const struct bpf_insn_cbs *cbs,
>   			verbose(cbs->private_data, "BUG_st_%02x", insn->code);
>   		}
>   	} else if (class == BPF_LDX) {
> -		if (BPF_MODE(insn->code) != BPF_MEM && BPF_MODE(insn->code) != BPF_MEMSX) {
> +		if ((BPF_MODE(insn->code) != BPF_MEM && BPF_MODE(insn->code) != BPF_MEMSX) ||
> +		    (BPF_MODE(insn->code) == BPF_MEMSX && BPF_SIZE(insn->code) == BPF_DW)) {
>   			verbose(cbs->private_data, "BUG_ldx_%02x", insn->code);
>   			return;
>   		}

  reply	other threads:[~2026-08-20  5:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-20  2:20 [PATCH bpf-next v1 0/2] Reject invalid LDSX instruction in disassembler Kumar Kartikeya Dwivedi
2026-08-20  2:20 ` [PATCH bpf-next v1 1/2] bpf: Reject invalid LDSX instruction in disassembly Kumar Kartikeya Dwivedi
2026-08-20  5:23   ` Jiayuan Chen [this message]
2026-08-20  2:20 ` [PATCH bpf-next v1 2/2] selftests/bpf: Test invalid DW LDSX diagnostics Kumar Kartikeya Dwivedi

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=abc32187-a946-46b2-8be5-8b61c5c58abc@linux.dev \
    --to=jiayuan.chen@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=kernel-team@meta.com \
    --cc=kkd@meta.com \
    --cc=memxor@gmail.com \
    --cc=syzbot+3544d9b2a9206be8ba37@syzkaller.appspotmail.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