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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 28 Jul 2020 22:47:15 -0700
From:   Song Liu <song@...nel.org>
To:     Andrii Nakryiko <andriin@...com>
Cc:     bpf <bpf@...r.kernel.org>, Networking <netdev@...r.kernel.org>,
        Alexei Starovoitov <ast@...com>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii.nakryiko@...il.com>,
        Kernel Team <kernel-team@...com>,
        YiFei Zhu <zhuyifei@...gle.com>
Subject: Re: [PATCH bpf-next] selftests/bpf: don't destroy failed link

On Tue, Jul 28, 2020 at 9:54 PM Andrii Nakryiko <andriin@...com> wrote:
>
> Check that link is NULL or proper pointer before invoking bpf_link__destroy().
> Not doing this causes crash in test_progs, when cg_storage_multi selftest
> fails.
>
> Cc: YiFei Zhu <zhuyifei@...gle.com>
> Fixes: 3573f384014f ("selftests/bpf: Test CGROUP_STORAGE behavior on shared egress + ingress")
> Signed-off-by: Andrii Nakryiko <andriin@...com>

Acked-by: Song Liu <songliubraving@...com>

btw: maybe we can move the IS_ERR() check to bpf_link__destroy()?

> ---
>  .../bpf/prog_tests/cg_storage_multi.c         | 42 ++++++++++++-------
>  1 file changed, 28 insertions(+), 14 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/cg_storage_multi.c b/tools/testing/selftests/bpf/prog_tests/cg_storage_multi.c
> index c67d8c076a34..643dfa35419c 100644
> --- a/tools/testing/selftests/bpf/prog_tests/cg_storage_multi.c
> +++ b/tools/testing/selftests/bpf/prog_tests/cg_storage_multi.c
> @@ -147,8 +147,10 @@ static void test_egress_only(int parent_cgroup_fd, int child_cgroup_fd)
>                 goto close_bpf_object;
>
>  close_bpf_object:
> -       bpf_link__destroy(parent_link);
> -       bpf_link__destroy(child_link);
> +       if (!IS_ERR(parent_link))
> +               bpf_link__destroy(parent_link);
> +       if (!IS_ERR(child_link))
> +               bpf_link__destroy(child_link);
>
>         cg_storage_multi_egress_only__destroy(obj);
>  }
> @@ -262,12 +264,18 @@ static void test_isolated(int parent_cgroup_fd, int child_cgroup_fd)
>                 goto close_bpf_object;
>
>  close_bpf_object:
> -       bpf_link__destroy(parent_egress1_link);
> -       bpf_link__destroy(parent_egress2_link);
> -       bpf_link__destroy(parent_ingress_link);
> -       bpf_link__destroy(child_egress1_link);
> -       bpf_link__destroy(child_egress2_link);
> -       bpf_link__destroy(child_ingress_link);
> +       if (!IS_ERR(parent_egress1_link))
> +               bpf_link__destroy(parent_egress1_link);
> +       if (!IS_ERR(parent_egress2_link))
> +               bpf_link__destroy(parent_egress2_link);
> +       if (!IS_ERR(parent_ingress_link))
> +               bpf_link__destroy(parent_ingress_link);
> +       if (!IS_ERR(child_egress1_link))
> +               bpf_link__destroy(child_egress1_link);
> +       if (!IS_ERR(child_egress2_link))
> +               bpf_link__destroy(child_egress2_link);
> +       if (!IS_ERR(child_ingress_link))
> +               bpf_link__destroy(child_ingress_link);
>
>         cg_storage_multi_isolated__destroy(obj);
>  }
> @@ -367,12 +375,18 @@ static void test_shared(int parent_cgroup_fd, int child_cgroup_fd)
>                 goto close_bpf_object;
>
>  close_bpf_object:
> -       bpf_link__destroy(parent_egress1_link);
> -       bpf_link__destroy(parent_egress2_link);
> -       bpf_link__destroy(parent_ingress_link);
> -       bpf_link__destroy(child_egress1_link);
> -       bpf_link__destroy(child_egress2_link);
> -       bpf_link__destroy(child_ingress_link);
> +       if (!IS_ERR(parent_egress1_link))
> +               bpf_link__destroy(parent_egress1_link);
> +       if (!IS_ERR(parent_egress2_link))
> +               bpf_link__destroy(parent_egress2_link);
> +       if (!IS_ERR(parent_ingress_link))
> +               bpf_link__destroy(parent_ingress_link);
> +       if (!IS_ERR(child_egress1_link))
> +               bpf_link__destroy(child_egress1_link);
> +       if (!IS_ERR(child_egress2_link))
> +               bpf_link__destroy(child_egress2_link);
> +       if (!IS_ERR(child_ingress_link))
> +               bpf_link__destroy(child_ingress_link);
>
>         cg_storage_multi_shared__destroy(obj);
>  }
> --
> 2.24.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ