lkml.org 
[lkml]   [2010]   [Feb]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC][PATCH 2/4] anon_inode fcntl() checks: report failure for fcntl(F_SETFL) on timerfd
Date
Report failure when userspace attempts to set unsupported flags
on timerfd files with fcntl().

Signed-off-by: Matt Helsley <matthltc@us.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Davide Libenzi <davidel@xmailserver.org>
---
fs/timerfd.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/fs/timerfd.c b/fs/timerfd.c
index 1bfc95a..198a564 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -156,7 +156,19 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count,
return res;
}

+static int timerfd_check_flags(int flags)
+{
+ /* Check the TFD_* constants for consistency. */
+ BUILD_BUG_ON(TFD_CLOEXEC != O_CLOEXEC);
+ BUILD_BUG_ON(TFD_NONBLOCK != O_NONBLOCK);
+
+ if (flags & ~(TFD_CLOEXEC | TFD_NONBLOCK))
+ return -EINVAL;
+ return 0;
+}
+
static const struct file_operations timerfd_fops = {
+ .check_flags = timerfd_check_flags,
.release = timerfd_release,
.poll = timerfd_poll,
.read = timerfd_read,
@@ -182,10 +194,6 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
int ufd;
struct timerfd_ctx *ctx;

- /* Check the TFD_* constants for consistency. */
- BUILD_BUG_ON(TFD_CLOEXEC != O_CLOEXEC);
- BUILD_BUG_ON(TFD_NONBLOCK != O_NONBLOCK);
-
if ((flags & ~TFD_CREATE_FLAGS) ||
(clockid != CLOCK_MONOTONIC &&
clockid != CLOCK_REALTIME))
--
1.6.3.3


\
 
 \ /
  Last update: 2010-02-14 01:31    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site