lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPhsuW49ZU+ak=uned=AfBbGNVboLguKVXjfsOy7hZLbUSkyag@mail.gmail.com>
Date:   Tue, 6 Sep 2022 14:30:09 -0700
From:   Song Liu <song@...nel.org>
To:     Lorenzo Bianconi <lorenzo@...nel.org>
Cc:     bpf <bpf@...r.kernel.org>, Networking <netdev@...r.kernel.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        "David S . Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Eric Dumazet <edumazet@...gle.com>,
        Paolo Abeni <pabeni@...hat.com>, pablo@...filter.org,
        fw@...len.de, netfilter-devel@...r.kernel.org,
        lorenzo.bianconi@...hat.com,
        Jesper Dangaard Brouer <brouer@...hat.com>,
        Toke Høiland-Jørgensen <toke@...hat.com>,
        Kumar Kartikeya Dwivedi <memxor@...il.com>
Subject: Re: [PATCH v2 bpf-next 2/4] selftests/bpf: Extend KF_TRUSTED_ARGS
 test for __ref annotation

On Mon, Sep 5, 2022 at 6:15 AM Lorenzo Bianconi <lorenzo@...nel.org> wrote:
>
> From: Kumar Kartikeya Dwivedi <memxor@...il.com>
>
> Extend the existing test for KF_TRUSTED_ARGS by also checking whether
> the same happens when a __ref suffix is present in argument name of a
> kfunc.
>
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@...il.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@...nel.org>

Acked-by: Song Liu <song@...nel.org>

> ---
>  tools/testing/selftests/bpf/verifier/calls.c | 38 +++++++++++++++-----
>  1 file changed, 30 insertions(+), 8 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/verifier/calls.c b/tools/testing/selftests/bpf/verifier/calls.c
> index 3fb4f69b1962..891fcda50d9d 100644
> --- a/tools/testing/selftests/bpf/verifier/calls.c
> +++ b/tools/testing/selftests/bpf/verifier/calls.c
> @@ -219,7 +219,7 @@
>         .errstr = "variable ptr_ access var_off=(0x0; 0x7) disallowed",
>  },
>  {
> -       "calls: invalid kfunc call: referenced arg needs refcounted PTR_TO_BTF_ID",
> +       "calls: invalid kfunc call: referenced arg needs refcounted PTR_TO_BTF_ID (KF_TRUSTED_ARGS)",
>         .insns = {
>         BPF_MOV64_REG(BPF_REG_1, BPF_REG_10),
>         BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, -8),
> @@ -227,10 +227,30 @@
>         BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, BPF_PSEUDO_KFUNC_CALL, 0, 0),
>         BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1),
>         BPF_EXIT_INSN(),
> -       BPF_MOV64_REG(BPF_REG_6, BPF_REG_0),
> -       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
> +       BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_0, 16),
>         BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, BPF_PSEUDO_KFUNC_CALL, 0, 0),
> -       BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_6, 16),
> +       BPF_MOV64_IMM(BPF_REG_0, 0),
> +       BPF_EXIT_INSN(),
> +       },
> +       .prog_type = BPF_PROG_TYPE_SCHED_CLS,
> +       .fixup_kfunc_btf_id = {
> +               { "bpf_kfunc_call_test_acquire", 3 },
> +               { "bpf_kfunc_call_test_trusted", 7 },
> +       },
> +       .result_unpriv = REJECT,
> +       .result = REJECT,
> +       .errstr = "R1 must be referenced",
> +},
> +{
> +       "calls: invalid kfunc call: referenced arg needs refcounted PTR_TO_BTF_ID (__ref)",
> +       .insns = {
> +       BPF_MOV64_REG(BPF_REG_1, BPF_REG_10),
> +       BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, -8),
> +       BPF_ST_MEM(BPF_DW, BPF_REG_1, 0, 0),
> +       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, BPF_PSEUDO_KFUNC_CALL, 0, 0),
> +       BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1),
> +       BPF_EXIT_INSN(),
> +       BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_0, 16),
>         BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, BPF_PSEUDO_KFUNC_CALL, 0, 0),
>         BPF_MOV64_IMM(BPF_REG_0, 0),
>         BPF_EXIT_INSN(),
> @@ -238,8 +258,7 @@
>         .prog_type = BPF_PROG_TYPE_SCHED_CLS,
>         .fixup_kfunc_btf_id = {
>                 { "bpf_kfunc_call_test_acquire", 3 },
> -               { "bpf_kfunc_call_test_ref", 8 },
> -               { "bpf_kfunc_call_test_ref", 10 },
> +               { "bpf_kfunc_call_test_ref", 7 },
>         },
>         .result_unpriv = REJECT,
>         .result = REJECT,
> @@ -259,14 +278,17 @@
>         BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, BPF_PSEUDO_KFUNC_CALL, 0, 0),
>         BPF_MOV64_REG(BPF_REG_1, BPF_REG_6),
>         BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, BPF_PSEUDO_KFUNC_CALL, 0, 0),
> +       BPF_MOV64_REG(BPF_REG_1, BPF_REG_6),
> +       BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, BPF_PSEUDO_KFUNC_CALL, 0, 0),
>         BPF_MOV64_IMM(BPF_REG_0, 0),
>         BPF_EXIT_INSN(),
>         },
>         .prog_type = BPF_PROG_TYPE_SCHED_CLS,
>         .fixup_kfunc_btf_id = {
>                 { "bpf_kfunc_call_test_acquire", 3 },
> -               { "bpf_kfunc_call_test_ref", 8 },
> -               { "bpf_kfunc_call_test_release", 10 },
> +               { "bpf_kfunc_call_test_trusted", 8 },
> +               { "bpf_kfunc_call_test_ref", 10 },
> +               { "bpf_kfunc_call_test_release", 12 },
>         },
>         .result_unpriv = REJECT,
>         .result = ACCEPT,
> --
> 2.37.3
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ