From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: [PATCH/RFC] user_ns: fix missing limiting of user_ns counts Date: Fri, 28 Dec 2012 18:43:34 +0000 Message-ID: <20121228184334.GZ4939@ZenIV.linux.org.uk> References: <20121228175627.GA7683@cachalot> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20121228175627.GA7683@cachalot> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Vasily Kulikov Cc: kernel-hardening-ZwoEplunGu1jrUoiu81ncdBPR1lH4CV8@public.gmane.org, Containers , "Serge E. Hallyn" , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "Eric W. Biederman" List-Id: containers.vger.kernel.org On Fri, Dec 28, 2012 at 09:56:27PM +0400, Vasily Kulikov wrote: > The included patch is a basic fix for both or them. Both values are > hardcoded here to 100 max depth and 1000 max in total. I'm not sure how > better to make them configurable. Looks like it needs some sysctl value > like kernel.max_user_ns_per_user, but also something more configurable > like new rlimit'ish limit may be created for user_ns needs. E.g. in > case root wants one user to contain hundreds of private containers > (container owner user), but he doesn't want anybody to fill the kernel > with hundreds of containers multiplied by number of system users (equals > to thousands). I'm sorry, but this is not a solution. Kernel is not x86-only; there are architectures with far bigger minimal stack frame size. E.g. on sparc64 every fucking stack frame is at least 176 bytes. So your 100 calls deep call chain will happily overflow the damn stack all by itself - kernel stack on sparc64 is 16Kb total, including struct thread_info living there. From mboxrd@z Thu Jan 1 00:00:00 1970 Reply-To: kernel-hardening@lists.openwall.com Date: Fri, 28 Dec 2012 18:43:34 +0000 From: Al Viro Message-ID: <20121228184334.GZ4939@ZenIV.linux.org.uk> References: <20121228175627.GA7683@cachalot> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121228175627.GA7683@cachalot> Sender: Al Viro Subject: [kernel-hardening] Re: [PATCH/RFC] user_ns: fix missing limiting of user_ns counts To: Vasily Kulikov Cc: Containers , "Eric W. Biederman" , Serge Hallyn , "Serge E. Hallyn" , linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com List-ID: On Fri, Dec 28, 2012 at 09:56:27PM +0400, Vasily Kulikov wrote: > The included patch is a basic fix for both or them. Both values are > hardcoded here to 100 max depth and 1000 max in total. I'm not sure how > better to make them configurable. Looks like it needs some sysctl value > like kernel.max_user_ns_per_user, but also something more configurable > like new rlimit'ish limit may be created for user_ns needs. E.g. in > case root wants one user to contain hundreds of private containers > (container owner user), but he doesn't want anybody to fill the kernel > with hundreds of containers multiplied by number of system users (equals > to thousands). I'm sorry, but this is not a solution. Kernel is not x86-only; there are architectures with far bigger minimal stack frame size. E.g. on sparc64 every fucking stack frame is at least 176 bytes. So your 100 calls deep call chain will happily overflow the damn stack all by itself - kernel stack on sparc64 is 16Kb total, including struct thread_info living there. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754000Ab2L1Snv (ORCPT ); Fri, 28 Dec 2012 13:43:51 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:39708 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753711Ab2L1Snt (ORCPT ); Fri, 28 Dec 2012 13:43:49 -0500 Date: Fri, 28 Dec 2012 18:43:34 +0000 From: Al Viro To: Vasily Kulikov Cc: Containers , "Eric W. Biederman" , Serge Hallyn , "Serge E. Hallyn" , linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: Re: [PATCH/RFC] user_ns: fix missing limiting of user_ns counts Message-ID: <20121228184334.GZ4939@ZenIV.linux.org.uk> References: <20121228175627.GA7683@cachalot> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121228175627.GA7683@cachalot> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 28, 2012 at 09:56:27PM +0400, Vasily Kulikov wrote: > The included patch is a basic fix for both or them. Both values are > hardcoded here to 100 max depth and 1000 max in total. I'm not sure how > better to make them configurable. Looks like it needs some sysctl value > like kernel.max_user_ns_per_user, but also something more configurable > like new rlimit'ish limit may be created for user_ns needs. E.g. in > case root wants one user to contain hundreds of private containers > (container owner user), but he doesn't want anybody to fill the kernel > with hundreds of containers multiplied by number of system users (equals > to thousands). I'm sorry, but this is not a solution. Kernel is not x86-only; there are architectures with far bigger minimal stack frame size. E.g. on sparc64 every fucking stack frame is at least 176 bytes. So your 100 calls deep call chain will happily overflow the damn stack all by itself - kernel stack on sparc64 is 16Kb total, including struct thread_info living there.