Received: by 10.223.164.202 with SMTP id h10csp299720wrb; Wed, 8 Nov 2017 16:57:02 -0800 (PST) X-Google-Smtp-Source: ABhQp+Srf+GfxdPFXpdsY6QiJvn4xI+4/IWVY66tUQ+KHd83iknoUIEBhDCRcvbQu0pl+Zm817z1 X-Received: by 10.84.162.204 with SMTP id o12mr2032937plg.230.1510189022755; Wed, 08 Nov 2017 16:57:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510189022; cv=none; d=google.com; s=arc-20160816; b=XYnFJv7e6zLO2zjmGOB2wQxv+1+AZsdT4dfIVcqiJSLCftOB92A1YE0DyslN7G/A9D fMbF09TWsViE8SQMFP0FvYHOXXYTzwmVDINywOXdjaVrbDBhkR/7XoiCQ0vf9TfxdRAn BpGCyqvwSAImhsLk+AUnGAJGdtKbbL3xRL8z5eEbuuKM5jnWWfpsI9gzsJpw6iaXki++ e6kAklcLbkZdVyhG8TTutE9P4hpLThQQAZ94muEpqL82UVo2wc9vuONo9TrSGtxgPo+G ZI3JNNdq1GcBflhmCGbEl60YGNH4biTo8gogoXRaWOMSGsrIh2TjOOec2/HnTy8jGbVA d58w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=HjGvs/LL63TdROIVc50bAqSMyCAgDE3FqB235C7YNRc=; b=e0RulOFIXYSs37myVmJ4alVaN9R9ZIKQiKZkOf3U6n9+kzgV/PAXuAaXQSK//FUMzr I0CbBwjA4RecnGT5nAJ7VpqlcQJP47GnZ77/rB0DZ1hHLrEGjTF07aFzSU0v0eFJox7U 9P9N21g7J8Ctq+6SUAQTg7p0nSSihaqW/X4M+RqHccMxe5qlaeuOxaQttmBlOe2FVMr2 hpLCmNm6LQ3GQtowakNjsAuCbe/Q1nyS2IvjoZGABX0CmoXpLhd1iNnAILelh+9/5J4S KPPqG3KrEPA7B+2NcZb7pfqYcfBqbaNTuNKWLhZpJ7NFmyZSl1fbJO4eR4Xhi01+73al QQkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=U4rJ2RTj; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g207si5288509pfb.413.2017.11.08.16.56.50; Wed, 08 Nov 2017 16:57:02 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=U4rJ2RTj; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753441AbdKIA4F (ORCPT + 84 others); Wed, 8 Nov 2017 19:56:05 -0500 Received: from mail-yw0-f180.google.com ([209.85.161.180]:55936 "EHLO mail-yw0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752985AbdKIA4D (ORCPT ); Wed, 8 Nov 2017 19:56:03 -0500 Received: by mail-yw0-f180.google.com with SMTP id t11so3925572ywg.12 for ; Wed, 08 Nov 2017 16:56:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=HjGvs/LL63TdROIVc50bAqSMyCAgDE3FqB235C7YNRc=; b=U4rJ2RTjk/jBDdNpjVBXfzDWFScqtBKvWekJ5s9yELpZPfCzBSnpgIY7bWvSq2Yr7w RVUJYJ17cm9ekbVOVTEssZjUCWp5cTLuySAky+VsiUPSNcEwza7HLgz2NxVh6/sr1a9C MuCQi4bteqAOw2q59rAXtD0/OjViIzeIG23Y5zaPX7XrSE+XjdWxOzkpi5+EdqzDyo1H i5nHGVlf5bh6Qt3H2pae809k3AUMeLU0Fj4qJVBEHcLjJtQF2pnHGXnZjl3ZQQVjXj0X 89Brrra0kYeyODLY6MtvosHUt1gtW27W6K3DDdt14dUvN3o0BhHxkuVsk2QbwBfvBvVu F4Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=HjGvs/LL63TdROIVc50bAqSMyCAgDE3FqB235C7YNRc=; b=V1U1NuvTlv2N+VnMfCN9avv8JCpFzAJfA1A3GR1uXLpyOV4rlBgTZUdVDuF1+RR8Qa n1YAa853DmSQ5VsHolz1ALshBbkHYei8bCoC2hNIc28Vw2938f/1dTPFvzptGrac/7rh cIIaRZqQ12FCoZdgFuw8hr2RUaQJOnfR2+PIgUHoI0DrvcoPdI9p7bJShX9a93sACwaT nwcb7y9a1LQgrFNg4S4iYkO1XZVUcoAHAJz7IGYWR1G2ajCLQMstsAxyRxy2R+lFQvQ+ ajhNuNbHBPcTPpFc3Ce3NE9LCtq0NKzlloHfkBThDlszhqjnYw3qWcOJ7f9xARO258iB v07Q== X-Gm-Message-State: AJaThX4p+7b8/ODzmrqum8CcjHjUieDHrEU8K5/zfheM9It+26SxUB0z oi9nIKv/dqWO3Slzb4X+gPgzsnYbl0jgCzUNiN19qw== X-Received: by 10.37.8.70 with SMTP id 67mr1470922ybi.265.1510188962106; Wed, 08 Nov 2017 16:56:02 -0800 (PST) MIME-Version: 1.0 Received: by 10.37.131.198 with HTTP; Wed, 8 Nov 2017 16:55:41 -0800 (PST) In-Reply-To: <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> <20171108190223.vdkyepcaegmub6le@gmail.com> From: =?UTF-8?B?TWFoZXNoIEJhbmRld2FyICjgpK7gpLngpYfgpLYg4KSs4KSC4KSh4KWH4KS14KS+4KSwKQ==?= Date: Thu, 9 Nov 2017 09:55:41 +0900 Message-ID: Subject: Re: [kernel-hardening] Re: [PATCH resend 2/2] userns: control capabilities of some user namespaces To: Christian Brauner 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 9, 2017 at 4:02 AM, Christian Brauner wrote: > On Wed, Nov 08, 2017 at 03:09:59AM -0800, Mahesh Bandewar (=E0=A4=AE=E0= =A4=B9=E0=A5=87=E0=A4=B6 =E0=A4=AC=E0=A4=82=E0=A4=A1=E0=A5=87=E0=A4=B5=E0= =A4=BE=E0=A4=B0) 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 ta= pe >> > 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=C3=A9phane today about this and we should also ke= ep 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 creat= ed > *per namespace* type. So let's say your system runs a bunch of user names= paces > 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. > I'm not sure how it's solving the problem that my patch-set is addressing? I agree though that the need for unprivileged_userns_clone sysctl goes away as this is equivalent to setting that sysctl to 0 as you have described above. However as I mentioned earlier, blocking processes from creating user-namespaces is not the solution. Processes should be able to create namespaces as they are designed but at the same time we need to have controls to 'contain' them if a need arise. Setting max_no to 0 is not the solution that I'm looking for since it doesn't solve the problem. > Also I'd like to point out that a lot of capability checks and actual sec= urity > vulnerabilities are associated with CAP_SYS_ADMIN. So what you likely wan= t 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 p= atch > would add another layer of complexity that is - imho - not really warrant= ed > given what we already have. I disagree. I'm not sure how this patch is adding complexity? Simply the functionality is maintained exactly as it is with an extra knob which allows you to take control back if a situation arise. Once the kernel is patched for whatever was discovered, life returns back to normal by readjusting the knob. It's as simple as that! > The relationship between capabilities and user > namespaces should stay as simply as possible so that it stays maintaineab= le. > User namespaces already introduce a proper layer of complexity. > Just my two cents. I might be totally off here of course. The side effect of the solution is that you have sort-of scaled-down / broken functionality without blocking the feature completely until life returns to normal. If the workload needs the exact same capability that is being controlled, then tough luck but chances of you having a workload that is not in contention with the capability that is being controlled is very high. In a situation like that you wont even notice the change but at the same time admin can ensure that the exploit is contained. This has a very high value. > > Christian From 1583525716757457391@xxx Wed Nov 08 19:03:25 +0000 2017 X-GM-THRID: 1583003759650790753 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread