lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Tue, 12 Jan 2021 08:59:12 -0800 From: Yonghong Song <yhs@...com> To: Daniel Borkmann <daniel@...earbox.net>, Gilad Reti <gilad.reti@...il.com>, KP Singh <kpsingh@...nel.org> CC: bpf <bpf@...r.kernel.org>, Shuah Khan <shuah@...nel.org>, Alexei Starovoitov <ast@...nel.org>, Andrii Nakryiko <andrii@...nel.org>, Martin KaFai Lau <kafai@...com>, Song Liu <songliubraving@...com>, John Fastabend <john.fastabend@...il.com>, <linux-kselftest@...r.kernel.org>, Networking <netdev@...r.kernel.org>, open list <linux-kernel@...r.kernel.org> Subject: Re: [PATCH 2/2] selftests/bpf: add verifier test for PTR_TO_MEM spill On 1/12/21 7:43 AM, Daniel Borkmann wrote: > On 1/12/21 4:35 PM, Gilad Reti wrote: >> On Tue, Jan 12, 2021 at 4:56 PM KP Singh <kpsingh@...nel.org> wrote: >>> On Tue, Jan 12, 2021 at 10:16 AM Gilad Reti <gilad.reti@...il.com> >>> wrote: >>>> >>>> Add test to check that the verifier is able to recognize spilling of >>>> PTR_TO_MEM registers. >>> >>> It would be nice to have some explanation of what the test does to >>> recognize the spilling of the PTR_TO_MEM registers in the commit >>> log as well. >>> >>> Would it be possible to augment an existing test_progs >>> program like tools/testing/selftests/bpf/progs/test_ringbuf.c to test >>> this functionality? > > How would you guarantee that LLVM generates the spill/fill, via inline asm? You can make the following change to force the return value ("sample" here) of bpf_ringbuf_reserve() to spill on the stack. diff --git a/tools/testing/selftests/bpf/progs/test_ringbuf.c b/tools/testing/selftests/bpf/progs/test_ringbuf.c index 8ba9959b036b..011521170856 100644 --- a/tools/testing/selftests/bpf/progs/test_ringbuf.c +++ b/tools/testing/selftests/bpf/progs/test_ringbuf.c @@ -40,7 +40,7 @@ SEC("tp/syscalls/sys_enter_getpgid") int test_ringbuf(void *ctx) { int cur_pid = bpf_get_current_pid_tgid() >> 32; - struct sample *sample; + struct sample * volatile sample; int zero = 0; if (cur_pid != pid) This change will cause verifier failure without Patch #1. > >> It may be possible, but from what I understood from Daniel's comment here >> >> https://lore.kernel.org/bpf/17629073-4fab-a922-ecc3-25b019960f44@iogearbox.net/ >> >> >> the test should be a part of the verifier tests (which is reasonable >> to me since it is >> a verifier bugfix) > > Yeah, the test_verifier case as you have is definitely the most straight > forward way to add coverage in this case.
Powered by blists - more mailing lists