From owner-svn-src-head@FreeBSD.ORG Sat Nov 2 21:17:31 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 06766AEA; Sat, 2 Nov 2013 21:17:31 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id B695F2929; Sat, 2 Nov 2013 21:17:30 +0000 (UTC) Received: from turtle.stack.nl (turtle.stack.nl [IPv6:2001:610:1108:5010::132]) by mx1.stack.nl (Postfix) with ESMTP id 0AE0B359314; Sat, 2 Nov 2013 22:17:28 +0100 (CET) Received: by turtle.stack.nl (Postfix, from userid 1677) id D4EDFCB4E; Sat, 2 Nov 2013 22:17:27 +0100 (CET) Date: Sat, 2 Nov 2013 22:17:27 +0100 From: Jilles Tjoelker To: Konstantin Belousov Subject: Re: svn commit: r256849 - in head/sys: kern sys Message-ID: <20131102211727.GA160@stack.nl> References: <201310211644.r9LGirtR012470@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201310211644.r9LGirtR012470@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 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: Sat, 02 Nov 2013 21:17:31 -0000 On Mon, Oct 21, 2013 at 04:44:53PM +0000, Konstantin Belousov wrote: > Author: kib > Date: Mon Oct 21 16:44:53 2013 > New Revision: 256849 > URL: http://svnweb.freebsd.org/changeset/base/256849 > Log: > Add a resource limit for the total number of kqueues available to the > user. Kqueue now saves the ucred of the allocating thread, to > correctly decrement the counter on close. > Under some specific and not real-world use scenario for kqueue, it is > possible for the kqueues to consume memory proportional to the square > of the number of the filedescriptors available to the process. Limit > allows administrator to prevent the abuse. > This is kernel-mode side of the change, with the user-mode enabling > commit following. > Reported and tested by: pho > Discussed with: jmg > Sponsored by: The FreeBSD Foundation > MFC after: 2 weeks > [snip] > + if (!chgkqcnt(cred->cr_ruidinfo, 1, lim_cur(td->td_proc, > + RLIMIT_KQUEUES))) { > + PROC_UNLOCK(p); > + crfree(cred); > + return (EMFILE); > + } Perhaps this error should be [ENOMEM] instead of [EMFILE] as it is unrelated to the number of file descriptors in the process. This error is already listed in the kqueue(2) man page but appears to be not generated. The rlimit can then be mentioned in the man page. -- Jilles Tjoelker