[PATCH] Avoid unnecessary copy for EPOLL_CTL_DEL

From: Ulrich Drepper
Date: Sun Oct 03 2004 - 02:10:03 EST


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

When epoll_ctl() is used with the EPOLL_CTL_DEL operation the event
structure pointed to by the fourth parameter is unnecessarily copied.
It is not used and userlevel would have to initialize some memory to
avoid passing down a pointer to some uninitialized memory. The attached
patch should work just fine.

Signed-off-by: Ulrich Drepper <drepper@xxxxxxxxxx>

- --
â Ulrich Drepper â Red Hat, Inc. â 444 Castro St â Mountain View, CA â
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFBX6Vh2ijCOnn/RHQRAo0HAJ0UyKipkrlhK6xiNgeoOBsoK7bxEgCgqCMK
xI430mMmGxi9Ce1jBTZFYK4=
=Gq3D
-----END PGP SIGNATURE-----
--- fs/eventpoll.c 2004-08-26 19:14:51.000000000 -0700
+++ fs/eventpoll.c.new 2004-10-03 00:04:33.000000000 -0700
@@ -531,7 +531,8 @@ sys_epoll_ctl(int epfd, int op, int fd,
current, epfd, op, fd, event));

error = -EFAULT;
- if (copy_from_user(&epds, event, sizeof(struct epoll_event)))
+ if (op != EPOLL_CTL_DEL &&
+ copy_from_user(&epds, event, sizeof(struct epoll_event)))
goto eexit_1;

/* Get the "struct file *" for the eventpoll file */