dcavalca / rpms / systemd

Forked from rpms/systemd 4 months ago
Clone
2aacef
From b2d259a82329e37b0f369e9951f19a067cb8bfb4 Mon Sep 17 00:00:00 2001
2aacef
From: Sam James <sam@gentoo.org>
2aacef
Date: Fri, 18 Nov 2022 07:18:18 +0000
2aacef
Subject: [PATCH] nspawn: allow sched_rr_get_interval_time64 through seccomp
2aacef
 filter
2aacef
2aacef
We only allow a selected subset of syscalls from nspawn containers
2aacef
and don't list any time64 variants (needed for 32-bit arches when
2aacef
built using TIME_BITS=64, which is relatively new).
2aacef
2aacef
We allow sched_rr_get_interval which cpython's test suite makes
2aacef
use of, but we don't allow sched_rr_get_interval_time64.
2aacef
2aacef
The test failures when run in an arm32 nspawn container on an arm64 host
2aacef
were as follows:
2aacef
```
2aacef
======================================================================
2aacef
ERROR: test_sched_rr_get_interval (test.test_posix.PosixTester.test_sched_rr_get_interval)
2aacef
----------------------------------------------------------------------
2aacef
Traceback (most recent call last):
2aacef
  File "/var/tmp/portage/dev-lang/python-3.11.0_p1/work/Python-3.11.0/Lib/test/test_posix.py", line 1180, in test_sched_rr_get_interval
2aacef
    interval = posix.sched_rr_get_interval(0)
2aacef
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2aacef
PermissionError: [Errno 1] Operation not permitted
2aacef
```
2aacef
2aacef
Then strace showed:
2aacef
```
2aacef
sched_rr_get_interval_time64(0, 0xffbbd4a0) = -1 EPERM (Operation not permitted)
2aacef
```
2aacef
2aacef
This appears to be the only time64 syscall that isn't already included one of
2aacef
the sets listed in nspawn-seccomp.c that has a non-time64 variant. Checked
2aacef
over each of the time64 syscalls known to systemd and verified that none
2aacef
of the others had a non-time64-variant whitelisted in nspawn other than
2aacef
sched_rr_get_interval.
2aacef
2aacef
Bug: https://bugs.gentoo.org/880131
2aacef
(cherry picked from commit b9e7f22c2d80930cad36ae53e66e42a2996dca4a)
2aacef
2aacef
Related: #2138081
2aacef
---
2aacef
 src/nspawn/nspawn-seccomp.c | 1 +
2aacef
 1 file changed, 1 insertion(+)
2aacef
2aacef
diff --git a/src/nspawn/nspawn-seccomp.c b/src/nspawn/nspawn-seccomp.c
2aacef
index 77f4c2ac88..27044fadd2 100644
2aacef
--- a/src/nspawn/nspawn-seccomp.c
2aacef
+++ b/src/nspawn/nspawn-seccomp.c
2aacef
@@ -88,6 +88,7 @@ static int add_syscall_filters(
2aacef
                 { 0,                  "sched_getparam"         },
2aacef
                 { 0,                  "sched_getscheduler"     },
2aacef
                 { 0,                  "sched_rr_get_interval"  },
2aacef
+                { 0,                  "sched_rr_get_interval_time64" },
2aacef
                 { 0,                  "sched_yield"            },
2aacef
                 { 0,                  "seccomp"                },
2aacef
                 { 0,                  "sendfile"               },