seccomp_syscall_test1: use ftruncate instead of kcmp

kcmp is often missing: https://man7.org/linux/man-pages/man2/kcmp.2.html

> Before Linux 5.12, this system call is available only if the
> kernel is configured with CONFIG_CHECKPOINT_RESTORE, since the
> original purpose of the system call was for the
> checkpoint/restore in user space (CRIU) feature.  (The
> alternative to this system call would have been to expose
> suitable process information via the proc(5) filesystem; this was
> deemed to be unsuitable for security reasons.)  Since Linux 5.12,
> this system call is also available if the kernel is configured
> with CONFIG_KCMP.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
Akihiro Suda
2023-12-15 11:23:01 +09:00
parent 30dc98f577
commit 053f6a0dca
2 changed files with 7 additions and 8 deletions
+4 -4
View File
@@ -57,10 +57,10 @@ int main(void)
syscall_assert(raw(process_vm_writev, 0, NULL, 0, NULL, 0, ~0), -EPERM);
// Multiple arguments with AND rules.
syscall_assert(raw(kcmp, 0, 1337, 0, 0, 0), -ESRCH);
syscall_assert(raw(kcmp, 0, 0, 0, 0, 0), -EPERM);
syscall_assert(raw(kcmp, 500, 1337, 0, 0, 0), -EPERM);
syscall_assert(raw(kcmp, 500, 500, 0, 0, 0), -EPERM);
syscall_assert(raw(ftruncate, 123456789, 1337), -EBADF);
syscall_assert(raw(ftruncate, 123456789, 0), -EPERM);
syscall_assert(raw(ftruncate, 500, 1337), -EPERM);
syscall_assert(raw(ftruncate, 500, 500), -EPERM);
// Multiple rules for the same syscall.
syscall_assert(raw(dup3, 0, -100, 0xFFFF), -EPERM);
+3 -4
View File
@@ -79,8 +79,6 @@
"fstatfs",
"fstatfs64",
"fsync",
"ftruncate",
"ftruncate64",
"futex",
"futex_time64",
"futimesat",
@@ -380,12 +378,13 @@
{
"action": "SCMP_ACT_ALLOW",
"names": [
"kcmp"
"ftruncate",
"ftruncate64"
],
"args": [
{
"index": 0,
"value": 0,
"value": 123456789,
"op": "SCMP_CMP_EQ"
},
{