]> git.baikalelectronics.ru Git - kernel.git/commit
timerfd: Only check CAP_WAKE_ALARM when it is needed
authorStephen Smalley <sds@tycho.nsa.gov>
Fri, 17 Feb 2017 15:13:59 +0000 (10:13 -0500)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 1 Mar 2017 11:53:44 +0000 (12:53 +0100)
commitb7dadf1fb5f6280174c1ad32b3d9d5da8f6dc559
treeff7243cae64f145556c8b0a5d49d324c19956d9c
parent19c8c9c4fd51fa41c3bdcbe2876120e03c685d70
timerfd: Only check CAP_WAKE_ALARM when it is needed

timerfd_create() and do_timerfd_settime() evaluate capable(CAP_WAKE_ALARM)
unconditionally although CAP_WAKE_ALARM is only required for
CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM.

This can cause extraneous audit messages when using a LSM such as SELinux,
incorrectly causes PF_SUPERPRIV to be set even when no privilege was
exercised, and is inefficient.

Flip the order of the tests in both functions so that we only call
capable() if the capability is truly required for the operation.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Cc: linux-security-module@vger.kernel.org
Cc: selinux@tycho.nsa.gov
Link: http://lkml.kernel.org/r/1487344439-22293-1-git-send-email-sds@tycho.nsa.gov
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
fs/timerfd.c