* [PATCH] selftests/mm/mseal_test: Fix mmap return value check in test_seal_zero_address
@ 2026-07-06 8:30 longlong yan
2026-07-06 11:24 ` Mike Rapoport
0 siblings, 1 reply; 4+ messages in thread
From: longlong yan @ 2026-07-06 8:30 UTC (permalink / raw)
To: akpm, rppt; +Cc: linux-mm, linux-kselftest, linux-kernel, longlong yan
test_seal_zero_address() uses mmap() with MAP_FIXED to map at address 0,
but only checks if the return value equals 0. If mmap() fails, it returns
MAP_FAILED ((void *)-1), not 0. The existing check FAIL_TEST_IF_FALSE(ptr == 0)
would pass when ptr == -1 (since -1 != 0 is true), causing the test to
continue with an invalid pointer.
Add a check for MAP_FAILED before verifying ptr == 0, consistent with all
other mmap() checks in this file which use FAIL_TEST_IF_FALSE(ptr != (void *)-1).
Fixes: 4926c7a52de7 ("selftest mm/mseal memory sealing")
Signed-off-by: longlong yan <yanlonglong@kylinos.cn>
---
tools/testing/selftests/mm/mseal_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/selftests/mm/mseal_test.c
index faad4833366a..a6ecc81c6aa0 100644
--- a/tools/testing/selftests/mm/mseal_test.c
+++ b/tools/testing/selftests/mm/mseal_test.c
@@ -482,7 +482,7 @@ static void test_seal_zero_address(void)
/* use mmap to change protection. */
ptr = mmap(0, size, PROT_NONE,
MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0);
- FAIL_TEST_IF_FALSE(ptr == 0);
+ FAIL_TEST_IF_FALSE(ptr == (void *)-1);
size = get_vma_size(ptr, &prot);
FAIL_TEST_IF_FALSE(size == 4 * page_size);
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] selftests/mm/mseal_test: Fix mmap return value check in test_seal_zero_address
2026-07-06 8:30 [PATCH] selftests/mm/mseal_test: Fix mmap return value check in test_seal_zero_address longlong yan
@ 2026-07-06 11:24 ` Mike Rapoport
2026-07-07 3:17 ` [PATCH v2] " longlong yan
0 siblings, 1 reply; 4+ messages in thread
From: Mike Rapoport @ 2026-07-06 11:24 UTC (permalink / raw)
To: longlong yan; +Cc: akpm, linux-mm, linux-kselftest, linux-kernel
Hi,
On Mon, Jul 06, 2026 at 04:30:48PM +0800, longlong yan wrote:
> test_seal_zero_address() uses mmap() with MAP_FIXED to map at address 0,
> but only checks if the return value equals 0. If mmap() fails, it returns
> MAP_FAILED ((void *)-1), not 0. The existing check FAIL_TEST_IF_FALSE(ptr == 0)
> would pass when ptr == -1 (since -1 != 0 is true), causing the test to
> continue with an invalid pointer.
> Add a check for MAP_FAILED before verifying ptr == 0, consistent with all
> other mmap() checks in this file which use FAIL_TEST_IF_FALSE(ptr != (void *)-1).
The changelog looks like an LLM generated. Can you please instruct your LLM
to produce more concise descriptions that communicated the gist of the
change?
> Fixes: 4926c7a52de7 ("selftest mm/mseal memory sealing")
> Signed-off-by: longlong yan <yanlonglong@kylinos.cn>
Other than that,
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> ---
> tools/testing/selftests/mm/mseal_test.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/selftests/mm/mseal_test.c
> index faad4833366a..a6ecc81c6aa0 100644
> --- a/tools/testing/selftests/mm/mseal_test.c
> +++ b/tools/testing/selftests/mm/mseal_test.c
> @@ -482,7 +482,7 @@ static void test_seal_zero_address(void)
> /* use mmap to change protection. */
> ptr = mmap(0, size, PROT_NONE,
> MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0);
> - FAIL_TEST_IF_FALSE(ptr == 0);
> + FAIL_TEST_IF_FALSE(ptr == (void *)-1);
>
> size = get_vma_size(ptr, &prot);
> FAIL_TEST_IF_FALSE(size == 4 * page_size);
> --
> 2.43.0
>
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] selftests/mm/mseal_test: Fix mmap return value check in test_seal_zero_address
2026-07-06 11:24 ` Mike Rapoport
@ 2026-07-07 3:17 ` longlong yan
2026-07-07 5:57 ` Mike Rapoport
0 siblings, 1 reply; 4+ messages in thread
From: longlong yan @ 2026-07-07 3:17 UTC (permalink / raw)
To: rppt; +Cc: akpm, linux-kernel, linux-kselftest, linux-mm, yanlonglong
The return value for a failed mmap function is MAP_FAILED.
According to the definition of FAIL_TEST_IF FALSE,ptr must be
determined to be distinct from MAP_FAILED
Fixes: 4926c7a52de7 ("selftest mm/mseal memory sealing")
Signed-off-by: longlong yan <yanlonglong@kylinos.cn>
---
tools/testing/selftests/mm/mseal_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/selftests/mm/mseal_test.c
index faad4833366a..277c8fda3f5e 100644
--- a/tools/testing/selftests/mm/mseal_test.c
+++ b/tools/testing/selftests/mm/mseal_test.c
@@ -482,7 +482,7 @@ static void test_seal_zero_address(void)
/* use mmap to change protection. */
ptr = mmap(0, size, PROT_NONE,
MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0);
- FAIL_TEST_IF_FALSE(ptr == 0);
+ FAIL_TEST_IF_FALSE(ptr != (void *)-1);
size = get_vma_size(ptr, &prot);
FAIL_TEST_IF_FALSE(size == 4 * page_size);
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] selftests/mm/mseal_test: Fix mmap return value check in test_seal_zero_address
2026-07-07 3:17 ` [PATCH v2] " longlong yan
@ 2026-07-07 5:57 ` Mike Rapoport
0 siblings, 0 replies; 4+ messages in thread
From: Mike Rapoport @ 2026-07-07 5:57 UTC (permalink / raw)
To: longlong yan; +Cc: akpm, linux-kernel, linux-kselftest, linux-mm
On Tue, Jul 07, 2026 at 11:17:45AM +0800, longlong yan wrote:
> The return value for a failed mmap function is MAP_FAILED.
> According to the definition of FAIL_TEST_IF FALSE,ptr must be
> determined to be distinct from MAP_FAILED
>
> Fixes: 4926c7a52de7 ("selftest mm/mseal memory sealing")
> Signed-off-by: longlong yan <yanlonglong@kylinos.cn>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> ---
> tools/testing/selftests/mm/mseal_test.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/selftests/mm/mseal_test.c
> index faad4833366a..277c8fda3f5e 100644
> --- a/tools/testing/selftests/mm/mseal_test.c
> +++ b/tools/testing/selftests/mm/mseal_test.c
> @@ -482,7 +482,7 @@ static void test_seal_zero_address(void)
> /* use mmap to change protection. */
> ptr = mmap(0, size, PROT_NONE,
> MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0);
> - FAIL_TEST_IF_FALSE(ptr == 0);
> + FAIL_TEST_IF_FALSE(ptr != (void *)-1);
>
> size = get_vma_size(ptr, &prot);
> FAIL_TEST_IF_FALSE(size == 4 * page_size);
> --
> 2.43.0
>
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-07 5:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06 8:30 [PATCH] selftests/mm/mseal_test: Fix mmap return value check in test_seal_zero_address longlong yan
2026-07-06 11:24 ` Mike Rapoport
2026-07-07 3:17 ` [PATCH v2] " longlong yan
2026-07-07 5:57 ` Mike Rapoport
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox