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]
Date:   Thu, 12 Nov 2020 16:59:35 +0100
From:   Alexander Potapenko <glider@...gle.com>
To:     Andrey Konovalov <andreyknvl@...gle.com>
Cc:     Catalin Marinas <catalin.marinas@....com>,
        Will Deacon <will.deacon@....com>,
        Vincenzo Frascino <vincenzo.frascino@....com>,
        Dmitry Vyukov <dvyukov@...gle.com>,
        Andrey Ryabinin <aryabinin@...tuozzo.com>,
        Marco Elver <elver@...gle.com>,
        Evgenii Stepanov <eugenis@...gle.com>,
        Branislav Rankov <Branislav.Rankov@....com>,
        Kevin Brodsky <kevin.brodsky@....com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        kasan-dev <kasan-dev@...glegroups.com>,
        Linux ARM <linux-arm-kernel@...ts.infradead.org>,
        Linux Memory Management List <linux-mm@...ck.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v9 44/44] kselftest/arm64: Check GCR_EL1 after context switch

On Tue, Nov 10, 2020 at 11:12 PM Andrey Konovalov <andreyknvl@...gle.com> wrote:
>
> From: Vincenzo Frascino <vincenzo.frascino@....com>
>
> This test is specific to MTE and verifies that the GCR_EL1 register
> is context switched correctly.
>
> It spawn 1024 processes and each process spawns 5 threads. Each thread

Nit: "spawns"


> +       srand(time(NULL) ^ (pid << 16) ^ (tid << 16));
> +
> +       prctl_tag_mask = rand() % 0xffff;

Nit: if you want values between 0 and 0xffff you probably want to use
bitwise AND.


> +
> +int execute_test(pid_t pid)
> +{
> +       pthread_t thread_id[MAX_THREADS];
> +       int thread_data[MAX_THREADS];
> +
> +       for (int i = 0; i < MAX_THREADS; i++)
> +               pthread_create(&thread_id[i], NULL,
> +                              execute_thread, (void *)&pid);

It might be simpler to call getpid() in execute_thread() instead.

> +int mte_gcr_fork_test()
> +{
> +       pid_t pid[NUM_ITERATIONS];
> +       int results[NUM_ITERATIONS];
> +       pid_t cpid;
> +       int res;
> +
> +       for (int i = 0; i < NUM_ITERATIONS; i++) {
> +               pid[i] = fork();
> +
> +               if (pid[i] == 0) {

pid[i] isn't used anywhere else. Did you want to keep the pids to
ensure that all children finished the work?
If not, we can probably go with a scalar here.


> +       for (int i = 0; i < NUM_ITERATIONS; i++) {
> +               wait(&res);
> +
> +               if(WIFEXITED(res))
> +                       results[i] = WEXITSTATUS(res);
> +               else
> +                       --i;

Won't we get stuck in this loop if fork() returns -1 for one of the processes?

> +       }
> +
> +       for (int i = 0; i < NUM_ITERATIONS; i++)
> +               if (results[i] == KSFT_FAIL)
> +                       return KSFT_FAIL;
> +
> +       return KSFT_PASS;
> +}
> +


-- 
Alexander Potapenko
Software Engineer

Google Germany GmbH
Erika-Mann-Straße, 33
80636 München

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ