[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <f7708afd314b93994ea6bef80b24442016742820e59f57bac0b793cddf37076d@mail.kernel.org>
Date: Wed, 3 Dec 2025 23:57:39 +0000 (UTC)
From: bot+bpf-ci@...nel.org
To: ameryhung@...il.com,bpf@...r.kernel.org
Cc: netdev@...r.kernel.org,alexei.starovoitov@...il.com,andrii@...nel.org,daniel@...earbox.net,tj@...nel.org,martin.lau@...nel.org,ameryhung@...il.com,kernel-team@...a.com,ast@...nel.org,andrii@...nel.org,daniel@...earbox.net,martin.lau@...nel.org,eddyz87@...il.com,yonghong.song@...ux.dev,clm@...a.com,ihor.solodrai@...ux.dev
Subject: Re: [PATCH bpf-next v8 3/6] libbpf: Add support for associating BPF program with struct_ops
> diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
> index b66f5fbfb..21b57a629 100644
> --- a/tools/lib/bpf/bpf.c
> +++ b/tools/lib/bpf/bpf.c
[ ... ]
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 706e7481b..076dc6b79 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -14137,6 +14137,37 @@ int bpf_program__set_attach_target(struct bpf_program *prog,
> return 0;
> }
>
> +int bpf_program__assoc_struct_ops(struct bpf_program *prog, struct bpf_map *map,
> + struct bpf_prog_assoc_struct_ops_opts *opts)
> +{
> + int prog_fd, map_fd;
> +
> + prog_fd = bpf_program__fd(prog);
> + if (prog_fd < 0) {
> + pr_warn("prog '%s': can't associate BPF program without FD (was it loaded?)\n",
> + prog->name);
^^^^^^^^^^
Can this dereference prog->name when prog is NULL? If prog is NULL,
bpf_program__fd() returns -EINVAL, entering this error path, but
prog->name dereferences the NULL pointer before the error can be
returned.
> + return libbpf_err(-EINVAL);
> + }
> +
> + if (prog->type == BPF_PROG_TYPE_STRUCT_OPS) {
> + pr_warn("prog '%s': can't associate struct_ops program\n", prog->name);
^^^^^^^^^^
Same issue here - prog->name is dereferenced after we already know
prog_fd is invalid, which includes the case where prog is NULL.
> + return libbpf_err(-EINVAL);
> + }
> +
> + map_fd = bpf_map__fd(map);
> + if (map_fd < 0) {
> + pr_warn("map '%s': can't associate BPF map without FD (was it created?)\n", map->name);
^^^^^^^^^
Similar issue with map->name when map is NULL? If map is NULL,
bpf_map__fd() returns -EINVAL, and then map->name is dereferenced.
> + return libbpf_err(-EINVAL);
> + }
> +
> + if (!bpf_map__is_struct_ops(map)) {
> + pr_warn("map '%s': can't associate non-struct_ops map\n", map->name);
^^^^^^^^^
And again here with map->name after checking the map is not a
struct_ops type.
> + return libbpf_err(-EINVAL);
> + }
> +
> + return bpf_prog_assoc_struct_ops(prog_fd, map_fd, opts);
> +}
> +
[ ... ]
---
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/19912520845
Powered by blists - more mailing lists