[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250825145719.29455-6-linyongting@bytedance.com>
Date: Mon, 25 Aug 2025 22:57:08 +0800
From: Yongting Lin <linyongting@...edance.com>
To: anthony.yznaga@...cle.com,
khalid@...nel.org,
shuah@...nel.org,
linyongting@...edance.com
Cc: linux-kernel@...r.kernel.org,
linux-kselftest@...r.kernel.org,
akpm@...ux-foundation.org,
linux-mm@...ck.org
Subject: [PATCH 5/8] mshare: selftests: Add test case ioctl unmap
This test case aims to verify whether the process with guest mm will
segfault when VMA of host mm is unmaped via ioctl(MSHAREFS_UNMAP).
Signed-off-by: Yongting Lin <linyongting@...edance.com>
---
tools/testing/selftests/mshare/basic.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/tools/testing/selftests/mshare/basic.c b/tools/testing/selftests/mshare/basic.c
index 2347d30adfee..16d1f63c3ebe 100644
--- a/tools/testing/selftests/mshare/basic.c
+++ b/tools/testing/selftests/mshare/basic.c
@@ -85,4 +85,24 @@ TEST_F(basic, shared_mem)
ASSERT_EQ(memcmp(addr, STRING, sizeof(STRING)), 0);
}
+TEST_F_SIGNAL(basic, ioctl_unmap, SIGSEGV)
+{
+ char *addr;
+ int fd;
+
+ fd = open(self->filename, O_RDWR, 0600);
+ addr = mmap(NULL, self->allocate_size, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, 0);
+ ASSERT_NE(addr, MAP_FAILED);
+ addr[0] = 'M';
+
+ /* munmap vma for host mm */
+ mshare_ioctl_munmap(fd, self->allocate_size);
+ /*
+ * Will generate SIGSEGV signal as ioctl has already cleaned
+ * shared page table
+ */
+ addr[0] = 'D';
+}
+
TEST_HARNESS_MAIN
--
2.20.1
Powered by blists - more mailing lists