On Dec 14, 2009, at 2:12 PM, Mindaugas Rasiukevicius wrote: > Hello, > >> Module Name: src >> Committed By: dsl >> Date: Sat Dec 12 17:47:05 UTC 2009 >> >> Modified Files: >> src/sys/kern: sys_select.c >> >> Log Message: >> Bounding the 'nfds' arg to poll() at the current process limit for actual >> open files is rather gross - the poll map isn't required to be dense. >> Instead limit to a much larger value (1000 + dt_nfiles) so that user >> programs cannot allocate indefinite sized blocks of kvm. > > This does not look right to me. > > - Where does the random value 1000 come from? If you need a limit, POSIX > allows to limit up to OPEN_MAX (thus did SVR4?). > > - How about truncating to fd_lastfile (plus one), instead of dt_nfiles?
you could has one each pollfd for IN, OUT, HUP so that's 3 times nfiles.