All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v1] security/dirtyc0w_shmem: Fix remaining cases where UFFD_FEATURE_MINOR_SHMEM is absent
@ 2022-11-25 10:52 David Hildenbrand
  2022-11-25 11:12 ` Petr Vorel
  2022-11-25 11:20 ` Martin Doucha
  0 siblings, 2 replies; 6+ messages in thread
From: David Hildenbrand @ 2022-11-25 10:52 UTC (permalink / raw)
  To: ltp; +Cc: David Hildenbrand

When UFFD_FEATURE_MINOR_SHMEM is not defined, we still have to make the
checkpoint happy, otherwise our parent process will run into a timeout.
Further, we have to test if UFFD_FEATURE_MINOR_SHMEM is really returned by
the UFFD_API ioctl: if the kernel knows about the feature but doesn't
support it, it will be masked off.

Reported-by: Martin Doucha <mdoucha@suse.cz>
Cc: Petr Vorel <pvorel@suse.cz>
Cc: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 .../dirtyc0w_shmem/dirtyc0w_shmem_child.c        | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/security/dirtyc0w_shmem/dirtyc0w_shmem_child.c b/testcases/kernel/security/dirtyc0w_shmem/dirtyc0w_shmem_child.c
index cb2e9df0c..c117c6f39 100644
--- a/testcases/kernel/security/dirtyc0w_shmem/dirtyc0w_shmem_child.c
+++ b/testcases/kernel/security/dirtyc0w_shmem/dirtyc0w_shmem_child.c
@@ -24,12 +24,12 @@
 #include <linux/userfaultfd.h>
 #endif
 
-#ifdef UFFD_FEATURE_MINOR_SHMEM
-
 #define TST_NO_DEFAULT_MAIN
 #include "tst_test.h"
 #include "tst_safe_macros.h"
 #include "tst_safe_pthread.h"
+
+#ifdef UFFD_FEATURE_MINOR_SHMEM
 #include "lapi/syscalls.h"
 
 #define TMP_DIR "tmp_dirtyc0w_shmem"
@@ -162,6 +162,10 @@ retry:
 			"Could not create userfault file descriptor");
 	}
 
+	if (!(uffdio_api.features & UFFD_FEATURE_MINOR_SHMEM))
+		tst_brk(TCONF,
+			"System does not have userfaultfd minor fault support for shmem");
+
 	uffdio_register.range.start = (unsigned long) map;
 	uffdio_register.range.len = page_size;
 	uffdio_register.mode = UFFDIO_REGISTER_MODE_MINOR;
@@ -236,6 +240,10 @@ int main(void)
 	return 0;
 }
 #else /* UFFD_FEATURE_MINOR_SHMEM */
-#include "tst_test.h"
-TST_TEST_TCONF("System does not have userfaultfd minor fault support for shmem");
+int main(void)
+{
+	tst_reinit();
+	TST_CHECKPOINT_WAKE(0);
+	tst_brk(TCONF, "System does not have userfaultfd minor fault support for shmem");
+}
 #endif /* UFFD_FEATURE_MINOR_SHMEM */
-- 
2.38.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-11-25 12:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-25 10:52 [LTP] [PATCH v1] security/dirtyc0w_shmem: Fix remaining cases where UFFD_FEATURE_MINOR_SHMEM is absent David Hildenbrand
2022-11-25 11:12 ` Petr Vorel
2022-11-25 11:16   ` David Hildenbrand
2022-11-25 12:34     ` Petr Vorel
2022-11-25 11:20 ` Martin Doucha
2022-11-25 12:19   ` David Hildenbrand

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.