[PATCH 2/5] epoll: remember the event if epoll_wait returns -EFAULT

From: Tony Battersby
Date: Mon Mar 02 2009 - 18:10:54 EST


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@xxxxxxxxxxxxxxx>
Acked-by: Davide Libenzi <davidel@xxxxxxxxxxxxxxx>
---
--- a/fs/eventpoll.c 2009-02-23 14:01:41.000000000 -0500
+++ b/fs/eventpoll.c 2009-02-23 14:01:47.000000000 -0500
@@ -1082,8 +1082,10 @@ static int ep_send_events_proc(struct ev
*/
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 linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/