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, 3 Mar 2020 14:58:20 -0800
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     KP Singh <kpsingh@...omium.org>
Cc:     open list <linux-kernel@...r.kernel.org>,
        bpf <bpf@...r.kernel.org>, Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Paul Turner <pjt@...gle.com>,
        Florent Revest <revest@...omium.org>,
        Brendan Jackman <jackmanb@...omium.org>
Subject: Re: [PATCH bpf-next 7/7] bpf: Add selftests for BPF_MODIFY_RETURN

On Tue, Mar 3, 2020 at 6:13 AM KP Singh <kpsingh@...omium.org> wrote:
>
> From: KP Singh <kpsingh@...gle.com>
>
> Test for two scenarios:
>
>   * When the fmod_ret program returns 0, the original function should
>     be called along with fentry and fexit programs.
>   * When the fmod_ret program returns a non-zero value, the original
>     function should not be called, no side effect should be observed and
>     fentry and fexit programs should be called.
>
> The result from the kernel function call and whether a side-effect is
> observed is returned via the retval attr of the BPF_PROG_TEST_RUN (bpf)
> syscall.
>
> Signed-off-by: KP Singh <kpsingh@...gle.com>
> ---

minor nits only

Acked-by: Andrii Nakryiko <andriin@...com>

>  net/bpf/test_run.c                            | 23 ++++++-
>  .../selftests/bpf/prog_tests/modify_return.c  | 65 +++++++++++++++++++
>  .../selftests/bpf/progs/modify_return.c       | 49 ++++++++++++++
>  3 files changed, 135 insertions(+), 2 deletions(-)
>  create mode 100644 tools/testing/selftests/bpf/prog_tests/modify_return.c
>  create mode 100644 tools/testing/selftests/bpf/progs/modify_return.c
>

[...]

>
> -       return 0;
> +       retval = (u32)side_effect << 16 | ret;

uhm, I didn't look up operator priority table, but I'd rather have ()
around bit shift operation :)

> +       if (copy_to_user(&uattr->test.retval, &retval, sizeof(retval)))
> +               goto out;
>
> +       return 0;
>  out:
>         trace_bpf_test_finish(&err);
>         return err;
> diff --git a/tools/testing/selftests/bpf/prog_tests/modify_return.c b/tools/testing/selftests/bpf/prog_tests/modify_return.c
> new file mode 100644
> index 000000000000..beab9a37f35c
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/modify_return.c
> @@ -0,0 +1,65 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +/*
> + * Copyright 2020 Google LLC.
> + */
> +
> +#include <test_progs.h>
> +#include "modify_return.skel.h"
> +
> +#define LOWER(x) (x & 0xffff)
> +#define UPPER(x) (x >> 16)

pedantic nit: (x) instead of just x

> +
> +

[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ