From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751762Ab1GONEa (ORCPT ); Fri, 15 Jul 2011 09:04:30 -0400 Received: from mother.openwall.net ([195.42.179.200]:57506 "HELO mother.openwall.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751617Ab1GONE2 (ORCPT ); Fri, 15 Jul 2011 09:04:28 -0400 Date: Fri, 15 Jul 2011 17:04:09 +0400 From: Solar Designer To: Vasiliy Kulikov Cc: NeilBrown , kernel-hardening@lists.openwall.com, James Morris , Linus Torvalds , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Andrew Morton , "David S. Miller" , Jiri Slaby , Alexander Viro , linux-fsdevel@vger.kernel.org, KOSAKI Motohiro , Eric Paris , Stephen Smalley , Willy Tarreau , Sebastian Krahmer Subject: Re: [PATCH] move RLIMIT_NPROC check from set_user() to do_execve_common() Message-ID: <20110715130409.GA2700@openwall.com> References: <20110713063142.GA19976@openwall.com> <20110713170657.59dae548@notabene.brown> <20110714112751.1bfd998f@notabene.brown> <20110714150602.GA30019@openwall.com> <20110715133013.4fa38d19@notabene.brown> <20110715063113.GA3166@albatros> <20110715170650.585f1dad@notabene.brown> <20110715073823.GA3821@albatros> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110715073823.GA3821@albatros> User-Agent: Mutt/1.4.2.3i Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Neil, Vasiliy - On Fri, Jul 15, 2011 at 11:38:23AM +0400, Vasiliy Kulikov wrote: > On Fri, Jul 15, 2011 at 17:06 +1000, NeilBrown wrote: > > How about this then? > > AFAIU, with this patch: > > 1) setuid() doesn't fail in NPROC exceed case. > 2) NPROC is forced on execve() after setuid(). > 3) execve() fails only if NPROC was exceeded during setuid() execution. > 4) Other processes of the same user doesn't suffer from "occasional" > execve() failures. > > If it is correct, then I like the patch :) I'm not convinced this has any advantages over the patch Vasiliy had posted (which simply moved the RLIMIT_NPROC check), but I don't mind, with one important correction: Although in the primary use cases we're considering, setuid() is very soon followed by execve(), this doesn't always have to be the case. There may be cases where the process would sleep between these two calls (for a variety of reasons). It would be surprising to see a process fail on execve() because of RLIMIT_NPROC when that limit had been reached, say, days ago and is no longer reached at the time of execve(). Thus, if we go with Neil's proposal (adding/checking an extra flag), we should also re-check the process count against RLIMIT_NPROC on execve(), and fail the exec only when both the flag is set and the current process count is excessive (still or again). Also, if we go with a patch like this, it brings up the question of whether the flag should be preserved or reset on fork(). I think it should be preserved. > It does RLIMIT_NPROC > enforcement without mixing other execve() calls like -ow patch did. "Mixing other execve() calls" (4 on the list above) is not obviously undesirable. Thus, either Vasiliy's original patch or Neil's patch with the addition mentioned above would be fine by me. Thanks, Alexander