]> git.baikalelectronics.ru Git - kernel.git/commit
sched: only perform capability check on privileged operation
authorChristian Göttsche <cgzones@googlemail.com>
Wed, 15 Jun 2022 15:25:04 +0000 (17:25 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 28 Jun 2022 07:08:29 +0000 (09:08 +0200)
commitcb99028e314480fa6a7e3d70b3687ecd235e32d4
treeaae5997212a93e654059896b14eb059f23e4173d
parent7266c4dd67f17a41c799ae48a09da8c43a650c13
sched: only perform capability check on privileged operation

sched_setattr(2) issues via kernel/sched/core.c:__sched_setscheduler()
a CAP_SYS_NICE audit event unconditionally, even when the requested
operation does not require that capability / is unprivileged, i.e. for
reducing niceness.
This is relevant in connection with SELinux, where a capability check
results in a policy decision and by default a denial message on
insufficient permission is issued.
It can lead to three undesired cases:
  1. A denial message is generated, even in case the operation was an
     unprivileged one and thus the syscall succeeded, creating noise.
  2. To avoid the noise from 1. the policy writer adds a rule to ignore
     those denial messages, hiding future syscalls, where the task
     performs an actual privileged operation, leading to hidden limited
     functionality of that task.
  3. To avoid the noise from 1. the policy writer adds a rule to allow
     the task the capability CAP_SYS_NICE, while it does not need it,
     violating the principle of least privilege.

Conduct privilged/unprivileged categorization first and perform a
capable test (and at most once) only if needed.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20220615152505.310488-1-cgzones@googlemail.com
kernel/sched/core.c