fs/timerfd: reject ALARM timerfds without CAP_WAKE_ALARM
Subsystems (2)
PATCH 1/1 fs/timerfd: reject ALARM timerfds without CAP_WAKE_ALARM
From: Eric Caruso <[email protected]>
timerfd gives processes a way to set wake alarms, but unlike timers made using timer_create, timerfds don't check whether the process has CAP_WAKE_ALARM before setting alarm-time timers. CAP_WAKE_ALARM is supposed to gate this behavior and so it makes sense that we should deny permission to create such timerfds if the process doesn't have this capability.
--- fs/timerfd.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/timerfd.c +10 -0
@@ -390,6 +390,11 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags) clockid != CLOCK_BOOTTIME_ALARM))return -EINVAL ; +if (!capable (CAP_WAKE_ALARM ) && + (clockid ==CLOCK_REALTIME_ALARM || + clockid ==CLOCK_BOOTTIME_ALARM )) +return -EPERM ; + ctx =kzalloc (sizeof (*ctx),GFP_KERNEL );if (!ctx)return -ENOMEM ;
@@ -433,6 +438,11 @@ static int do_timerfd_settime(int ufd, int flags,return ret; ctx = f.file->private_data; +if (!capable (CAP_WAKE_ALARM ) &&isalarm (ctx)) { +fdput (f); +return -EPERM ; + } +timerfd_setup_cancel (ctx, flags);/*
Signature · 1 line
2.8.0.rc3.226.g39d4020
tip-bot for Eric Caruso
merge bot[tip:timers/core] timerfd: Reject ALARM timerfds without CAP_WAKE_ALARM
timerfd: Reject ALARM timerfds without CAP_WAKE_ALARM
Commit-ID: 2895a5e5b3ae78d9923a91fce405d4a2f32c4309 Gitweb: http://git.kernel.org/tip/2895a5e5b3ae78d9923a91fce405d4a2f32c4309 Author: Eric Caruso <[email protected]> AuthorDate: Wed, 8 Jun 2016 16:08:59 -0700 Committer: Thomas Gleixner <[email protected]> CommitDate: Thu, 9 Jun 2016 23:42:38 +0200
timerfd: Reject ALARM timerfds without CAP_WAKE_ALARM
timerfd gives processes a way to set wake alarms, but unlike timers made using timer_create, timerfds don't check whether the process has CAP_WAKE_ALARM before setting alarm-time timers. CAP_WAKE_ALARM is supposed to gate this behavior and so it makes sense that we should deny permission to create such timerfds if the process doesn't have this capability.
--- fs/timerfd.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/timerfd.c +10 -0
@@ -390,6 +390,11 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags) clockid != CLOCK_BOOTTIME_ALARM))return -EINVAL ; +if (!capable (CAP_WAKE_ALARM ) && + (clockid ==CLOCK_REALTIME_ALARM || + clockid ==CLOCK_BOOTTIME_ALARM )) +return -EPERM ; + ctx =kzalloc (sizeof (*ctx),GFP_KERNEL );if (!ctx)return -ENOMEM ;
@@ -433,6 +438,11 @@ static int do_timerfd_settime(int ufd, int flags,return ret; ctx = f.file->private_data; +if (!capable (CAP_WAKE_ALARM ) &&isalarm (ctx)) { +fdput (f); +return -EPERM ; + } +timerfd_setup_cancel (ctx, flags);/*