Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: [netbsd-10] src



Module Name:    src
Committed By:   martin
Date:           Mon Nov 18 18:16:52 UTC 2024

Modified Files:
        src/sys/kern [netbsd-10]: sys_select.c
        src/tests/lib/libc/sys [netbsd-10]: t_select.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1011):

        sys/kern/sys_select.c: revision 1.67
        tests/lib/libc/sys/t_select.c: revision 1.5

PR kern/57504 : Check all fds passed in to select

If an application passes in a huge fd_set (select(BIG, ...))
then check every bit in the fd_sets provided, to make sure
they are valid.

If BIG is too big (cannot possibly represent an open fd for
this process, under any circumstances: ie: not just because
that many are not currently open) return EINVAL.
Otherwise, check every set bit to make sure it is valid.  Any
fd bits set above the applications current highest open fd
automatically generate EBADF and quick(ish) exit.
fd's that are within the plausible range are then checked as
they always were (it is possible for there to be a few there
above the max open fd - as everything in select is done in
multiples of __FDBITS (fd_mask) but the max open fd is not so
constrained.  Those always were checked, continue using the
same mechanism.

This should have zero impact on any sane application which
uses the highest fd for which it set a bit, +1, as the first
arg to select.   However, if there are any broken applications
that were relying upon the previous behaviour of simply ignoring
any fd_masks that started beyond the max number of open files,
then they might (if they happen to have any bits set) now fail.

tests/lib/libc/sys/t_select: Test select on bad file descriptors.
This should immediately fail, not hang, even if the bad fd is
high-numbered.

PR kern/57504: select with large enough bogus fd number set hangs
instead of failing with EBADF


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.60.4.1 src/sys/kern/sys_select.c
cvs rdiff -u -r1.4 -r1.4.28.1 src/tests/lib/libc/sys/t_select.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index