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] [day] [month] [year] [list]
Message-ID: <aFGkVh-rs2ZqcL6g@x1.local>
Date: Tue, 17 Jun 2025 13:22:30 -0400
From: Peter Xu <peterx@...hat.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Ujwal Kundur <ujwal.kundur@...il.com>, shuah@...nel.org,
	jackmanb@...gle.com, linux-kernel@...r.kernel.org,
	linux-kselftest@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH v5 1/1] selftests/mm/uffd: Refactor non-composite global
 vars into struct

On Tue, Jun 17, 2025 at 11:52:52AM -0400, Peter Xu wrote:
> On Mon, Jun 16, 2025 at 05:26:18PM -0700, Andrew Morton wrote:
> > On Mon, 16 Jun 2025 15:34:06 +0530 Ujwal Kundur <ujwal.kundur@...il.com> wrote:
> > 
> > > Refactor macros and non-composite global variable definitions into a
> > > struct that is defined at the start of a test and is passed around
> > > instead of relying on global vars.
> > 
> > Well I guess that's nicer.
> > 
> > >  5 files changed, 616 insertions(+), 542 deletions(-)
> > 
> > It needs to be!
> > 
> > Thanks, I'll queue it for testing while Peter thinks about it :)
> 
> I didn't pay much attention on this one as I saw Brandan was actively
> reviewing it, which was great.
> 
> This is definitely an improvement to the test.  Thanks both!

I did give it a quick run today, but I found I hit this:

$ ./uffd-unit-tests
Testing UFFDIO_API (with syscall)... done
Testing UFFDIO_API (with /dev/userfaultfd)... done
Testing register-ioctls on anon... done
ERROR: munmap (errno=22, @uffd-common.c:277)

IIUC it's because after moving most globals to stack, they are not properly
zero-initialized anymore. In this case it failed at MEM_ANON of
register-ioctls test, trying to munmap() some address that will start to be
random garbage since it's on the stack.  So maybe we at least need
something like this?

diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c
index bed96f41c578..0b66ca3e7b82 100644
--- a/tools/testing/selftests/mm/uffd-unit-tests.c
+++ b/tools/testing/selftests/mm/uffd-unit-tests.c
@@ -1744,7 +1744,7 @@ int main(int argc, char *argv[])
                        mem_type = &mem_types[j];
 
                        /* Initialize global test options */
-                       uffd_global_test_opts_t gopts;
+                       uffd_global_test_opts_t gopts = { 0 };
 
                        gopts.map_shared = mem_type->shared;
                        uffd_test_ops = mem_type->mem_ops;

Even with that, it fails somewhere later.

Ujwal, can you reproduce these issues and have a look?

Thanks,

-- 
Peter Xu


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ