Skip to contentSkip to conversation

Add mseal() testing suite

PATCH New Andrea Cervesato 1 participant 3 messages Aug 2, 2024

lore
Share & tools
lore
#0 lore raw

v4 cover Add mseal() testing suite

Smoke test for mseal() syscall added in the kernel 6.10. All information can be found at the following link:

https://docs.kernel.org/userspace-api/mseal.html

---
Changes in v4:
- add mseal01 in runtest syscalls file
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- move memory allocation inside the child
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- don't use TST_ABI32 var anymore, but let tst_syscall handling ENOSYS
- call protection key syscalls via tst_syscall
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Andrea Cervesato (2):
Add mseal() syscall declaration
Add mseal01 test

 include/lapi/syscalls/aarch64.in           |   1 +
 include/lapi/syscalls/arc.in               |   1 +
 include/lapi/syscalls/arm.in               |   1 +
 include/lapi/syscalls/hppa.in              |   1 +
 include/lapi/syscalls/i386.in              |   1 +
 include/lapi/syscalls/ia64.in              |   1 +
 include/lapi/syscalls/loongarch.in         |   1 +
 include/lapi/syscalls/mips_n32.in          |   1 +
 include/lapi/syscalls/mips_n64.in          |   1 +
 include/lapi/syscalls/mips_o32.in          |   1 +
 include/lapi/syscalls/powerpc.in           |   1 +
 include/lapi/syscalls/powerpc64.in         |   1 +
 include/lapi/syscalls/s390.in              |   1 +
 include/lapi/syscalls/s390x.in             |   1 +
 include/lapi/syscalls/sh.in                |   1 +
 include/lapi/syscalls/sparc.in             |   1 +
 include/lapi/syscalls/sparc64.in           |   1 +
 include/lapi/syscalls/x86_64.in            |   1 +
 runtest/syscalls                           |   2 +
 testcases/kernel/syscalls/mseal/.gitignore |   1 +
 testcases/kernel/syscalls/mseal/Makefile   |   7 ++
 testcases/kernel/syscalls/mseal/mseal01.c  | 156 +++++++++++++++++++++++++++++
 22 files changed, 184 insertions(+)

---
base-commit: 8422d4680b21e6576da63c677b5d49f46b477df0
change-id: 20240607-mseal-dfac12675096

Best regards,

Signature · 5 lines
Andrea Cervesato <[email protected]>


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

PATCH v4 1/2 Add mseal() syscall declaration

From: Andrea Cervesato <[email protected]>

---
 include/lapi/syscalls/aarch64.in   | 1 +
 include/lapi/syscalls/arc.in       | 1 +
 include/lapi/syscalls/arm.in       | 1 +
 include/lapi/syscalls/hppa.in      | 1 +
 include/lapi/syscalls/i386.in      | 1 +
 include/lapi/syscalls/ia64.in      | 1 +
 include/lapi/syscalls/loongarch.in | 1 +
 include/lapi/syscalls/mips_n32.in  | 1 +
 include/lapi/syscalls/mips_n64.in  | 1 +
 include/lapi/syscalls/mips_o32.in  | 1 +
 include/lapi/syscalls/powerpc.in   | 1 +
 include/lapi/syscalls/powerpc64.in | 1 +
 include/lapi/syscalls/s390.in      | 1 +
 include/lapi/syscalls/s390x.in     | 1 +
 include/lapi/syscalls/sh.in        | 1 +
 include/lapi/syscalls/sparc.in     | 1 +
 include/lapi/syscalls/sparc64.in   | 1 +
 include/lapi/syscalls/x86_64.in    | 1 +
 18 files changed, 18 insertions(+)
include/lapi/syscalls/aarch64.in +1 -0
index ef0aa04a3..d1ff7c081 100644
@@ -301,4 +301,5 @@ landlock_add_rule 445
 landlock_restrict_self 446
 futex_waitv 449
 cachestat 451
+mseal 462
 _sysctl 1078
include/lapi/syscalls/arc.in +1 -0
index 3eaa6a8f1..265329cbe 100644
@@ -321,3 +321,4 @@ landlock_add_rule 445
 landlock_restrict_self 446
 futex_waitv 449
 cachestat 451
+mseal 462
include/lapi/syscalls/arm.in +1 -0
index b52a32b6b..b49590268 100644
@@ -400,3 +400,4 @@ landlock_restrict_self (__NR_SYSCALL_BASE+446)
 memfd_secret (__NR_SYSCALL_BASE+447)
 futex_waitv (__NR_SYSCALL_BASE+449)
 cachestat (__NR_SYSCALL_BASE+451)
+mseal (__NR_SYSCALL_BASE+462)
include/lapi/syscalls/hppa.in +1 -0
index 4919ee65d..9a8832248 100644
@@ -48,3 +48,4 @@ landlock_add_rule 445
 landlock_restrict_self 446
 futex_waitv 449
 cachestat 451
+mseal 462
include/lapi/syscalls/i386.in +1 -0
index cff40957a..59c97b9b8 100644
@@ -435,3 +435,4 @@ landlock_add_rule 445
 landlock_restrict_self 446
 futex_waitv 449
 cachestat 451
+mseal 462
include/lapi/syscalls/ia64.in +1 -0
index 11d4b46f4..f08a268e8 100644
@@ -348,3 +348,4 @@ landlock_add_rule 1469
 landlock_restrict_self 1470
 futex_waitv 1473
 cachestat 1475
+mseal 1486
include/lapi/syscalls/loongarch.in +1 -0
index 9bf6a7deb..29acad012 100644
@@ -306,3 +306,4 @@ process_mrelease 448
 futex_waitv 449
 set_mempolicy_home_node 450
 cachestat 451
+mseal 462
include/lapi/syscalls/mips_n32.in +1 -0
index a76c82593..260e01518 100644
@@ -375,3 +375,4 @@ landlock_add_rule 6445
 landlock_restrict_self 6446
 futex_waitv 6449
 cachestat 6451
+mseal 6462
include/lapi/syscalls/mips_n64.in +1 -0
index df991efd5..83da993ad 100644
@@ -351,3 +351,4 @@ landlock_add_rule 5445
 landlock_restrict_self 5446
 futex_waitv 5449
 cachestat 5451
+mseal 5462
include/lapi/syscalls/mips_o32.in +1 -0
index 826b7d66e..3589e0337 100644
@@ -421,3 +421,4 @@ landlock_add_rule 4445
 landlock_restrict_self 4446
 futex_waitv 4449
 cachestat 4451
+mseal 4462
include/lapi/syscalls/powerpc.in +1 -0
index 798ed9050..e39e6b69c 100644
@@ -428,3 +428,4 @@ landlock_add_rule 445
 landlock_restrict_self 446
 futex_waitv 449
 cachestat 451
+mseal 462
include/lapi/syscalls/powerpc64.in +1 -0
index 798ed9050..e39e6b69c 100644
@@ -428,3 +428,4 @@ landlock_add_rule 445
 landlock_restrict_self 446
 futex_waitv 449
 cachestat 451
+mseal 462
include/lapi/syscalls/s390.in +1 -0
index 126938095..d3426c88f 100644
@@ -415,3 +415,4 @@ landlock_add_rule 445
 landlock_restrict_self 446
 futex_waitv 449
 cachestat 451
+mseal 462
include/lapi/syscalls/s390x.in +1 -0
index 18f2496a0..02df53322 100644
@@ -363,3 +363,4 @@ landlock_add_rule 445
 landlock_restrict_self 446
 futex_waitv 449
 cachestat 451
+mseal 462
include/lapi/syscalls/sh.in +1 -0
index ae6f26050..c93271d1b 100644
@@ -409,3 +409,4 @@ landlock_add_rule 445
 landlock_restrict_self 446
 futex_waitv 449
 cachestat 451
+mseal 462
include/lapi/syscalls/sparc.in +1 -0
index 409fa2729..9be7d2e96 100644
@@ -414,3 +414,4 @@ landlock_add_rule 445
 landlock_restrict_self 446
 futex_waitv 449
 cachestat 451
+mseal 462
include/lapi/syscalls/sparc64.in +1 -0
index e13cf163e..9c80a328f 100644
@@ -379,3 +379,4 @@ landlock_add_rule 445
 landlock_restrict_self 446
 futex_waitv 449
 cachestat 451
+mseal 462
include/lapi/syscalls/x86_64.in +1 -0
index 05b1bee55..49cb1ab94 100644
@@ -356,6 +356,7 @@ landlock_add_rule 445
 landlock_restrict_self 446
 futex_waitv 449
 cachestat 451
+mseal 462
 rt_sigaction 512
 rt_sigreturn 513
 ioctl 514
Signature · 5 lines
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

PATCH v4 2/2 Add mseal01 test

In reply to Andrea Cervesato

From: Andrea Cervesato <[email protected]>

This is a smoke test that verifies if mseal() protects specific VMA portions of a process. According to documentation, the syscall should protect memory from the following actions:

- unmapping, moving to another location, and shrinking the size, via munmap() and mremap()
- moving or expanding a different VMA into the current location, via mremap()
- modifying a VMA via mmap(MAP_FIXED)
- mprotect() and pkey_mprotect()
- destructive madvice() behaviors (e.g. MADV_DONTNEED) for anonymous memory, when users don’t have write permission to the memory

Any of the described actions is recognized via EPERM errno.

---
 runtest/syscalls                           |   2 +
 testcases/kernel/syscalls/mseal/.gitignore |   1 +
 testcases/kernel/syscalls/mseal/Makefile   |   7 ++
 testcases/kernel/syscalls/mseal/mseal01.c  | 156 +++++++++++++++++++++++++++++
 4 files changed, 166 insertions(+)
runtest/syscalls +2 -0
index 9b3cba667..63abe1f77 100644
@@ -878,6 +878,8 @@ mremap04 mremap04
 mremap05 mremap05
 mremap06 mremap06
 
+mseal01 mseal01
+
 msgctl01 msgctl01
 msgctl02 msgctl02
 msgctl03 msgctl03
testcases/kernel/syscalls/mseal/.gitignore new file +1 -0
new file mode 100644
index 000000000..e13090994
@@ -0,0 +1 @@
+mseal01
testcases/kernel/syscalls/mseal/Makefile new file +7 -0
new file mode 100644
index 000000000..35317f446
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (C) 2023 SUSE LLC Andrea Cervesato <[email protected]>
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/mseal/mseal01.c new file +156 -0

156 lines not on this page · raw message

Signature · 5 lines
2.43.0


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