Re: [PATCH v3 23/23] x86/vdso/selftest: Add a test for unmapping vDSO

From: Shuah Khan
Date: Fri Jun 11 2021 - 14:45:09 EST


On 6/11/21 12:37 PM, Dmitry Safonov wrote:
On 6/11/21 7:21 PM, Shuah Khan wrote:
On 6/11/21 12:02 PM, Dmitry Safonov wrote:
Output for landing on x86:
[root@localhost ~]# ./test_munmap_vdso_64
    AT_SYSINFO_EHDR is 0x7fffead9f000
[NOTE]    unmapping vDSO: [0x7fffead9f000, 0x7fffeada0000]
[NOTE]    vDSO partial move failed, will try with bigger size
[NOTE]    unmapping vDSO: [0x7fffead9f000, 0x7fffeada1000]
[OK]
[root@localhost ~]# ./test_munmap_vdso_32
    AT_SYSINFO_EHDR is 0xf7eef000
[NOTE]    unmapping vDSO: [0xf7eef000, 0xf7ef0000]
[NOTE]    vDSO partial move failed, will try with bigger size
[NOTE]    unmapping vDSO: [0xf7eef000, 0xf7ef1000]
[OK]

The test also can check force_sigsegv(SIGSEGV) in do_fast_syscall_32():
[root@localhost ~]# ./test_munmap_vdso_32 sysenter
[NOTE]    Using sysenter after munmap
    AT_SYSINFO_EHDR is 0xf7efe000
[NOTE]    unmapping vDSO: [0xf7efe000, 0xf7eff000]
[NOTE]    vDSO partial move failed, will try with bigger size
[NOTE]    unmapping vDSO: [0xf7efe000, 0xf7f00000]
[OK]    32-bit process gets segfault on fast syscall with unmapped vDSO

Cc: Shuah Khan <shuah@xxxxxxxxxx>
Signed-off-by: Dmitry Safonov <dima@xxxxxxxxxx>
---
  tools/testing/selftests/x86/.gitignore        |   1 +
  tools/testing/selftests/x86/Makefile          |  11 +-
  .../testing/selftests/x86/test_munmap_vdso.c  | 151 ++++++++++++++++++
  3 files changed, 158 insertions(+), 5 deletions(-)
  create mode 100644 tools/testing/selftests/x86/test_munmap_vdso.c


I can take this through kselftest tree for 5.14 - are there any
dependencies on x86 tree, I should be aware of?

The test should work without other patches from the set.
So I guess, it's good to go by it's own.

The only note I can make here is that without previous patches this part
of the commit message is not exactly precise:
The test also can check force_sigsegv(SIGSEGV) in
do_fast_syscall_32()

I will still crash, but not by the kernel enforcement, rather with
landing on the area where vdso was previously mapped.


Playing it safe, here is my Ack for it to go through x86 tree

Acked-by: Shuah Khan <skhan@xxxxxxxxxxxxxxxxxxx>

thanks,
-- Shuah