seccomp: also refuse sched_setattr() in RestrictRealtime=
RestrictRealtime= only filtered sched_setscheduler(). sched_setattr() can switch a task to SCHED_FIFO and SCHED_RR as well, and is the only way to get SCHED_DEADLINE, so a process that is otherwise allowed to use realtime scheduling (CAP_SYS_NICE, or a non-zero RLIMIT_RTPRIO) could bypass the restriction. The policy is passed in a struct sched_attr by pointer, which seccomp cannot inspect, so refuse the syscall altogether. This also affects non-realtime callers of sched_setattr() (nice, utilization clamps), which now get the same error as the refused policies. Document this in systemd.exec(5) and extend the test. CPUSchedulingPolicy= is applied through sched_setattr(), so a service manager running under RestrictRealtime=yes (e.g. in a container) could no longer start units with a non-realtime policy. Fall back to sched_setscheduler() on EPERM, which the filter still allows for these policies. This is not possible with CPUSchedulingResetOnFork=yes, as the filter refuses SCHED_RESET_ON_FORK too, so setting the policy still fails in that case. Signed-off-by: Ricardo Branco <rbranco@suse.de> (cherry picked from commit 590ff29a641a4ddb736ea59303af9721fc6c1400)
This commit is contained in:
committed by
Luca Boccassi
parent
5e4d9b64f5
commit
2d3dd0a4fc
@@ -2803,7 +2803,10 @@ RestrictNamespaces=~cgroup net</programlisting>
|
||||
for details about these scheduling policies. Realtime scheduling policies may be used to monopolize CPU
|
||||
time for longer periods of time, and may hence be used to lock up or otherwise trigger Denial-of-Service
|
||||
situations on the system. It is hence recommended to restrict access to realtime scheduling to the few programs
|
||||
that actually require them. Defaults to off.</para>
|
||||
that actually require them. Note that the scheduling policy passed to
|
||||
<citerefentry project='man-pages'><refentrytitle>sched_setattr</refentrytitle><manvolnum>2</manvolnum></citerefentry>
|
||||
cannot be inspected by the system call filter, hence that system call is refused altogether, including
|
||||
for non-realtime uses. Defaults to off.</para>
|
||||
|
||||
<xi:include href="version-info.xml" xpointer="v231"/></listitem>
|
||||
</varlistentry>
|
||||
|
||||
Reference in New Issue
Block a user