From: sdf@google.com
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <martin.lau@kernel.org>,
Edward Cree <ecree.xilinx@gmail.com>
Subject: Re: [PATCH bpf v1 2/2] selftests/bpf: Add pruning test case for bpf_spin_lock
Date: Sat, 12 Nov 2022 17:59:10 -0800 [thread overview]
Message-ID: <Y3BPbmkCCQfR2xqt@google.com> (raw)
In-Reply-To: <20221111202719.982118-3-memxor@gmail.com>
On 11/12, Kumar Kartikeya Dwivedi wrote:
> Test that when reg->id is not same for the same register of type
> PTR_TO_MAP_VALUE between current and old explored state, we currently
> return false from regsafe and continue exploring.
> Without the fix in prior commit, the test case fails.
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Acked-by: Stanislav Fomichev <sdf@google.com>
> ---
> .../selftests/bpf/verifier/spin_lock.c | 39 +++++++++++++++++++
> 1 file changed, 39 insertions(+)
> diff --git a/tools/testing/selftests/bpf/verifier/spin_lock.c
> b/tools/testing/selftests/bpf/verifier/spin_lock.c
> index 781621facae4..0a8dcfc37fc6 100644
> --- a/tools/testing/selftests/bpf/verifier/spin_lock.c
> +++ b/tools/testing/selftests/bpf/verifier/spin_lock.c
> @@ -331,3 +331,42 @@
> .errstr = "inside bpf_spin_lock",
> .prog_type = BPF_PROG_TYPE_SCHED_CLS,
> },
> +{
> + "spin_lock: regsafe compare reg->id for map value",
> + .insns = {
> + BPF_MOV64_REG(BPF_REG_6, BPF_REG_1),
> + BPF_LDX_MEM(BPF_W, BPF_REG_6, BPF_REG_6, offsetof(struct __sk_buff,
> mark)),
> + BPF_LD_MAP_FD(BPF_REG_1, 0),
> + BPF_MOV64_REG(BPF_REG_9, BPF_REG_1),
> + BPF_ST_MEM(BPF_W, BPF_REG_10, -4, 0),
> + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
> + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -4),
> + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem),
> + BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1),
> + BPF_EXIT_INSN(),
> + BPF_MOV64_REG(BPF_REG_7, BPF_REG_0),
> + BPF_MOV64_REG(BPF_REG_1, BPF_REG_9),
> + BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
> + BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -4),
> + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem),
> + BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1),
> + BPF_EXIT_INSN(),
> + BPF_MOV64_REG(BPF_REG_8, BPF_REG_0),
> + BPF_MOV64_REG(BPF_REG_1, BPF_REG_7),
> + BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 4),
> + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_spin_lock),
> + BPF_JMP_IMM(BPF_JEQ, BPF_REG_6, 0, 1),
> + BPF_JMP_IMM(BPF_JA, 0, 0, 1),
> + BPF_MOV64_REG(BPF_REG_7, BPF_REG_8),
> + BPF_MOV64_REG(BPF_REG_1, BPF_REG_7),
> + BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 4),
> + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_spin_unlock),
> + BPF_MOV64_IMM(BPF_REG_0, 0),
> + BPF_EXIT_INSN(),
> + },
> + .fixup_map_spin_lock = { 2 },
> + .result = REJECT,
> + .errstr = "bpf_spin_unlock of different lock",
> + .prog_type = BPF_PROG_TYPE_SCHED_CLS,
> + .flags = BPF_F_TEST_STATE_FREQ,
> +},
> --
> 2.38.1
next prev parent reply other threads:[~2022-11-13 1:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 20:27 [PATCH bpf v1 0/2] Fix map value pruning check Kumar Kartikeya Dwivedi
2022-11-11 20:27 ` [PATCH bpf v1 1/2] bpf: Fix state pruning check for PTR_TO_MAP_VALUE Kumar Kartikeya Dwivedi
2022-11-13 1:58 ` sdf
2022-11-23 21:01 ` Andrii Nakryiko
2022-11-11 20:27 ` [PATCH bpf v1 2/2] selftests/bpf: Add pruning test case for bpf_spin_lock Kumar Kartikeya Dwivedi
2022-11-13 1:59 ` sdf [this message]
2022-11-11 21:17 ` [PATCH bpf v1 0/2] Fix map value pruning check Edward Cree
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y3BPbmkCCQfR2xqt@google.com \
--to=sdf@google.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=ecree.xilinx@gmail.com \
--cc=martin.lau@kernel.org \
--cc=memxor@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox