From: tip-bot for Eric Caruso <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: tglx@linutronix.de, toddpoynor@google.com, ejcaruso@google.com,
mingo@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org
Subject: [tip:timers/core] timerfd: Reject ALARM timerfds without CAP_WAKE_ALARM
Date: Thu, 9 Jun 2016 14:48:54 -0700 [thread overview]
Message-ID: <tip-2895a5e5b3ae78d9923a91fce405d4a2f32c4309@git.kernel.org> (raw)
In-Reply-To: <1465427339-96209-1-git-send-email-ejcaruso@chromium.org>
Commit-ID: 2895a5e5b3ae78d9923a91fce405d4a2f32c4309
Gitweb: http://git.kernel.org/tip/2895a5e5b3ae78d9923a91fce405d4a2f32c4309
Author: Eric Caruso <ejcaruso@google.com>
AuthorDate: Wed, 8 Jun 2016 16:08:59 -0700
Committer: Thomas Gleixner <tglx@linutronix.de>
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.
Signed-off-by: Eric Caruso <ejcaruso@google.com>
Cc: Todd Poynor <toddpoynor@google.com>
Link: http://lkml.kernel.org/r/1465427339-96209-1-git-send-email-ejcaruso@chromium.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
fs/timerfd.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/fs/timerfd.c b/fs/timerfd.c
index 053818d..9ae4abb 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -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);
/*
prev parent reply other threads:[~2016-06-09 21:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-08 23:08 [PATCH] fs/timerfd: reject " Eric Caruso
2016-06-09 21:48 ` tip-bot for Eric Caruso [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-2895a5e5b3ae78d9923a91fce405d4a2f32c4309@git.kernel.org \
--to=tipbot@zytor.com \
--cc=ejcaruso@google.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=toddpoynor@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®