[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6f414450-8a8e-7a9c-289a-675af96e758c@iogearbox.net>
Date: Tue, 12 Mar 2019 22:01:10 +0100
From: Daniel Borkmann <daniel@...earbox.net>
To: Yonghong Song <yhs@...com>, netdev@...r.kernel.org
Cc: Alexei Starovoitov <ast@...com>, kernel-team@...com
Subject: Re: [PATCH bpf] selftests/bpf: fix segfault of test_progs when prog
loading failed
On 03/12/2019 06:21 AM, Yonghong Song wrote:
> The test_progs subtests, test_spin_lock() and test_map_lock(),
> requires BTF present to run successfully.
> Currently, when BTF failed to load, test_progs will segfault,
> $ ./test_progs
> ...
> 12: (bf) r1 = r8
> 13: (85) call bpf_spin_lock#93
> map 'hash_map' has to have BTF in order to use bpf_spin_lock
>
> libbpf: -- END LOG --
> libbpf: failed to load program 'map_lock_demo'
> libbpf: failed to load object './test_map_lock.o'
> test_map_lock:bpf_prog_load errno 13
> Segmentation fault
>
> The segfault is caused by uninitialized variable "obj", which
> is used in bpf_object__close(obj), when bpf prog failed to load.
>
> Initializing variable "obj" to NULL in two occasions fixed the problem.
> $ ./test_progs
> ...
> Summary: 219 PASSED, 2 FAILED
>
> Fixes: b4d4556c3266 ("selftests/bpf: add bpf_spin_lock verifier tests")
> Fixes: ba72a7b4badb ("selftests/bpf: test for BPF_F_LOCK")
> Reported-by: Daniel Borkmann <daniel@...earbox.net>
> Signed-off-by: Yonghong Song <yhs@...com>
Applied, thanks!
Powered by blists - more mailing lists