Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4646996pxu; Thu, 10 Dec 2020 01:44:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJxi28XlZN9Cay9ozGkOHOKhz47lBcxePvo4KvwCuChswRWmudQYu9YmCJ/mSRhwVJPMSu7Y X-Received: by 2002:a05:6402:949:: with SMTP id h9mr5785985edz.301.1607593455701; Thu, 10 Dec 2020 01:44:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607593455; cv=none; d=google.com; s=arc-20160816; b=tSiEC/h4ZVaupTv3pxOSb8u6WAQyM/n/EmZa6GclI5fvjkGYYiMTKijhiorkA05Td0 uxk6mDFWPVcu0TcBbBM3l6KV8vRZOky7ezoK0olb5LZNs7+vqzwBkDLXeznhY7VrRU1B /k99Ru86Azk6dMb8FtcA5htOvoDvFPFAjmy67KaUJpdMnm8wQP0uy/015ZI3VHvKv/wE wiHuJGImwddhd4qUwlR3FPTsU4v2RQFizvJqOrlTP3TAjqz8yBYsGzIKTayi96jChFIi rJuh7Dc3+MDG3K2HqYdEAXYzI41sznqQfnQmg6qM30di7jfYszIoGfZ+kEN7nmlzdwT1 XFZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=lv1NfgTb7QIF3AXa/c4X8+rTmIE6V/EqKtuPGFR6zg8=; b=lQgiSwJoJbQ4xHwAfmrUVZcT2/+5sEN00RgZKIKVjCHCJEOZxX1WtzkSwLyEtepRlG IlmbpGXbLCOsbx2HKTFZfwQHsRN2brAv0cxiYZXhoED7+tMM2TQ4KyW4bOXvt5jt0xkd b7O0aBKgw/1E9F0Dtu45+qRgEjRXXidGSinN6v32YGmBgKG77H4/eIR8Qha/fmr83HqR geZjkllrkT+dOhg8FpI/UutWY8II1bM9VNAF7ciqMuQopWW/PhwP6rbdhoCqAxCQZV8W +YO6jROKAUr5xfqSGMLUwTcTY/I9x48c3WvQyMJllCdzJ6+Hx4Vh2FVIdDu7oBnU1OyH Zrjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=S7Pkm4cC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x91si2254061edc.442.2020.12.10.01.43.53; Thu, 10 Dec 2020 01:44:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=S7Pkm4cC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732782AbgLJJki (ORCPT + 99 others); Thu, 10 Dec 2020 04:40:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730317AbgLJJkg (ORCPT ); Thu, 10 Dec 2020 04:40:36 -0500 Received: from mail-vs1-xe42.google.com (mail-vs1-xe42.google.com [IPv6:2607:f8b0:4864:20::e42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0DBBC0613CF for ; Thu, 10 Dec 2020 01:39:55 -0800 (PST) Received: by mail-vs1-xe42.google.com with SMTP id q10so2485298vsr.13 for ; Thu, 10 Dec 2020 01:39:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lv1NfgTb7QIF3AXa/c4X8+rTmIE6V/EqKtuPGFR6zg8=; b=S7Pkm4cCLEf4W4nwx8c7uks4lJK8p3/l3GOZ1ira+Vv19bt2HnmTD4QjI4tfkEzNIj rAcSOaVsaZUwp3dwaYi12HGVGQIo/DJKFgNGpYZpWmlf7Z3oT7XRlTBL3jNn61FgQgQP A1SW+/t+IAi+hS2p1U4fvyLHgRh05nhpeoxv4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lv1NfgTb7QIF3AXa/c4X8+rTmIE6V/EqKtuPGFR6zg8=; b=Xks+K2oivnppZZ/hVUc68c3BPLWa1tbQXeVR79c/akGXrA/Ta8ID//HU9AazQV6yg+ BF4gFJhrBYEFkxIiNtllRdyJgYH0bqbsTxepWct5/c/WZ9sWxjOn967Nq08g942nELNI BvhsDSN57LPliKnD9A9ypHPZWQCx/MohHx8LfDYx+6TAP2VljBjUKVcFohkBU8qS+AlJ h6HpMSlrc8VMa6hTHVA+OT2KRWQd30h6H/cThX5sO8C5Jw53PzJLBORi6QT1SZ0qWM8l G8TPwYsuvZ9+NiUfgN71IHspIwfLlS35a2ynhSF3AMT9iMGdDzH7iovfGjCqvg8ovwy6 KLYA== X-Gm-Message-State: AOAM530dGB1Pymk7owrbtt+SBn5y3iiIFLvG9F6/q+YNd0qdoxft5A/n hWN2DL1cRxg6ululwZDUOYFHlcL7nym87rt0f5bG3w== X-Received: by 2002:a05:6102:2:: with SMTP id j2mr6462091vsp.47.1607593195047; Thu, 10 Dec 2020 01:39:55 -0800 (PST) MIME-Version: 1.0 References: <20201207163255.564116-1-mszeredi@redhat.com> <1725e01a-4d4d-aecb-bad6-54aa220b4cd2@i-love.sakura.ne.jp> <7a64acab-dd05-765f-df2c-4896eb6a29df@canonical.com> In-Reply-To: <7a64acab-dd05-765f-df2c-4896eb6a29df@canonical.com> From: Miklos Szeredi Date: Thu, 10 Dec 2020 10:39:44 +0100 Message-ID: Subject: Re: [PATCH v2 00/10] allow unprivileged overlay mounts To: John Johansen Cc: Tetsuo Handa , Miklos Szeredi , "Eric W . Biederman" , linux-fsdevel@vger.kernel.org, overlayfs , LSM , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 10, 2020 at 10:00 AM John Johansen wrote: > > On 12/8/20 2:27 AM, Tetsuo Handa wrote: > > On 2020/12/08 1:32, Miklos Szeredi wrote: > >> A general observation is that overlayfs does not call security_path_*() > >> hooks on the underlying fs. I don't see this as a problem, because a > >> simple bind mount done inside a private mount namespace also defeats the > >> path based security checks. Maybe I'm missing something here, so I'm > >> interested in comments from AppArmor and Tomoyo developers. > > > > Regarding TOMOYO, I don't want overlayfs to call security_path_*() hooks on the > > underlying fs, but the reason is different. It is not because a simple bind mount > > done inside a private mount namespace defeats the path based security checks. > > TOMOYO does want to check what device/filesystem is mounted on which location. But > > currently TOMOYO is failing to check it due to fsopen()/fsmount()/move_mount() API. > > > > Regardless of TOMOYO's approach I would say that overlays should call the > security_path_*() hooks, making it possible for an LSM to do something based off of > them when needed. > > The current state of private mounts with regard to path based mediation is broken. > I just haven't had time to try and come up with an acceptable fix for it. overlayfs > is actually broken under apparmor mediation, and accesses to the lower layer end up > getting denied but there is no way to properly allow them. So policy that hits this > needs a flag set that allows for it in a very hacky way (its on the list of things > to fix). > > Path based mediation has to carefully control mounts otherwise policy can be > circumvented as Miklos rightly points out. Ideally path based LSM wouldn't allow > you to do the simple bind mount inside a private mount namespace (at least not > unless policy allowed for it). AppArmor does mediate the mount hooks and bind > mounts in a private mount namespace (if they go through the LSM mount hooks) will > be denied. Again the problem is how to allow them, and this is broken. Okay, so what does that mean for overlayfs? AA can deny the overlay mount just as well as the bind mount, and it can allow it just as well as the bind mount. Policy could be the same. Also all the security_path_ hooks will still get called for each access on overlayfs itself. They won't be called for the accesses which overlayfs does on underlying layers, but is that needed? Overlay could call those hooks itself (since the vfs_ helpers don't) but the big question is whether that makes any sense. AFAICS it might make sense, but only if AA would correctly handle bind mounts, and especially detached bind mounts (which is what overlayfs technically uses). Thanks, Miklos Tja