Received: by 10.223.164.202 with SMTP id h10csp5909wrb; Wed, 8 Nov 2017 11:03:25 -0800 (PST) X-Google-Smtp-Source: ABhQp+RYADspCooycswVvo7lkZwnqYzQq0LmXyCT277+jAZntismomRV5QUX5XxmPnOdENNL1RvH X-Received: by 10.99.66.130 with SMTP id p124mr1413825pga.0.1510167805723; Wed, 08 Nov 2017 11:03:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510167805; cv=none; d=google.com; s=arc-20160816; b=yI1wp0N7wxk4tOgOxnCSjj64CVDNFe3XcX7HNblDbpYGLh4uD2UWIMO1CSU1gueB78 mi5DWiU5N03DF5miHzrIHfCd2Es7okAKv1KbNequg5TGTb2vjxO+jcdanrUOzYf6mO2u lv5aJSr1Kr30xbwJVF3BLtwSyowXolJ+ARLzBKiXYG9TCJIMF7WLDx0jVbk/QnzpKWfN XHcExepBgHaKM2vk1/AgQOnYHFIj21i/PZeVuue6tHpvxUIcm14Hu1RY3LANamhMrbFb 9h0dJsfkGHJvXmTqX8nj1nfOgz00THQhr2UFBrB6G2NqL1vagCOzolWYloSR9CBIQt9s GkHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=o8G1Otgo86IDEx7g0iE6mSkup5aqzZnZBbSifdVZMt0=; b=wOVcxCmGcNVfHTDaHRWjWjN6a5YZN2M6vjogFDbnuObVLsWk26jlp627VUP31NPmck R28u6eBPS12N47z3yTiiIkEGqgB/DdsVIEiTOevsteY3DeiCkMR12PMGfk1OJ9/AZ68k fMfEV7/IabDqrZ3yYyg3AJB56Ua9dTOmahoF/Khkjh39U7+mYEtPVg9eLWhrnqTohBLV vvgFAMEg/X3j1Yp7+Ro74WIg1s8L0jNDQIleONOFX6YmcIZNDj3VbCxQAuE/70RlJMdg lBeiCjk4slIoQPxG4q7VXv9WirqQOzyylrj6BVx+pG97AFQUfr0QZblGxefH/+DO20rI UnoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r29si2540996pfb.252.2017.11.08.11.03.13; Wed, 08 Nov 2017 11:03:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752419AbdKHTCf (ORCPT + 84 others); Wed, 8 Nov 2017 14:02:35 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:38761 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751716AbdKHTC3 (ORCPT ); Wed, 8 Nov 2017 14:02:29 -0500 Received: from mail-wm0-f70.google.com ([74.125.82.70]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1eCVcK-00024Q-DX for linux-kernel@vger.kernel.org; Wed, 08 Nov 2017 19:02:28 +0000 Received: by mail-wm0-f70.google.com with SMTP id b189so2855214wmd.9 for ; Wed, 08 Nov 2017 11:02:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=o8G1Otgo86IDEx7g0iE6mSkup5aqzZnZBbSifdVZMt0=; b=es3/LFwlLOxqPOIT9EMCkDLeMcMhZMVs4hSI9e//aSMUsTW4DVvI5KMBaGxzlE2ALi TyjwB01I836ydY97A4HAQVC0cr0hMQkkOJG2jbQdsG0yJg8oLD0I7uLkH3lVnnc1SA6E 588/IAGuLZS6XxAyalcGRmZ00XJQM54gAxIpjkyx3w7oerw2hBizHhAc8AjZyP9st4TK MdgRwpvoYZdOyexGDLTonmNWVTdrdANruVJtXGv58vNXv07uJ6lMYiqRb/KqSLkQSFkA t+NnhHYWMW2Qmxvssx42EiJWd/oPzFcn5lbtJljtiPgWH1pFqqI2d1OFNx+Fgs7aupTe siCA== X-Gm-Message-State: AJaThX4Je9lGSH0LSG1TGGkYfkrNaODQMe/ZKXzFTu5Hgod7ZpJX3KOs XCI123LZhnnWk0zQ7lQCIokG+1g79RUaX9l4TgPuvD1wkn82Z/c34Ost5DA/lJ0dZKav+oP9YZD EaaUj0HslQRrbI6tPPLWAmNDiIl2GXXmZWgcFchqofg== X-Received: by 10.80.169.193 with SMTP id n59mr1945961edc.282.1510167747875; Wed, 08 Nov 2017 11:02:27 -0800 (PST) X-Received: by 10.80.169.193 with SMTP id n59mr1945936edc.282.1510167747581; Wed, 08 Nov 2017 11:02:27 -0800 (PST) Received: from gmail.com (p5B2A6E0E.dip0.t-ipconnect.de. [91.42.110.14]) by smtp.gmail.com with ESMTPSA id h2sm4270803edf.39.2017.11.08.11.02.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Nov 2017 11:02:26 -0800 (PST) Date: Wed, 8 Nov 2017 20:02:25 +0100 From: Christian Brauner To: Mahesh Bandewar =?utf-8?B?KOCkruCkueClh+CktiDgpKzgpILgpKHgpYfgpLXgpL4=?= =?utf-8?B?4KSwKQ==?= Cc: "Serge E. Hallyn" , Boris Lukashev , Daniel Micay , Mahesh Bandewar , LKML , Netdev , Kernel-hardening , Linux API , Kees Cook , "Eric W . Biederman" , Eric Dumazet , David Miller Subject: Re: [kernel-hardening] Re: [PATCH resend 2/2] userns: control capabilities of some user namespaces Message-ID: <20171108190223.vdkyepcaegmub6le@gmail.com> References: <20171104235346.GA17170@mail.hallyn.com> <20171106150302.GA26634@mail.hallyn.com> <1510003994.736.0.camel@gmail.com> <20171106221418.GA32543@mail.hallyn.com> <20171106233913.GA1518@mail.hallyn.com> <20171107032802.GA6669@mail.hallyn.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 08, 2017 at 03:09:59AM -0800, Mahesh Bandewar (महेश बंडेवार) wrote: > Sorry folks I was traveling and seems like lot happened on this thread. :p > > I will try to response few of these comments selectively - > > > The thing that makes me hesitate with this set is that it is a > > permanent new feature to address what (I hope) is a temporary > > problem. > I agree this is permanent new feature but it's not solving a temporary > problem. It's impossible to assess what and when new vulnerability > that could show up. I think Daniel summed it up appropriately in his > response > > > Seems like there are two naive ways to do it, the first being to just > > look at all code under ns_capable() plus code called from there. It > > seems like looking at the result of that could be fruitful. > This is really hard. The main issue that there were features designed > and developed before user-ns days with an assumption that unprivileged > users will never get certain capabilities which only root user gets. > Now that is not true anymore with user-ns creation with mapping root > for any process. Also at the same time blocking user-ns creation for > eveyone is a big-hammer which is not needed too. So it's not that easy > to just perform a code-walk-though and correct those decisions now. > > > It seems to me that the existing control in > > /proc/sys/kernel/unprivileged_userns_clone might be the better duct tape > > in that case. > This solution is essentially blocking unprivileged users from using > the user-namespaces entirely. This is not really a solution that can > work. The solution that this patch-set adds allows unprivileged users > to create user-namespaces. Actually the proposed solution is more > fine-grained approach than the unprivileged_userns_clone solution > since you can selectively block capabilities rather than completely > blocking the functionality. I've been talking to Stéphane today about this and we should also keep in mind that we have: chb@conventiont|~ > ls -al /proc/sys/user/ total 0 dr-xr-xr-x 1 root root 0 Nov 6 23:32 . dr-xr-xr-x 1 root root 0 Nov 2 22:13 .. -rw-r--r-- 1 root root 0 Nov 8 19:48 max_cgroup_namespaces -rw-r--r-- 1 root root 0 Nov 8 19:48 max_inotify_instances -rw-r--r-- 1 root root 0 Nov 8 19:48 max_inotify_watches -rw-r--r-- 1 root root 0 Nov 8 19:48 max_ipc_namespaces -rw-r--r-- 1 root root 0 Nov 8 19:48 max_mnt_namespaces -rw-r--r-- 1 root root 0 Nov 8 19:48 max_net_namespaces -rw-r--r-- 1 root root 0 Nov 8 19:48 max_pid_namespaces -rw-r--r-- 1 root root 0 Nov 8 19:48 max_user_namespaces -rw-r--r-- 1 root root 0 Nov 8 19:48 max_uts_namespaces These files allow you to limit the number of namespaces that can be created *per namespace* type. So let's say your system runs a bunch of user namespaces you can do: chb@conventiont|~ > echo 0 > /proc/sys/user/max_user_namespaces So that the next time you try to create a user namespaces you'd see: chb@conventiont|~ > unshare -U unshare: unshare failed: No space left on device So there's not even a need to upstream a new sysctl since we have ways of blocking this. Also I'd like to point out that a lot of capability checks and actual security vulnerabilities are associated with CAP_SYS_ADMIN. So what you likely want to do is block CAP_SYS_ADMIN in user namespaces but at this point they become basically useless for a lot of interesting use cases. In addition, this patch would add another layer of complexity that is - imho - not really warranted given what we already have. The relationship between capabilities and user namespaces should stay as simply as possible so that it stays maintaineable. User namespaces already introduce a proper layer of complexity. Just my two cents. I might be totally off here of course. Christian From 1583496014848022257@xxx Wed Nov 08 11:11:19 +0000 2017 X-GM-THRID: 1583003759650790753 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread