epoll: remember the event if epoll_wait returns -EFAULT

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Wednesday, April 1, 2009 - 11:01 am

Gitweb:     http://git.kernel.org/linus/d0305882825784e74f68a56eee6c3a812a99f235
Commit:     d0305882825784e74f68a56eee6c3a812a99f235
Parent:     abff55cee1039b5a3b96f7a5eb6e65b9f247a274
Author:     Tony Battersby <tonyb@cybernetics.com>
AuthorDate: Tue Mar 31 15:24:14 2009 -0700
Committer:  Linus Torvalds <torvalds@linux-foundation.org>
CommitDate: Wed Apr 1 08:59:19 2009 -0700

    epoll: remember the event if epoll_wait returns -EFAULT
    
    If epoll_wait returns -EFAULT, the event that was being returned when the
    fault was encountered will be forgotten.  This is not a big deal since
    EFAULT will happen only if a buggy userspace program passes in a bad
    address, in which case what happens later usually doesn't matter.
    However, it is easy to remember the event for later, and this patch makes
    a simple change to do that.
    
    Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
    Acked-by: Davide Libenzi <davidel@xmailserver.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
 fs/eventpoll.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index db4365f..c806a0c 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1054,8 +1054,10 @@ static int ep_send_events_proc(struct eventpoll *ep, struct list_head *head,
 		 */
 		if (revents) {
 			if (__put_user(revents, &uevent->events) ||
-			    __put_user(epi->event.data, &uevent->data))
+			    __put_user(epi->event.data, &uevent->data)) {
+				list_add(&epi->rdllink, head);
 				return eventcnt ? eventcnt : -EFAULT;
+			}
 			eventcnt++;
 			uevent++;
 			if (epi->event.events & EPOLLONESHOT)
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
epoll: remember the event if epoll_wait returns -EFAULT, Linux Kernel Mailing ..., (Wed Apr 1, 11:01 am)