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:   Fri, 24 Feb 2023 09:37:08 -0800
From:   James Houghton <jthoughton@...gle.com>
To:     Mike Kravetz <mike.kravetz@...cle.com>,
        Muchun Song <songmuchun@...edance.com>,
        Peter Xu <peterx@...hat.com>,
        Andrew Morton <akpm@...ux-foundation.org>
Cc:     David Hildenbrand <david@...hat.com>,
        David Rientjes <rientjes@...gle.com>,
        Axel Rasmussen <axelrasmussen@...gle.com>,
        Mina Almasry <almasrymina@...gle.com>,
        "Zach O'Keefe" <zokeefe@...gle.com>,
        Manish Mishra <manish.mishra@...anix.com>,
        Naoya Horiguchi <naoya.horiguchi@....com>,
        "Dr . David Alan Gilbert" <dgilbert@...hat.com>,
        "Matthew Wilcox (Oracle)" <willy@...radead.org>,
        Vlastimil Babka <vbabka@...e.cz>,
        Baolin Wang <baolin.wang@...ux.alibaba.com>,
        Miaohe Lin <linmiaohe@...wei.com>,
        Yang Shi <shy828301@...il.com>,
        Frank van der Linden <fvdl@...gle.com>,
        Jiaqi Yan <jiaqiyan@...gle.com>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 46/46] selftests/mm: add HGM UFFDIO_CONTINUE and
 hwpoison tests

> +static int test_fork(int uffd, char *primary_map, size_t len)
> +{
> +       int status;
> +       int ret = 0;
> +       pid_t pid;
> +       pthread_t uffd_thd;
> +
> +       /*
> +        * UFFD_FEATURE_EVENT_FORK will put fork event on the userfaultfd,
> +        * which we must read, otherwise we block fork(). Setup a thread to
> +        * read that event now.
> +        *
> +        * Page fault events should result in a SIGBUS, so we expect only a
> +        * single event from the uffd (the fork event).
> +        */
> +       if (read_event_from_uffd(&uffd, &uffd_thd))
> +               return -1;
> +
> +       pid = fork();
> +
> +       if (!pid) {
> +               /*
> +                * Because we have UFFDIO_REGISTER_MODE_WP and
> +                * UFFD_FEATURE_EVENT_FORK, the page tables should be copied
> +                * exactly.
> +                *
> +                * Check that everything except that last 4K has correct
> +                * contents, and then check that the last 4K gets a SIGBUS.
> +                */
> +               printf(PREFIX "child validating...\n");
> +               ret = verify_contents(primary_map, len, false) ||
> +                       test_sigbus(primary_map + len - 1, false);
> +               ret = 0;
> +               exit(ret ? 1 : 0);
> +       } else {
> +               /* wait for the child to finish. */
> +               waitpid(pid, &status, 0);
> +               ret = WEXITSTATUS(status);
> +               if (!ret) {
> +                       printf(PREFIX "parent validating...\n");
> +                       /* Same check as the child. */
> +                       ret = verify_contents(primary_map, len, false) ||
> +                               test_sigbus(primary_map + len - 1, false);
> +                       ret = 0;

I'm not sure how these 'ret = 0's got here -- they will be removed.

> +               }
> +       }

This else block also runs when fork() fails; we need to fail the test instead.

> +
> +       pthread_join(uffd_thd, NULL);
> +       return ret;
> +
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ