Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4762605imm; Mon, 18 Jun 2018 22:40:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI9ywHegpV/gVbquauCXKiPG4BImrdgg5F7ndr0bPPf5aY7meeL9YR7L89O5sQIHDi0NIbe X-Received: by 2002:a17:902:760d:: with SMTP id k13-v6mr16948863pll.56.1529386848717; Mon, 18 Jun 2018 22:40:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529386848; cv=none; d=google.com; s=arc-20160816; b=NTNJmxshlRT/TQID5AsSPd3Jo2SSIC26cjsZOROZ5tAiiTY/zNMRvTZxEmrJ2vTn2u pzGaPSH92qBAZyOVJvVS6IMNYvIEzQaV5O6jRlbzPKp5r3Vf38qCJJ8B2FIRDPe+exuV 9Nv7y+ohhmHTCj3MNfLF02iGZsSK96F2S45jFQ4fesoqRafP8FxliEke6hFgXaoBDJtK /ZNx1DLgPBHhrEzJbPwK54lsc3OPkwYY8RL8injhMSWDMHb2Yma4Ok/Wd6orgs+WF3QV Fya4bn4FNY4rOvZNLI1qNhXJl7ChmiRNbwqg+mMe3JhggvbTWQs5tPmdfUFbFppEBRR3 u9SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=jRmR9Ir7Hxv5BEAB9O55qM501tg9AC56/e8gCFTlL5Q=; b=Ox/Ec2qOuXsJ1jdpIKCF/0C298OIxMnbQRWKz5DxnIKviBeAVaLv7lE+GT8B/8xENt ri1TlpbyEZLkvoGTjqzgTtzBQS5B7OejSBEBIvNjsW62ioiER/hf+gRepcn++kTNWMSu 87do5qIhCXcNag8KmejJ/1bPcgOXoI4+8zq7jWTwb8V3RdHojNRzmEa37kuFPw2obDc+ fmBjTPQB1CCIeeinSw9xa+1U4uADT6cAOij79NuTtweGQ4amjNsr3qdbcTeSRD3P+W7o adUJYCXZEq2TcXYoS3FmJmPRngY9IYuvqZ4CU53cwaBG5hyui2mgCssHXTqnzg1wrgLA FKNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=r6YkbgiS; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c14-v6si13364099pgw.478.2018.06.18.22.40.33; Mon, 18 Jun 2018 22:40:48 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=r6YkbgiS; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965049AbeFSFjM (ORCPT + 99 others); Tue, 19 Jun 2018 01:39:12 -0400 Received: from mail-yw0-f194.google.com ([209.85.161.194]:44036 "EHLO mail-yw0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755840AbeFSFjK (ORCPT ); Tue, 19 Jun 2018 01:39:10 -0400 Received: by mail-yw0-f194.google.com with SMTP id k18-v6so5919861ywm.11; Mon, 18 Jun 2018 22:39:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=jRmR9Ir7Hxv5BEAB9O55qM501tg9AC56/e8gCFTlL5Q=; b=r6YkbgiSr4Y4r+cexYf0i3G61id72X8ZJAoHbS9YFPg6jfWKLeSXg+35yFhZHKvysE rge/w7hEPJUClhwY3cECuugEFz4/6J/lvDJj4oLSFXUX50jQjFOiNcGkTjvaeZiSYjI3 2TA3rROxABmPZE+qaILiUJceJbg1EZn7BdMpCtT0x3laSypWtadnK4Rvnz4AtfMjjgMy oXNFpdcB897XkwSLoOkevJT4aEoJPPObnB9st+dCDnouoPB/4pFtApcs1ccfYqp6MBgY 7qxiOIVdxD2QazZWDZq+hoT7yoS/j7bWpVOO52SDjMesK7/7vdDahNP0xaKbD9at/3IS qQ0A== 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; bh=jRmR9Ir7Hxv5BEAB9O55qM501tg9AC56/e8gCFTlL5Q=; b=Hy3plJJxuUrmCBqhH04vIK3DqrQk9iTUfE01j+glsAP/riZhOaVFQffQ8eH5aoTpZ2 pgBkEXvHq5ks7KW0brcgEWfjtKhfILnXkJYxCT61+/o8TI/nbvi90FKPfevXapsycmt/ i0rVmr8yc5MXFyFa82aFf5UNFMiVzs8Ylijzqr+U9SHCdOoYxOP1XyvISoPvWIR+BiXk dWgDskHMZoM8YQ/mIQggGLjazjnEa8P5OPLXtLu2Lak1/wROwiSlSSA3cYEXafDDnO5Z FAvPd2C3nkAGCbgFXVl1T4BqUATTSMlLmbiOwbuIrY6YrSry/1+3b9iodPciN2vF0F1b HWTg== X-Gm-Message-State: APt69E31ZHSbvgfJKhza9QyQvmtnrbedc8/4qYRcVxXA9Y47jvB8+j8P 9w1hw9dR4vynNH5o/9vFwKidRGTHBy5OuFzuxZE= X-Received: by 2002:a81:3050:: with SMTP id w77-v6mr7146341yww.88.1529386749151; Mon, 18 Jun 2018 22:39:09 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a81:79cf:0:0:0:0:0 with HTTP; Mon, 18 Jun 2018 22:39:08 -0700 (PDT) In-Reply-To: <87in6fagxw.fsf@xmission.com> References: <20180618192726.67981-1-salyzyn@android.com> <87in6fagxw.fsf@xmission.com> From: Amir Goldstein Date: Tue, 19 Jun 2018 08:39:08 +0300 Message-ID: Subject: Re: [PATCH v2] overlayfs: caller_credentials option bypass creator_cred To: "Eric W. Biederman" Cc: Mark Salyzyn , linux-kernel , Miklos Szeredi , Jonathan Corbet , Vivek Goyal , overlayfs , linux-doc@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 19, 2018 at 1:05 AM, Eric W. Biederman wrote: > Mark Salyzyn writes: > >> All accesses to the lower filesystems reference the creator (mount) >> context. This is a security issue as the user context does not >> overlay the creator context. > > Sigh. You gave Vivek a reasonable description of what is going on > and then you did not repeat it here. Your patch description > very much needs to be fixed. > > As I read your patch there you are removing an override in credentials. > Presumably that override is needed for the fileystem to function. > > If that override is needed to function your patch is incorrect > because it breaks things for no reason. > > If that override is not needed it should be safe to explain why > and simply remove it from overlayfs. > Eric is correct about override being needed for filesystem to function because overlayfs calls mknod and sets trusted xattr. Alas, overlayfs makes an assumption that if mounter has credentials to mount, it also has credentials for those other things, which so far, nobody complained about AFAIK. There was one complain though about abusing SYS_CAP_RESOURCE of mounter to exceed underlying ext4 quotas, so that capability has been recently revoked unconditionally from the override creds - that makes a user with SYS_CAP_RESOURCE also incapable of exceeding underlying ext4 quotas (a good thing IMO, but that is arguable). Ideally, the correct solution would be to "merge" the mounter creds and caller creds and use different combinations of the two in different cases, but that would complicate the code and the test matrix considerably. > I don't see any real explanations in this change description. > So this appears to be an incompletely thought out change. > > > Mostly this looks like someone tried to use the principle of least > privilege in your Android implementation and got it wrong. Having given > the mounter of overlayfs too few privileges this appears to be an > attempt to get overlayfs to pay the cost of an implementation mistake in > the Android security model. > > That seems like a very unreasonable thing to do. > To the best of my knowledge, the Android sepolicy rules for init have been like that for a very long time. I am not sure why Eric claims the unreasonable claim. Not sure who the users of overlayfs are going to be though and if it is possible to guaranty that they have capabilities to mknod and set trusted xattr (needed for removing dirs among other things). As it is, the patch is simple enough and only makes an existing functionality optional, so if it *really* solves the Android use case, and there is *really* no other "reasonable" way to configure Android sepolicy, I rather have this patch than the more "correct" implementation. Two comments about the patch in case we are going forward with it: 1. I would use the same convention for Kconfig/module param/mount option as used for other overlayfs defaults, i.e. override_creds=on/off and Kconfig default which defaults to the legacy behavior. 2. with override_creds=off, all the checks being done during mount become irrelevant (e.g. mounter can set trusted xattr), so either skip them and issue a warning saying that we really hope mounter knows what it is doing, or I don't know what. Thanks, Amir.