[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <b3f27238de61d1b4f2b7ee31644b65bdca9fdbd0.1266107200.git.matthltc@us.ibm.com>
Date: Sat, 13 Feb 2010 16:27:47 -0800
From: Matt Helsley <matthltc@...ibm.com>
To: linux-kernel@...r.kernel.org
Cc: Matt Helsley <matthltc@...ibm.com>,
Davide Libenzi <davidel@...ilserver.org>
Subject: [RFC][PATCH 4/4] anon_inode fcntl() checks: report failure for fcntl(F_SETFL) on eventfd
Report failure when userspace attempts to set unsupported flags
on eventfd files with fcntl().
Signed-off-by: Matt Helsley <matthltc@...ibm.com>
Cc: Davide Libenzi <davidel@...ilserver.org>
---
fs/eventfd.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/fs/eventfd.c b/fs/eventfd.c
index 7758cc3..8976079 100644
--- a/fs/eventfd.c
+++ b/fs/eventfd.c
@@ -287,7 +287,19 @@ static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t c
return res;
}
+static int eventfd_check_flags(int flags)
+{
+ /* Check the EFD_* constants for consistency. */
+ BUILD_BUG_ON(EFD_CLOEXEC != O_CLOEXEC);
+ BUILD_BUG_ON(EFD_NONBLOCK != O_NONBLOCK);
+
+ if (flags & ~EFD_SHARED_FCNTL_FLAGS)
+ return -EINVAL;
+ return 0;
+}
+
static const struct file_operations eventfd_fops = {
+ .check_flags = eventfd_check_flags,
.release = eventfd_release,
.poll = eventfd_poll,
.read = eventfd_read,
@@ -381,9 +393,6 @@ struct file *eventfd_file_create(unsigned int count, int flags)
struct file *file;
struct eventfd_ctx *ctx;
- /* Check the EFD_* constants for consistency. */
- BUILD_BUG_ON(EFD_CLOEXEC != O_CLOEXEC);
- BUILD_BUG_ON(EFD_NONBLOCK != O_NONBLOCK);
if (flags & ~EFD_FLAGS_SET)
return ERR_PTR(-EINVAL);
--
1.6.3.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists