Messages in this thread Patch in this message | | | From | Matt Helsley <> | Subject | [RFC][PATCH 3/4] anon_inode fcntl() checks: report failure for fcntl(F_SETFL) on epoll | Date | Sat, 13 Feb 2010 16:27:46 -0800 |
| |
Report failure when userspace attempts to set unsupported flags on epoll files with fcntl().
Signed-off-by: Matt Helsley <matthltc@us.ibm.com> Cc: Davide Libenzi <davidel@xmailserver.org> --- fs/eventpoll.c | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/fs/eventpoll.c b/fs/eventpoll.c index bd056a5..ea46b92 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -671,8 +671,19 @@ static unsigned int ep_eventpoll_poll(struct file *file, poll_table *wait) return pollflags != -1 ? pollflags : 0; } +static int ep_eventpoll_check_flags(int flags) +{ + /* Check the EPOLL_* constant for consistency. */ + BUILD_BUG_ON(EPOLL_CLOEXEC != O_CLOEXEC); + + if (flags & ~EPOLL_CLOEXEC) + return -EINVAL; + return 0; +} + /* File callbacks that implement the eventpoll file behaviour */ static const struct file_operations eventpoll_fops = { + .check_flags = ep_eventpoll_check_flags, .release = ep_eventpoll_release, .poll = ep_eventpoll_poll }; @@ -1190,11 +1201,9 @@ SYSCALL_DEFINE1(epoll_create1, int, flags) int error; struct eventpoll *ep = NULL; - /* Check the EPOLL_* constant for consistency. */ - BUILD_BUG_ON(EPOLL_CLOEXEC != O_CLOEXEC); - - if (flags & ~EPOLL_CLOEXEC) + if (ep_eventpoll_check_flags(flags)) return -EINVAL; + /* * Create the internal data structure ("struct eventpoll"). */ -- 1.6.3.3
| |