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: <CACT4Y+b3cpG_L+UO=vvRtPdBh7Np5U4AA5_WuK7s7FUazuBvwQ@mail.gmail.com>
Date:   Tue, 1 Feb 2022 08:33:24 +0100
From:   Dmitry Vyukov <dvyukov@...gle.com>
To:     Marco Elver <elver@...gle.com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...nel.org>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        linux-perf-users@...r.kernel.org, kasan-dev@...glegroups.com,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/3] selftests/perf_events: Test modification of perf_event_attr::sig_data

On Mon, 31 Jan 2022 at 11:34, Marco Elver <elver@...gle.com> wrote:
>
> Test that PERF_EVENT_IOC_MODIFY_ATTRIBUTES correctly modifies
> perf_event_attr::sig_data as well.
>
> Signed-off-by: Marco Elver <elver@...gle.com>

Reviewed-by: Dmitry Vyukov <dvyukov@...gle.com>


> ---
>  .../selftests/perf_events/sigtrap_threads.c     | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/tools/testing/selftests/perf_events/sigtrap_threads.c b/tools/testing/selftests/perf_events/sigtrap_threads.c
> index 8e83cf91513a..6d849dc2bee0 100644
> --- a/tools/testing/selftests/perf_events/sigtrap_threads.c
> +++ b/tools/testing/selftests/perf_events/sigtrap_threads.c
> @@ -44,9 +44,10 @@ static struct {
>  } ctx;
>
>  /* Unique value to check si_perf_data is correctly set from perf_event_attr::sig_data. */
> -#define TEST_SIG_DATA(addr) (~(unsigned long)(addr))
> +#define TEST_SIG_DATA(addr, id) (~(unsigned long)(addr) + id)
>
> -static struct perf_event_attr make_event_attr(bool enabled, volatile void *addr)
> +static struct perf_event_attr make_event_attr(bool enabled, volatile void *addr,
> +                                             unsigned long id)
>  {
>         struct perf_event_attr attr = {
>                 .type           = PERF_TYPE_BREAKPOINT,
> @@ -60,7 +61,7 @@ static struct perf_event_attr make_event_attr(bool enabled, volatile void *addr)
>                 .inherit_thread = 1, /* ... but only cloned with CLONE_THREAD. */
>                 .remove_on_exec = 1, /* Required by sigtrap. */
>                 .sigtrap        = 1, /* Request synchronous SIGTRAP on event. */
> -               .sig_data       = TEST_SIG_DATA(addr),
> +               .sig_data       = TEST_SIG_DATA(addr, id),
>         };
>         return attr;
>  }
> @@ -110,7 +111,7 @@ FIXTURE(sigtrap_threads)
>
>  FIXTURE_SETUP(sigtrap_threads)
>  {
> -       struct perf_event_attr attr = make_event_attr(false, &ctx.iterate_on);
> +       struct perf_event_attr attr = make_event_attr(false, &ctx.iterate_on, 0);
>         struct sigaction action = {};
>         int i;
>
> @@ -165,7 +166,7 @@ TEST_F(sigtrap_threads, enable_event)
>         EXPECT_EQ(ctx.tids_want_signal, 0);
>         EXPECT_EQ(ctx.first_siginfo.si_addr, &ctx.iterate_on);
>         EXPECT_EQ(ctx.first_siginfo.si_perf_type, PERF_TYPE_BREAKPOINT);
> -       EXPECT_EQ(ctx.first_siginfo.si_perf_data, TEST_SIG_DATA(&ctx.iterate_on));
> +       EXPECT_EQ(ctx.first_siginfo.si_perf_data, TEST_SIG_DATA(&ctx.iterate_on, 0));
>
>         /* Check enabled for parent. */
>         ctx.iterate_on = 0;
> @@ -175,7 +176,7 @@ TEST_F(sigtrap_threads, enable_event)
>  /* Test that modification propagates to all inherited events. */
>  TEST_F(sigtrap_threads, modify_and_enable_event)
>  {
> -       struct perf_event_attr new_attr = make_event_attr(true, &ctx.iterate_on);
> +       struct perf_event_attr new_attr = make_event_attr(true, &ctx.iterate_on, 42);
>
>         EXPECT_EQ(ioctl(self->fd, PERF_EVENT_IOC_MODIFY_ATTRIBUTES, &new_attr), 0);
>         run_test_threads(_metadata, self);
> @@ -184,7 +185,7 @@ TEST_F(sigtrap_threads, modify_and_enable_event)
>         EXPECT_EQ(ctx.tids_want_signal, 0);
>         EXPECT_EQ(ctx.first_siginfo.si_addr, &ctx.iterate_on);
>         EXPECT_EQ(ctx.first_siginfo.si_perf_type, PERF_TYPE_BREAKPOINT);
> -       EXPECT_EQ(ctx.first_siginfo.si_perf_data, TEST_SIG_DATA(&ctx.iterate_on));
> +       EXPECT_EQ(ctx.first_siginfo.si_perf_data, TEST_SIG_DATA(&ctx.iterate_on, 42));
>
>         /* Check enabled for parent. */
>         ctx.iterate_on = 0;
> @@ -204,7 +205,7 @@ TEST_F(sigtrap_threads, signal_stress)
>         EXPECT_EQ(ctx.tids_want_signal, 0);
>         EXPECT_EQ(ctx.first_siginfo.si_addr, &ctx.iterate_on);
>         EXPECT_EQ(ctx.first_siginfo.si_perf_type, PERF_TYPE_BREAKPOINT);
> -       EXPECT_EQ(ctx.first_siginfo.si_perf_data, TEST_SIG_DATA(&ctx.iterate_on));
> +       EXPECT_EQ(ctx.first_siginfo.si_perf_data, TEST_SIG_DATA(&ctx.iterate_on, 0));
>  }
>
>  TEST_HARNESS_MAIN
> --
> 2.35.0.rc2.247.g8bbb082509-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ