[PATCH 2/5] selftests/prctl: skip the anonymous VMA naming test when unsupported

From: Sasha Levin

Date: Wed Oct 14 2026 - 16:06:25 EST


PR_SET_VMA_ANON_NAME is only implemented when CONFIG_ANON_VMA_NAME is
enabled. Without it, set_anon_vma_name() returns -EINVAL for every
request, so set-anon-vma-name-test reports a failure on kernels that
simply do not provide the feature:

# renaming: Expected rename_vma(...) (-22) >= 0
not ok 1 vma.renaming

Probe the interface in the fixture setup by clearing the name of the
anonymous mapping, which succeeds whenever the feature is available,
and skip the test when the kernel rejects the request with EINVAL.

Fixes: 5290586186d2 ("selftests: prctl: Add new prctl test for PR_SET_VMA action")
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
tools/testing/selftests/prctl/set-anon-vma-name-test.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/tools/testing/selftests/prctl/set-anon-vma-name-test.c b/tools/testing/selftests/prctl/set-anon-vma-name-test.c
index 5f9589534da8e..d3854ccb2a7a3 100644
--- a/tools/testing/selftests/prctl/set-anon-vma-name-test.c
+++ b/tools/testing/selftests/prctl/set-anon-vma-name-test.c
@@ -93,6 +93,9 @@ FIXTURE_SETUP(vma) {
MAP_PRIVATE, self->fd_not_anon, 0);
ASSERT_NE(self->ptr_not_anon, MAP_FAILED);
close(self->fd_not_anon);
+
+ if (rename_vma((unsigned long)self->ptr_anon, AREA_SIZE, NULL) == -EINVAL)
+ SKIP(return, "PR_SET_VMA_ANON_NAME is not supported");
}

FIXTURE_TEARDOWN(vma) {
--
2.53.0