Module Name:    src
Committed By:   christos
Date:           Sat May  4 15:46:58 UTC 2019

Modified Files:
        src/sys/kern: sys_select.c

Log Message:
PR/54158: Anthony Mallet: poll(2) does not allow polling all possible fds
(hardcoded limit to 1000 + #<open-fds>). Changed to limit by the max of
the resource limit of open descriptors and the above.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/kern/sys_select.c

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

Modified files:

Index: src/sys/kern/sys_select.c
diff -u src/sys/kern/sys_select.c:1.41 src/sys/kern/sys_select.c:1.42
--- src/sys/kern/sys_select.c:1.41	Tue Jan 30 02:52:23 2018
+++ src/sys/kern/sys_select.c	Sat May  4 11:46:58 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_select.c,v 1.41 2018/01/30 07:52:23 ozaki-r Exp $	*/
+/*	$NetBSD: sys_select.c,v 1.42 2019/05/04 15:46:58 christos Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
@@ -84,7 +84,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.41 2018/01/30 07:52:23 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.42 2019/05/04 15:46:58 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -488,7 +488,8 @@ pollcommon(register_t *retval, struct po
 	int		error;
 	size_t		ni;
 
-	if (nfds > 1000 + curlwp->l_fd->fd_dt->dt_nfiles) {
+	if (nfds > MAX(1000 + curlwp->l_fd->fd_dt->dt_nfiles,
+	    curlwp->l_proc->p_rlimit[RLIMIT_NOFILE].rlim_cur)) {
 		/*
 		 * Either the user passed in a very sparse 'fds' or junk!
 		 * The kmem_alloc() call below would be bad news.

Reply via email to