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 --- 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