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: <a9e9a1a7-346a-475e-961c-ec8568613b45@kili.mountain>
Date:   Mon, 15 May 2023 14:51:54 +0300
From:   Dan Carpenter <dan.carpenter@...aro.org>
To:     Naresh Kamboju <naresh.kamboju@...aro.org>,
        Ricardo CaƱuelo 
        <ricardo.canuelo@...labora.com>
Cc:     open list <linux-kernel@...r.kernel.org>,
        "open list:KERNEL SELFTEST FRAMEWORK" 
        <linux-kselftest@...r.kernel.org>, lkft-triage@...ts.linaro.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Arnd Bergmann <arnd@...db.de>,
        Ard Biesheuvel <ardb@...nel.org>,
        Shuah Khan <shuah@...nel.org>,
        Anders Roxell <anders.roxell@...aro.org>
Subject: Re: selftests: mincore: mincore_selftest fails only on qemu-armv7

On Mon, May 15, 2023 at 03:29:02PM +0530, Naresh Kamboju wrote:
> The selftests: mincore: mincore_selftest fails only on qemu-armv7 running
> Linux next, mainline and stable branches.
> 
> Reported-by: Linux Kernel Functional Testing <lkft@...aro.org>
> 
> # selftests: mincore: mincore_selftest
> # TAP version 13
> # 1..5
> # # Starting 5 tests from 1 test cases.
> # #  RUN           global.basic_interface ...
> # #            OK  global.basic_interface
> # ok 1 global.basic_interface
> # #  RUN           global.check_anonymous_locked_pages ...
> # #            OK  global.check_anonymous_locked_pages
> # ok 2 global.check_anonymous_locked_pages
> # #  RUN           global.check_huge_pages ...
> # # mincore_selftest.c:156:check_huge_pages:mmap error: Invalid argument
> # # mincore_selftest.c:159:check_huge_pages:Expected 0 (0) == retval (-1)

The test is wrong.  It doesn't accept -EINVAL as a valid failure.

tools/testing/selftests/mincore/mincore_selftest.c
   139  TEST(check_huge_pages)
   140  {
   141          unsigned char vec[1];
   142          char *addr;
   143          int retval;
   144          int page_size;
   145  
   146          page_size = sysconf(_SC_PAGESIZE);
   147  
   148          errno = 0;
   149          addr = mmap(NULL, page_size, PROT_READ | PROT_WRITE,
   150                  MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB,
   151                  -1, 0);
   152          if (addr == MAP_FAILED) {
   153                  if (errno == ENOMEM)

On Armv7 is a 32bit machine so HUGETLB isn't enabled and the errno can
be -EINVAL.  It's has returned this for 10 years.

   154                          SKIP(return, "No huge pages available.");
   155                  else
   156                          TH_LOG("mmap error: %s", strerror(errno));
   157          }
   158          retval = mincore(addr, page_size, vec);
   159          ASSERT_EQ(0, retval);

mm/mmap.c
  1405                  }
  1406          } else if (flags & MAP_HUGETLB) {
  1407                  struct hstate *hs;
  1408  
  1409                  hs = hstate_sizelog((flags >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK);
  1410                  if (!hs)
  1411                          return -EINVAL;
                                ^^^^^^^^^^^^^^^
hstate_sizelog() return NULL when CONFIG_HUGETLB_PAGE is disabled.

  1412  
  1413                  len = ALIGN(len, huge_page_size(hs));

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ