selftests/bpf: check if BPF_ST with variable offset preserves STACK_ZERO
authorEduard Zingerman <eddyz87@gmail.com>
Tue, 14 Feb 2023 23:20:30 +0000 (01:20 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 15 Feb 2023 19:48:48 +0000 (11:48 -0800)
commit2a33c5a25ef4fb574e6744fe7636956b124ad78f
tree5ee57d8c70a3bc9f1b7ff3231b30d09edecfbd1f
parent31ff2135121ca9c0fd6c60de6b851509a24446ab
selftests/bpf: check if BPF_ST with variable offset preserves STACK_ZERO

A test case to verify that variable offset BPF_ST instruction
preserves STACK_ZERO marks when writes zeros, e.g. in the following
situation:

  *(u64*)(r10 - 8) = 0   ; STACK_ZERO marks for fp[-8]
  r0 = random(-7, -1)    ; some random number in range of [-7, -1]
  r0 += r10              ; r0 is now variable offset pointer to stack
  *(u8*)(r0) = 0         ; BPF_ST writing zero, STACK_ZERO mark for
                         ; fp[-8] should be preserved.

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20230214232030.1502829-5-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/verifier/bpf_st_mem.c