Re: [PATCH] libbpf: Report error when a negative kprobe offset is specified
From: bot+bpf-ci
Date: Fri Apr 17 2026 - 16:54:15 EST
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 8b0c3246097f..af81e0e200b9 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -12279,7 +12279,7 @@ bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog,
> static int attach_kprobe(const struct bpf_program *prog, long cookie, struct bpf_link **link)
> {
> DECLARE_LIBBPF_OPTS(bpf_kprobe_opts, opts);
> - unsigned long offset = 0;
> + long offset = 0;
> const char *func_name;
> char *func;
> int n;
> @@ -12301,6 +12301,13 @@ static int attach_kprobe(const struct bpf_program *prog, long cookie, struct bpf
> pr_warn("kprobe name is invalid: %s\n", func_name);
> return -EINVAL;
> }
> +
> + if (offset < 0) {
> + free(func);
> + pr_warn("kprobe offset must be a non-negative integer: %li\n", offset);
> + return -EINVAL;
> + }
> +
> if (opts.retprobe && offset != 0) {
> free(func);
> pr_warn("kretprobes do not support offset specification\n");
---
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/24584708297