All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix poll() nfds check.
@ 2006-07-06  3:00 Vadim Lobanov
  2006-07-06  3:39 ` Andrew Morton
  2006-07-07  3:00 ` H. Peter Anvin
  0 siblings, 2 replies; 6+ messages in thread
From: Vadim Lobanov @ 2006-07-06  3:00 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

Hi,

This is a trivial patch to fix the nfds check in the poll system call
implementation. Namely, OPEN_MAX no longer does anything important in
the kernel, and checking that nfds is greater than max_fdset AND greater
than OPEN_MAX therefore just seems wrong.

This brings up a slightly-tangential question: Why do the nfds checks
exist in select()/poll()? They're not strictly necessary, since bad
input will be caught later when we validate all the fds, one by one.
Furthermore, these checks optimize the handling of error cases (which
should be uncommon) while pessimizing correct usage of the syscalls
(which should be more common).

Signed-off-by: Vadim Lobanov <vlobanov@speakeasy.net>

diff -Npru linux-2.6.17-git25/fs/select.c linux-new/fs/select.c
--- linux-2.6.17-git25/fs/select.c	2006-07-05 19:06:56.000000000 -0700
+++ linux-new/fs/select.c	2006-07-05 19:10:51.000000000 -0700
@@ -671,7 +671,7 @@ int do_sys_poll(struct pollfd __user *uf
 	fdt = files_fdtable(current->files);
 	max_fdset = fdt->max_fdset;
 	rcu_read_unlock();
-	if (nfds > max_fdset && nfds > OPEN_MAX)
+	if (nfds > max_fdset)
 		return -EINVAL;

 	poll_initwait(&table);

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-07-07  3:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-06  3:00 [PATCH] Fix poll() nfds check Vadim Lobanov
2006-07-06  3:39 ` Andrew Morton
2006-07-06  4:02   ` Vadim Lobanov
2006-07-06 15:44   ` Ulrich Drepper
2006-07-06 16:28     ` Vadim Lobanov
2006-07-07  3:00 ` H. Peter Anvin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.