mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matt Helsley <matthltc@us.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: Matt Helsley <matthltc@us.ibm.com>,
	Davide Libenzi <davidel@xmailserver.org>
Subject: [RFC][PATCH 4/4] anon_inode fcntl() checks: report failure for fcntl(F_SETFL) on eventfd
Date: Sat, 13 Feb 2010 16:27:47 -0800	[thread overview]
Message-ID: <b3f27238de61d1b4f2b7ee31644b65bdca9fdbd0.1266107200.git.matthltc@us.ibm.com> (raw)
In-Reply-To: <1518b6425f7dbee3a666d45cb3be0e3d2487fbec.1266107200.git.matthltc@us.ibm.com>
In-Reply-To: <69d9c93fe958497f69102bea7c32cd048160b978.1266107200.git.matthltc@us.ibm.com>

Report failure when userspace attempts to set unsupported flags
on eventfd files with fcntl().

Signed-off-by: Matt Helsley <matthltc@us.ibm.com>
Cc: Davide Libenzi <davidel@xmailserver.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


  reply	other threads:[~2010-02-14  0:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-14  0:27 [RFC][PATCH 0/4] Check O_* flags set with fcntl() on anon_inode files Matt Helsley
2010-02-14  0:27 ` [RFC][PATCH 1/4] anon_inode fcntl() checks: report failure for fcntl(F_SETFL) on signalfd Matt Helsley
2010-02-14  0:27   ` [RFC][PATCH 2/4] anon_inode fcntl() checks: report failure for fcntl(F_SETFL) on timerfd Matt Helsley
2010-02-14  0:27     ` [RFC][PATCH 3/4] anon_inode fcntl() checks: report failure for fcntl(F_SETFL) on epoll Matt Helsley
2010-02-14  0:27       ` Matt Helsley [this message]
2010-02-14  0:40 ` [RFC][PATCH 0/4] Check O_* flags set with fcntl() on anon_inode files Davide Libenzi
2010-02-14  3:52 ` Al Viro
2010-02-15 17:26   ` Matt Helsley
2010-02-15 19:57     ` Al Viro
2010-02-16 11:37       ` Matt Helsley

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=b3f27238de61d1b4f2b7ee31644b65bdca9fdbd0.1266107200.git.matthltc@us.ibm.com \
    --to=matthltc@us.ibm.com \
    --cc=davidel@xmailserver.org \
    --cc=linux-kernel@vger.kernel.org \
    /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®