From owner-svn-src-head@freebsd.org Fri Nov 2 00:46:11 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2B2D210DEF19; Fri, 2 Nov 2018 00:46:11 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 95C816E9B8; Fri, 2 Nov 2018 00:46:10 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id wA20jtip007261 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 2 Nov 2018 02:45:58 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua wA20jtip007261 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id wA20jtMv007260; Fri, 2 Nov 2018 02:45:55 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 2 Nov 2018 02:45:55 +0200 From: Konstantin Belousov To: Conrad Meyer Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r340038 - in head: lib/libc/sys sys/kern Message-ID: <20181102004555.GJ5335@kib.kiev.ua> References: <201811012346.wA1NkNS5079845@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201811012346.wA1NkNS5079845@repo.freebsd.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Nov 2018 00:46:11 -0000 On Thu, Nov 01, 2018 at 11:46:23PM +0000, Conrad Meyer wrote: > Author: cem > Date: Thu Nov 1 23:46:23 2018 > New Revision: 340038 > URL: https://svnweb.freebsd.org/changeset/base/340038 > > Log: > kern_poll: Restore explanatory comment removed in r177374 > > The comment isn't stale. The check is bogus in the sense that poll(2) > does not require pollfd entries to be unique in fd space, so there is no > reason there cannot be more pollfd entries than open or even allowed > fds. The check is mostly a seatbelt against accidental misuse or > abuse. FD_SETSIZE, while usually unrelated to poll, is used as an > arbitrary floor for systems with very low kern.maxfilesperproc. > > Additionally, document this possible EINVAL condition in the poll.2 > manual. > > No functional change. > > Reviewed by: markj > Sponsored by: Dell EMC Isilon > Differential Revision: https://reviews.freebsd.org/D17671 > > Modified: > head/lib/libc/sys/poll.2 > head/sys/kern/sys_generic.c > > Modified: head/lib/libc/sys/poll.2 > ============================================================================== > --- head/lib/libc/sys/poll.2 Thu Nov 1 23:42:35 2018 (r340037) > +++ head/lib/libc/sys/poll.2 Thu Nov 1 23:46:23 2018 (r340038) > @@ -28,7 +28,7 @@ > .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > .\" > -.Dd November 13, 2014 > +.Dd November 1, 2018 > .Dt POLL 2 > .Os > .Sh NAME > @@ -232,7 +232,15 @@ points outside the process's allocated address space. > A signal was delivered before the time limit expired and > before any of the selected events occurred. > .It Bq Er EINVAL > -The specified time limit is invalid. One of its components is negative or too large. > +The specified time limit is invalid. > +One of its components is negative or too large. > +.It Bq Er EINVAL > +The number of pollfd structures specified by > +.Fa nfds > +exceeds the system tunable > +.Va kern.maxfilesperproc > +and > +.Dv FD_SETSIZE . This is somewhat confusing. Looking only at the man page text, most straight reading of it is that nfds cannot exceed min(maxfilesperproc, FD_SETSIZE). But in fact nfds cannot exceed max of it, which is significantly different, i.e. poll(2) does not suffer from the (userspace) FD_SETSIZE limitation of select(2). > .El > .Sh SEE ALSO > .Xr accept 2 , > > Modified: head/sys/kern/sys_generic.c > ============================================================================== > --- head/sys/kern/sys_generic.c Thu Nov 1 23:42:35 2018 (r340037) > +++ head/sys/kern/sys_generic.c Thu Nov 1 23:46:23 2018 (r340038) > @@ -1339,6 +1339,13 @@ kern_poll(struct thread *td, struct pollfd *ufds, u_in > } else > sbt = -1; > > + /* > + * This is kinda bogus. We have fd limits, but that is not > + * really related to the size of the pollfd array. Make sure > + * we let the process use at least FD_SETSIZE entries and at > + * least enough for the system-wide limits. We want to be reasonably > + * safe, but not overly restrictive. > + */ > if (nfds > maxfilesperproc && nfds > FD_SETSIZE) > return (EINVAL); > if (nfds > nitems(stackfds))