freebsd-dev/sys/kern
Konstantin Belousov 56be1b9a7a To limit amount of the kernel memory allocated, and to optimize the
iteration over the fdsets, kern_select() limits the length of the
fdsets copied in by the last valid file descriptor index. If any bit
is set in a mask above the limit, current implementation ignores the
filedescriptor, instead of returning EBADF.

Fix the issue by scanning the tails of fdset before entering the
select loop and returning EBADF if any bit above last valid
filedescriptor index is set. The performance impact of the additional
check is only imposed on the (somewhat) buggy applications that pass
bad file descriptors to select(2) or pselect(2).

PR:	kern/155606, kern/162379
Discussed with:	cognet, glebius
Tested by:	andreast (powerpc, all 64/32bit ABI combinations, big-endian),
       marius (sparc64, big-endian)
MFC after:    2 weeks
2011-11-13 10:28:01 +00:00
..
bus_if.m Add a new bus method, BUS_ADJUST_RESOURCE() that is intended to be a 2011-04-29 21:36:45 +00:00
capabilities.conf Add experimental support for process descriptors 2011-08-18 22:51:30 +00:00
clock_if.m
cpufreq_if.m
device_if.m Update comments for DEVICE_PROBE() to reflect that BUS_PROBE_DEFAULT is 2011-05-24 13:22:40 +00:00
genassym.sh
imgact_aout.c Do not trash the argv[0] pointer for an a.out process on amd64. 2011-06-16 22:00:59 +00:00
imgact_elf32.c
imgact_elf64.c
imgact_elf.c Control the execution permission of the readable segments for 2011-10-15 12:35:18 +00:00
imgact_gzip.c Add accounting for most of the memory-related resources. 2011-04-05 20:23:59 +00:00
imgact_shell.c The execution of the shebang script requires putting interpreter path, 2011-03-06 22:59:30 +00:00
inflate.c
init_main.c Remove the long reprecated ``/stand/sysinstall'' from the init_path. 2011-10-27 10:25:11 +00:00
init_sysent.c Regen. 2011-11-04 04:06:31 +00:00
kern_acct.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
kern_alq.c - Rework the underlying ALQ storage to be a circular buffer, which amongst other 2010-04-26 13:48:22 +00:00
kern_clock.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
kern_clocksource.c Set negative quality to TSC timecounter when C3 state is enabled for Intel 2011-06-22 16:40:45 +00:00
kern_condvar.c
kern_conf.c Style. 2011-11-11 04:13:47 +00:00
kern_cons.c Add descriptions to a handful of sysctl nodes. 2010-08-09 14:48:31 +00:00
kern_context.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
kern_cpu.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
kern_cpuset.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
kern_ctf.c The in-kernel CTF parser caches the result of its first attempt to parse 2011-11-08 15:17:54 +00:00
kern_descrip.c Move the cleanup of f_cdevpriv when the reference count of a devfs 2011-11-04 03:39:31 +00:00
kern_dtrace.c Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs. 2011-11-07 06:44:47 +00:00
kern_environment.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
kern_et.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
kern_event.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
kern_exec.c Do not deliver SIGTRAP on exec as the normal signal, use ptracestop() on 2011-09-27 13:17:02 +00:00
kern_exit.c Fix long-standing thinko regarding maxproc accounting. Basically, 2011-09-17 19:55:32 +00:00
kern_fail.c Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs. 2011-11-07 06:44:47 +00:00
kern_fork.c Move some code inside the racct_proc_fork(); it spares a few lock operations 2011-10-03 17:40:55 +00:00
kern_gzio.c Do not set IO_NODELOCKED while writing to vnodes as our consumers 2010-04-30 03:10:53 +00:00
kern_hhook.c Staticize malloc types. 2011-04-13 11:28:46 +00:00
kern_idle.c On multi-core, multi-threaded PPC systems, it is important that the threads 2011-05-31 15:11:43 +00:00
kern_intr.c - Remove the eintrcnt/eintrnames usage and introduce the concept of 2011-07-18 15:19:40 +00:00
kern_jail.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
kern_khelp.c Use the full and proper company name for Swinburne University of Technology 2011-04-12 08:13:18 +00:00
kern_kthread.c Add experimental support for process descriptors 2011-08-18 22:51:30 +00:00
kern_ktr.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
kern_ktrace.c Revisit the capability failure trace points. The initial implementation 2011-10-18 07:28:58 +00:00
kern_linker.c Add KLD_DEBUG option. 2011-11-06 08:10:41 +00:00
kern_lock.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
kern_lockf.c Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs. 2011-11-07 06:44:47 +00:00
kern_lockstat.c
kern_loginclass.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
kern_malloc.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
kern_mbuf.c Use ISO C99 integer types in sys/kern where possible. 2010-06-21 09:55:56 +00:00
kern_mib.c Define two new sysctl node flags: CTLFLAG_CAPRD and CTLFLAG_CAPRW, which 2011-07-17 23:05:24 +00:00
kern_module.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
kern_mtxpool.c
kern_mutex.c - Remove <machine/mutex.h>. Most of the headers were empty, and the 2010-11-09 20:46:41 +00:00
kern_ntptime.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
kern_osd.c
kern_physio.c Account i/o done on cdevs. 2010-11-25 20:05:11 +00:00
kern_pmc.c Commit the support for removing cpumask_t and replacing it directly with 2011-05-05 14:39:14 +00:00
kern_poll.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
kern_priv.c Add an extra comment to the SDT probes definition. This allows us to get 2010-08-22 11:18:57 +00:00
kern_proc.c Add KVME_FLAG_SUPER and use it in sysctl_kern_proc_vmmap for marking 2011-11-07 21:13:19 +00:00
kern_prot.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
kern_racct.c Actually enforce limit for inheritable resources on fork. 2011-10-04 14:56:33 +00:00
kern_rctl.c Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs. 2011-11-07 06:44:47 +00:00
kern_resource.c In lim_fork() assert that processes locks are held. 2011-11-07 21:09:04 +00:00
kern_rmlock.c Remove pc_cpumask and pc_other_cpus usage from MI code. 2011-06-13 13:28:31 +00:00
kern_rwlock.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
kern_sdt.c Use ISO C99 integer types in sys/kern where possible. 2010-06-21 09:55:56 +00:00
kern_sema.c
kern_shutdown.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
kern_sig.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
kern_switch.c Update several places that iterate over CPUs to use CPU_FOREACH(). 2010-06-11 18:46:34 +00:00
kern_sx.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
kern_synch.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
kern_syscalls.c Call chainevh callback when we are invoked with neither MOD_LOAD nor 2010-10-21 20:31:50 +00:00
kern_sysctl.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
kern_tc.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
kern_thr.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
kern_thread.c Fix some locking nits with the p_state field of struct proc: 2011-03-24 18:40:11 +00:00
kern_time.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
kern_timeout.c Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs. 2011-11-07 06:44:47 +00:00
kern_umtx.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
kern_uuid.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
kern_xxx.c
ksched.c Use p4prio_to_tsprio to calculate TS priority instead of using 2011-06-07 02:50:14 +00:00
link_elf_obj.c Remove malloc(9) return value checks when M_WAITOK is used. 2011-04-16 16:20:51 +00:00
link_elf.c Even if the loaded module has no symbols, we still need to notify 2011-06-16 17:41:21 +00:00
linker_if.m
Make.tags.inc Update tags build script 2011-07-10 00:53:04 +00:00
Makefile Continue to introduce Capsicum Capability Mode support: 2011-03-01 13:28:27 +00:00
makesyscalls.sh Correct the types of the arguments to return probes of the syscall 2011-11-11 03:49:42 +00:00
md4c.c
md5c.c
p1003_1b.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
posix4_mib.c Define two new sysctl node flags: CTLFLAG_CAPRD and CTLFLAG_CAPRW, which 2011-07-17 23:05:24 +00:00
sched_4bsd.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
sched_ule.c - Currently, sched_balance_pair() may cause a CPU to send an IPI_PREEMPT to 2011-10-06 11:48:13 +00:00
serdev_if.m
stack_protector.c
subr_acl_nfs4.c Remove assertion against empty NFSv4 ACLs. An empty ACL is not exactly 2011-10-05 17:29:49 +00:00
subr_acl_posix1e.c execve(2) has a special check for file permissions: a file must have at 2010-08-30 16:30:18 +00:00
subr_autoconf.c Retire PCONFIG and leave the priority of thread0 alone when waiting for 2011-01-06 22:09:37 +00:00
subr_blist.c
subr_bufring.c Switch to our preferred 2-clause BSD license. 2010-05-05 20:39:02 +00:00
subr_bus.c In device_get_children() avoid malloc(0) in order to increase portability 2011-10-09 21:21:37 +00:00
subr_clock.c Improve style and wording of comments and sysctl descriptions [1]. 2011-01-09 14:34:56 +00:00
subr_devstat.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
subr_disk.c Correct bioq_disksort so that bioq_insert_tail() offers barrier semantic. 2010-09-02 19:40:28 +00:00
subr_eventhandler.c Split eventhandler_register() into an internal part and a wrapper function 2010-03-19 19:51:03 +00:00
subr_fattime.c Use ISO C99 integer types in sys/kern where possible. 2010-06-21 09:55:56 +00:00
subr_firmware.c Bump up the firmware_table from 30 to 50. bwn needs more than 30, it 2010-03-07 22:37:35 +00:00
subr_hash.c Decompose the most lousy named file in sys/kern; kern_subr.c. 2010-02-21 19:53:33 +00:00
subr_hints.c
subr_kdb.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
subr_kobj.c Simplify the code emitted by makeobjops.awk slightly. 2011-11-09 11:00:29 +00:00
subr_lock.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
subr_log.c Finish r210923, 210926. Mark some devices as eternal. 2011-01-04 10:59:38 +00:00
subr_mbpool.c
subr_mchain.c Add some FEATURE macros for various features (AUDIT/CAM/IPC/KTR/MAC/NFS/NTP/ 2011-02-25 10:11:01 +00:00
subr_module.c Provide convenience function for obtaining MODINFO_ADDR and MODINFO_SIZE 2011-02-09 19:08:21 +00:00
subr_msgbuf.c Fix a bug introduced in revision 222537. 2011-05-31 22:39:32 +00:00
subr_param.c Modestly increase the maximum allowed size of the kmem map on i386. 2011-03-23 16:38:29 +00:00
subr_pcpu.c Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs. 2011-11-07 06:44:47 +00:00
subr_power.c
subr_prf.c Fix double vision syndrome (read: double output) when in the 2011-10-16 14:16:46 +00:00
subr_prof.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
subr_rman.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
subr_rtc.c Add the half of time-of-day clock resolution when we adjust system time from 2010-08-12 17:17:05 +00:00
subr_sbuf.c r222015 introduced a new assertion that the size of a fixed-length sbuf 2011-08-19 08:29:10 +00:00
subr_scanf.c
subr_sglist.c
subr_sleepqueue.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
subr_smp.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
subr_stack.c Add some FEATURE macros for various features (AUDIT/CAM/IPC/KTR/MAC/NFS/NTP/ 2011-02-25 10:11:01 +00:00
subr_syscall.c Revert rev. 226893: subr_syscall.c is being included from C files and 2011-10-30 02:19:39 +00:00
subr_taskqueue.c Ensure that ta_pending doesn't overflow u_short by capping its value at USHRT_MAX. 2011-09-15 08:42:06 +00:00
subr_trap.c Assert that exiting process does not return to usermode. 2011-10-03 16:58:58 +00:00
subr_turnstile.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
subr_uio.c Add a facility to disable processing page faults. When activated, 2011-07-09 15:21:10 +00:00
subr_unit.c Fix typos - remove duplicate "the". 2011-02-21 09:01:34 +00:00
subr_witness.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
sys_capability.c Revisit the capability failure trace points. The initial implementation 2011-10-18 07:28:58 +00:00
sys_generic.c To limit amount of the kernel memory allocated, and to optimize the 2011-11-13 10:28:01 +00:00
sys_pipe.c Supply unique (st_dev, st_ino) value pair for the fstat(2) done on the pipes. 2011-10-05 16:56:06 +00:00
sys_procdesc.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
sys_process.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
sys_socket.c Add the fo_chown and fo_chmod methods to struct fileops and use them 2011-08-16 20:07:47 +00:00
syscalls.c Regen. 2011-11-04 04:06:31 +00:00
syscalls.master Add the posix_fadvise(2) system call. It is somewhat similar to 2011-11-04 04:02:50 +00:00
systrace_args.c Correct the types of the arguments to return probes of the syscall 2011-11-11 03:49:42 +00:00
sysv_ipc.c Move SysV IPC freebsd32 compat shims helpers from freebsd32_misc.c to 2010-03-19 11:01:51 +00:00
sysv_msg.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
sysv_sem.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
sysv_shm.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
tty_compat.c Make TIOCSTI work again. 2010-01-04 20:59:52 +00:00
tty_info.c
tty_inq.c Fix whitespace inconsistencies in the TTY layer and its drivers owned by me. 2011-06-26 18:26:20 +00:00
tty_outq.c Fix whitespace inconsistencies in the TTY layer and its drivers owned by me. 2011-06-26 18:26:20 +00:00
tty_pts.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
tty_tty.c Finish r210923, 210926. Mark some devices as eternal. 2011-01-04 10:59:38 +00:00
tty_ttydisc.c Fix whitespace inconsistencies in the TTY layer and its drivers owned by me. 2011-06-26 18:26:20 +00:00
tty.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
uipc_accf.c (S)LIST_HEAD_INITIALIZER takes a (S)LIST_HEAD as an argument. 2009-12-28 22:56:30 +00:00
uipc_cow.c Add some FEATURE macros for various features (AUDIT/CAM/IPC/KTR/MAC/NFS/NTP/ 2011-02-25 10:11:01 +00:00
uipc_debug.c
uipc_domain.c
uipc_mbuf2.c Use ISO C99 integer types in sys/kern where possible. 2010-06-21 09:55:56 +00:00
uipc_mbuf.c Fix typos - remove duplicate "the". 2011-02-21 09:01:34 +00:00
uipc_mqueue.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
uipc_sem.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
uipc_shm.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
uipc_sockbuf.c Increase the defaults for the maximum socket buffer limit, 2011-08-25 09:20:13 +00:00
uipc_socket.c Fix a deficiency in the selinfo interface: 2011-08-25 15:51:54 +00:00
uipc_syscalls.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
uipc_usrreq.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
vfs_acl.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
vfs_aio.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
vfs_bio.c Eliminate vestiges of page coloring in VM_ALLOC_NOOBJ calls to 2011-10-27 16:39:17 +00:00
vfs_cache.c Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
vfs_cluster.c The hardware has caught up; improvements are now observed even at 128, 2011-03-16 16:22:59 +00:00
vfs_default.c Add the posix_fadvise(2) system call. It is somewhat similar to 2011-11-04 04:02:50 +00:00
vfs_export.c
vfs_extattr.c In order to maximize the re-usability of kernel code in user space this 2011-09-16 13:58:51 +00:00
vfs_hash.c
vfs_init.c Modify vfs_register() to use a hash calculation 2011-09-13 21:01:26 +00:00
vfs_lookup.c Revisit the capability failure trace points. The initial implementation 2011-10-18 07:28:58 +00:00
vfs_mount.c Introduce the option VFS_ALLOW_NONMPSAFE and turn it on by default on 2011-11-08 10:18:07 +00:00
vfs_mountroot.c Don't terminate the interactive root mount prompt on mount failure. 2011-10-23 20:03:33 +00:00
vfs_subr.c Add the posix_fadvise(2) system call. It is somewhat similar to 2011-11-04 04:02:50 +00:00
vfs_syscalls.c Add the posix_fadvise(2) system call. It is somewhat similar to 2011-11-04 04:02:50 +00:00
vfs_vnops.c Add the posix_fadvise(2) system call. It is somewhat similar to 2011-11-04 04:02:50 +00:00
vnode_if.src Add the posix_fadvise(2) system call. It is somewhat similar to 2011-11-04 04:02:50 +00:00