[PATCHv7 04/13] kexec_file: Implement decompress method for parser
bot+bpf-ci at kernel.org
bot+bpf-ci at kernel.org
Sat Mar 21 19:26:34 PDT 2026
> diff --git a/kernel/kexec_bpf_loader.c b/kernel/kexec_bpf_loader.c
> index bd1800a76782..c79fb777d51b 100644
> --- a/kernel/kexec_bpf_loader.c
> +++ b/kernel/kexec_bpf_loader.c
[ ... ]
> @@ -73,8 +74,243 @@ static int __init kexec_bpf_prog_run_init(void)
> }
> late_initcall(kexec_bpf_prog_run_init);
[ ... ]
> static int kexec_buff_parser(struct bpf_parser_context *parser)
> {
> + struct bpf_parser_buf *pbuf = parser->buf;
> + struct kexec_context *ctx = (struct kexec_context *)parser->data;
> + struct cmd_hdr *cmd = (struct cmd_hdr *)pbuf->buf;
> + char *decompressed_buf, *buf, *p;
> + unsigned long decompressed_sz;
> + int ret = 0;
[ ... ]
> + case KEXEC_BPF_CMD_DECOMPRESS:
> + ret = parser_cmd_decompress(buf, cmd->payload_len, &decompressed_buf,
> + &decompressed_sz, ctx);
> + if (!ret) {
> + switch (cmd->subcmd) {
> + case KEXEC_BPF_SUBCMD_KERNEL:
> + vfree(ctx->kernel);
> + ctx->kernel = decompressed_buf;
> + ctx->kernel_sz = decompressed_sz;
> + break;
> + default:
> + vfree(decompressed_buf);
> + break;
> + }
> + }
> + break;
> + default:
> + break;
> + }
> +
> return 0;
> }
Should this return ret instead of 0? When parser_cmd_decompress()
fails, ret holds the error code, but the function discards it and
returns success.
bpf_buffer_parser() in bpf_buffer_parser.c propagates this return
value back to the calling BPF program:
ret = context->func(context);
...
return ret;
Returning 0 here means the BPF program sees success even when
decompression failed. It would then proceed to send
KEXEC_BPF_CMD_DONE, setting ctx->parsed = true, causing kexec
to complete loading with a missing or undecompressed kernel image.
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/23393379437
More information about the kexec
mailing list