diff mbox series

[v1,1/2] security/dirtyc0w_shmem: Fix runtime absence of UFFD_FEATURE_MINOR_SHMEM

Message ID 20221125123129.102360-2-david@redhat.com
State Accepted
Headers show
Series security/dirtyc0w_shmem: Two fixes | expand

Commit Message

David Hildenbrand Nov. 25, 2022, 12:31 p.m. UTC
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>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 .../kernel/security/dirtyc0w_shmem/dirtyc0w_shmem_child.c     | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Petr Vorel Nov. 25, 2022, 12:37 p.m. UTC | #1
Hi all,

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Fixes: a46f8956f ("security/dirtyc0w_shmem: Add new test for CVE-2022-2590")

Waiting little bit for Martin's input (not required) before merging.

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/kernel/security/dirtyc0w_shmem/dirtyc0w_shmem_child.c b/testcases/kernel/security/dirtyc0w_shmem/dirtyc0w_shmem_child.c
index cb2e9df0c..45cc0ee76 100644
--- a/testcases/kernel/security/dirtyc0w_shmem/dirtyc0w_shmem_child.c
+++ b/testcases/kernel/security/dirtyc0w_shmem/dirtyc0w_shmem_child.c
@@ -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;