Source-Changes-HG archive

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

[src/trunk]: src/sys/kern PR/54158: Anthony Mallet: poll(2) does not allow po...



details:   https://anonhg.NetBSD.org/src/rev/40b6d04c5525
branches:  trunk
changeset: 451043:40b6d04c5525
user:      christos <christos%NetBSD.org@localhost>
date:      Sat May 04 15:46:58 2019 +0000

description:
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.

diffstat:

 sys/kern/sys_select.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r 6314af729707 -r 40b6d04c5525 sys/kern/sys_select.c
--- a/sys/kern/sys_select.c     Sat May 04 13:14:18 2019 +0000
+++ b/sys/kern/sys_select.c     Sat May 04 15:46:58 2019 +0000
@@ -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 @@
        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.



Home | Main Index | Thread Index | Old Index