bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	Martynas Pumputis <m@lambda.lt>, Joe Stringer <joe@wand.net.nz>,
	bpf <bpf@vger.kernel.org>, Networking <netdev@vger.kernel.org>
Subject: Re: [PATCH bpf-next 7/7] bpf: add selftest cases for ctx_or_null argument type
Date: Fri, 27 Mar 2020 17:51:46 -0700	[thread overview]
Message-ID: <CAEf4BzbEMVBMhN7cOCxzQ84wRXK3Um1Pc=gi_C7-GQ8WLpz+Uw@mail.gmail.com> (raw)
In-Reply-To: <c74758d07b1b678036465ef7f068a49e9efd3548.1585323121.git.daniel@iogearbox.net>

On Fri, Mar 27, 2020 at 8:59 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> Add various tests to make sure the verifier keeps catching them:
>
>   # ./test_verifier
>   [...]
>   #230/p pass ctx or null check, 1: ctx OK
>   #231/p pass ctx or null check, 2: null OK
>   #232/p pass ctx or null check, 3: 1 OK
>   #233/p pass ctx or null check, 4: ctx - const OK
>   #234/p pass ctx or null check, 5: null (connect) OK
>   #235/p pass ctx or null check, 6: null (bind) OK
>   #236/p pass ctx or null check, 7: ctx (bind) OK
>   #237/p pass ctx or null check, 8: null (bind) OK
>   [...]
>   Summary: 1595 PASSED, 0 SKIPPED, 0 FAILED
>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> ---
>  tools/testing/selftests/bpf/verifier/ctx.c | 105 +++++++++++++++++++++
>  1 file changed, 105 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/verifier/ctx.c b/tools/testing/selftests/bpf/verifier/ctx.c
> index 92762c08f5e3..93d6b1641481 100644
> --- a/tools/testing/selftests/bpf/verifier/ctx.c
> +++ b/tools/testing/selftests/bpf/verifier/ctx.c
> @@ -91,3 +91,108 @@
>         .result = REJECT,
>         .errstr = "variable ctx access var_off=(0x0; 0x4)",
>  },
> +{
> +       "pass ctx or null check, 1: ctx",
> +       .insns = {
> +               BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
> +                            BPF_FUNC_get_netns_cookie),

nit: seems like it deserves its own helper, e.g.,
BPF_CALL_HELPER(BPF_FUNC_get_netns_cookie)?

> +               BPF_MOV64_IMM(BPF_REG_0, 0),
> +               BPF_EXIT_INSN(),
> +       },
> +       .prog_type = BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
> +       .expected_attach_type = BPF_CGROUP_UDP6_SENDMSG,
> +       .result = ACCEPT,
> +},

[...]

      reply	other threads:[~2020-03-28  0:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-27 15:58 [PATCH bpf-next 0/7] Various improvements to cgroup helpers Daniel Borkmann
2020-03-27 15:58 ` [PATCH bpf-next 1/7] bpf: enable retrieval of socket cookie for bind/post-bind hook Daniel Borkmann
2020-03-27 15:58 ` [PATCH bpf-next 2/7] bpf: enable perf event rb output for bpf cgroup progs Daniel Borkmann
2020-03-27 15:58 ` [PATCH bpf-next 3/7] bpf: add netns cookie and enable it for bpf cgroup hooks Daniel Borkmann
2020-03-28  0:32   ` Andrii Nakryiko
2020-03-28  1:30     ` Daniel Borkmann
2020-03-28  1:48   ` Alexei Starovoitov
2020-03-28  2:16     ` Daniel Borkmann
2020-03-28  2:56       ` Alexei Starovoitov
2020-03-27 15:58 ` [PATCH bpf-next 4/7] bpf: allow to retrieve cgroup v1 classid from v2 hooks Daniel Borkmann
2020-03-28  0:41   ` Andrii Nakryiko
2020-03-28  1:56     ` Daniel Borkmann
2020-03-28 20:27       ` Andrii Nakryiko
2020-03-27 15:58 ` [PATCH bpf-next 5/7] bpf: enable bpf cgroup hooks to retrieve cgroup v2 and ancestor id Daniel Borkmann
2020-03-28  0:43   ` Andrii Nakryiko
2020-03-27 15:58 ` [PATCH bpf-next 6/7] bpf: enable retrival of pid/tgid/comm from bpf cgroup hooks Daniel Borkmann
2020-03-28  0:49   ` Andrii Nakryiko
2020-03-28  1:40     ` Daniel Borkmann
2020-03-27 15:58 ` [PATCH bpf-next 7/7] bpf: add selftest cases for ctx_or_null argument type Daniel Borkmann
2020-03-28  0:51   ` Andrii Nakryiko [this message]

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='CAEf4BzbEMVBMhN7cOCxzQ84wRXK3Um1Pc=gi_C7-GQ8WLpz+Uw@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=joe@wand.net.nz \
    --cc=m@lambda.lt \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).