mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hou Tao <houtao@huaweicloud.com>
To: Song Liu <song@kernel.org>, Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	John Fastabend <john.fastabend@gmail.com>,
	Jiri Olsa <jolsa@kernel.org>,
	bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next v5 3/3] selftests/bpf: Skip callback tests if jit is disabled in test_verifier
Date: Thu, 18 Jan 2024 09:11:14 +0800	[thread overview]
Message-ID: <342f1c7f-a8d3-dbba-a45f-66fc672883be@huaweicloud.com> (raw)
In-Reply-To: <CAPhsuW6mWoQQ1M-uPE_i+RWv=t5GaVqUDAObWgpEC-PCYSbwHQ@mail.gmail.com>

Hi Song,

On 1/18/2024 1:20 AM, Song Liu wrote:
> On Wed, Jan 17, 2024 at 3:10 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
> [...]
>> @@ -1622,6 +1624,16 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
>>         alignment_prevented_execution = 0;
>>
>>         if (expected_ret == ACCEPT || expected_ret == VERBOSE_ACCEPT) {
>> +               if (fd_prog < 0 && saved_errno == EINVAL && jit_disabled) {
>> +                       for (i = 0; i < prog_len; i++, prog++) {
>> +                               if (!insn_is_pseudo_func(prog))
>> +                                       continue;
>> +                               printf("SKIP (callbacks are not allowed in non-JITed programs)\n");
>> +                               skips++;
>> +                               goto close_fds;
>> +                       }
>> +               }
>> +
> I would put this chunk above "alignment_prevented_execution = 0;".
>
> @@ -1619,6 +1621,16 @@ static void do_test_single(struct bpf_test
> *test, bool unpriv,
>                 goto close_fds;
>         }
>
> +       if (fd_prog < 0 && saved_errno == EINVAL && jit_disabled) {
> +               for (i = 0; i < prog_len; i++, prog++) {
> +                       if (!insn_is_pseudo_func(prog))
> +                               continue;
> +                       printf("SKIP (callbacks are not allowed in
> non-JITed programs)\n");
> +                       skips++;
> +                       goto close_fds;
> +               }
> +       }
> +
>         alignment_prevented_execution = 0;
>
>         if (expected_ret == ACCEPT || expected_ret == VERBOSE_ACCEPT) {
>
> Other than this,

The check was placed before the checking of expected_ret in v3. However
I suggested Tiezhu to move it after the checking of expected_ret due to
the following two reasons:
1) when the expected result is REJECT, the return value in about one
third of these test cases is -EINVAL. And I think we should not waste
the cpu to check the pseudo func and exit prematurely, instead we should
let test_verifier check expected_err.
2) As for now all expected_ret of these failed cases are ACCEPT when jit
is disabled, so I think it will be enough for current situation and we
can revise it later if the checking of pseudo func is too later.

So wdyt ?

>
> Acked-by: Song Liu <song@kernel.org>
>
> Thanks,
> Song
>
> .


  reply	other threads:[~2024-01-18  1:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-17 11:09 [PATCH bpf-next v5 0/3] " Tiezhu Yang
2024-01-17 11:09 ` [PATCH bpf-next v5 1/3] selftests/bpf: Move is_jit_enabled() to testing_helpers Tiezhu Yang
2024-01-17 11:09 ` [PATCH bpf-next v5 2/3] libbpf: Move insn_is_pseudo_func() to libbpf_internal.h Tiezhu Yang
2024-01-17 16:53   ` Song Liu
2024-01-18  1:34   ` Hou Tao
2024-01-19 21:18   ` Andrii Nakryiko
2024-01-17 11:10 ` [PATCH bpf-next v5 3/3] selftests/bpf: Skip callback tests if jit is disabled in test_verifier Tiezhu Yang
2024-01-17 17:20   ` Song Liu
2024-01-18  1:11     ` Hou Tao [this message]
2024-01-18  1:27       ` Song Liu
2024-01-18  1:32         ` Hou Tao

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=342f1c7f-a8d3-dbba-a45f-66fc672883be@huaweicloud.com \
    --to=houtao@huaweicloud.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=song@kernel.org \
    --cc=yangtiezhu@loongson.cn \
    /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

all inboxes | Powered by JetHome®