public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@fb.com>
To: Shung-Hsi Yu <shung-hsi.yu@suse.com>,
	linux-kselftest@vger.kernel.org, netdev@vger.kernel.org,
	bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Shuah Khan <shuah@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>
Subject: Re: [PATCH bpf-next 4/4] selftests/bpf: add reason of rejection in ld_imm64
Date: Fri, 20 May 2022 17:27:12 -0700	[thread overview]
Message-ID: <7301b9cc-fdb1-cd4c-2dda-eb97018546a6@fb.com> (raw)
In-Reply-To: <20220520113728.12708-5-shung-hsi.yu@suse.com>



On 5/20/22 4:37 AM, Shung-Hsi Yu wrote:
> It may not be immediately clear why that ld_imm64 test cases are
> rejected, especially for test1 and test2 where JMP to the 2nd
> instruction of BPF_LD_IMM64 is performed.
> 
> Add brief explaination of why each test case in verifier/ld_imm64.c
> should be rejected.
> 
> Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
> ---
>   .../testing/selftests/bpf/verifier/ld_imm64.c | 20 ++++++++++---------
>   1 file changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/verifier/ld_imm64.c b/tools/testing/selftests/bpf/verifier/ld_imm64.c
> index f9297900cea6..021312641aaf 100644
> --- a/tools/testing/selftests/bpf/verifier/ld_imm64.c
> +++ b/tools/testing/selftests/bpf/verifier/ld_imm64.c
> @@ -1,5 +1,6 @@
> +/* Note: BPF_LD_IMM64 is composed of two instructions of class BPF_LD */

> [...]LD | BPF_IMM | BPF_DW, 0, 0, 0, 0),
> @@ -42,7 +43,7 @@
>   	.result = REJECT,
>   },
>   {
> -	"test4 ld_imm64",
> +	"test4 ld_imm64: reject incomplete BPF_LD_IMM64 instruction",
>   	.insns = {
>   	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 0),
>   	BPF_EXIT_INSN(),
> @@ -70,7 +71,7 @@
>   	.retval = 1,
>   },
>   {
> -	"test8 ld_imm64",
> +	"test8 ld_imm64: reject 1st off!=0",

Let add some space like 'off != 0'. The same for
some of later test names.

>   	.insns = {
>   	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 1, 1),
>   	BPF_RAW_INSN(0, 0, 0, 0, 1),
> @@ -80,7 +81,7 @@
>   	.result = REJECT,
>   },
>   {
> -	"test9 ld_imm64",
> +	"test9 ld_imm64: reject 2nd off!=0",
>   	.insns = {
>   	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 1),
>   	BPF_RAW_INSN(0, 0, 0, 1, 1),
> @@ -90,7 +91,7 @@
>   	.result = REJECT,
>   },
>   {
> -	"test10 ld_imm64",
> +	"test10 ld_imm64: reject 2nd dst_reg!=0",
>   	.insns = {
>   	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 1),
>   	BPF_RAW_INSN(0, BPF_REG_1, 0, 0, 1),
> @@ -100,7 +101,7 @@
>   	.result = REJECT,
>   },
>   {
> -	"test11 ld_imm64",
> +	"test11 ld_imm64: reject 2nd src_reg!=0",
>   	.insns = {
>   	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 1),
>   	BPF_RAW_INSN(0, 0, BPF_REG_1, 0, 1),
> @@ -113,6 +114,7 @@
>   	"test12 ld_imm64",
>   	.insns = {
>   	BPF_MOV64_IMM(BPF_REG_1, 0),
> +	/* BPF_REG_1 is interpreted as BPF_PSEUDO_MAP_FD */
>   	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, BPF_REG_1, 0, 1),
>   	BPF_RAW_INSN(0, 0, 0, 0, 0),
>   	BPF_EXIT_INSN(),
> @@ -121,7 +123,7 @@
>   	.result = REJECT,
>   },
>   {
> -	"test13 ld_imm64",
> +	"test13 ld_imm64: 2nd src_reg!=0",
>   	.insns = {
>   	BPF_MOV64_IMM(BPF_REG_1, 0),
>   	BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, BPF_REG_1, 0, 1),

  reply	other threads:[~2022-05-21  0:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-20 11:37 [PATCH bpf-next 0/4] bpf: verifier: remove redundant opcode checks Shung-Hsi Yu
2022-05-20 11:37 ` [PATCH bpf-next 1/4] bpf: verifier: update resolve_pseudo_ldimm64() comment Shung-Hsi Yu
2022-05-20 11:37 ` [PATCH bpf-next 2/4] bpf: verifier: explain opcode check in check_ld_imm() Shung-Hsi Yu
2022-05-20 23:50   ` Yonghong Song
2022-05-21  0:25     ` Yonghong Song
2022-05-24  7:10       ` Shung-Hsi Yu
2022-05-24 15:12         ` Alexei Starovoitov
2022-05-26  8:59           ` Shung-Hsi Yu
2022-05-20 11:37 ` [PATCH bpf-next 3/4] bpf: verifier: remove redundant opcode checks Shung-Hsi Yu
2022-05-20 22:46   ` Alexei Starovoitov
2022-05-20 11:37 ` [PATCH bpf-next 4/4] selftests/bpf: add reason of rejection in ld_imm64 Shung-Hsi Yu
2022-05-21  0:27   ` Yonghong Song [this message]
2022-05-24  4:49     ` Shung-Hsi Yu

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=7301b9cc-fdb1-cd4c-2dda-eb97018546a6@fb.com \
    --to=yhs@fb.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=shung-hsi.yu@suse.com \
    --cc=songliubraving@fb.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