diff mbox series

[bpf-next] libbpf: Fix null pointer when using old pref_buffer__new()

Message ID 20211202220933.1155174-1-fallentree@fb.com (mailing list archive)
State Rejected
Delegated to: BPF
Headers show
Series [bpf-next] libbpf: Fix null pointer when using old pref_buffer__new() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers fail 1 blamed authors not CCed: ast@kernel.org; 8 maintainers not CCed: netdev@vger.kernel.org kafai@fb.com daniel@iogearbox.net songliubraving@fb.com john.fastabend@gmail.com kpsingh@kernel.org yhs@fb.com ast@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes fail Problems with Fixes tag: 1
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next success VM_Test
bpf/vmtest-bpf-next-PR success PR summary

Commit Message

Yucong Sun Dec. 2, 2021, 10:09 p.m. UTC
Passing opts point to new function so program using old interface won't
segfault.

Fixes: 417889346577 ("libbpf: Make perf_buffer__new() use OPTS-based interface")

Signed-off-by: Yucong Sun <fallentree@fb.com>
---
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrii Nakryiko Dec. 3, 2021, 12:01 a.m. UTC | #1
On Thu, Dec 2, 2021 at 2:09 PM Yucong Sun <fallentree@fb.com> wrote:
>
> Passing opts point to new function so program using old interface won't
> segfault.
>
> Fixes: 417889346577 ("libbpf: Make perf_buffer__new() use OPTS-based interface")
>
> Signed-off-by: Yucong Sun <fallentree@fb.com>
> ---
>  tools/lib/bpf/libbpf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 1341ce539662..dac4929e5810 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -10812,7 +10812,7 @@ struct perf_buffer *perf_buffer__new_deprecated(int map_fd, size_t page_cnt,
>                                        opts ? opts->sample_cb : NULL,
>                                        opts ? opts->lost_cb : NULL,
>                                        opts ? opts->ctx : NULL,
> -                                      NULL);
> +                                      opts);

perf_buffer__new_v0_6_0() doesn't need non-null opts, OPTS_VALID(opts,
perf_buffer_opts) handles NULL perfectly fine. After that we never
dereference opts. That NULL there is intentional.

>  }
>
>  DEFAULT_VERSION(perf_buffer__new_raw_v0_6_0, perf_buffer__new_raw, LIBBPF_0.6.0)
> --
> 2.30.2
>
diff mbox series

Patch

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 1341ce539662..dac4929e5810 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -10812,7 +10812,7 @@  struct perf_buffer *perf_buffer__new_deprecated(int map_fd, size_t page_cnt,
 				       opts ? opts->sample_cb : NULL,
 				       opts ? opts->lost_cb : NULL,
 				       opts ? opts->ctx : NULL,
-				       NULL);
+				       opts);
 }
 
 DEFAULT_VERSION(perf_buffer__new_raw_v0_6_0, perf_buffer__new_raw, LIBBPF_0.6.0)