Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1614867pxf; Fri, 19 Mar 2021 11:05:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeSuupYSkkYdVWaEY5Ddzwb9naxcK4W7JSWuE3F0UQ14EcxDEpYqR/XR97bSK/Un9w/4eq X-Received: by 2002:a17:907:78d9:: with SMTP id kv25mr5920985ejc.415.1616177155767; Fri, 19 Mar 2021 11:05:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616177155; cv=none; d=google.com; s=arc-20160816; b=Rub9nwQXFbIXjojaGL27bHNh6cQZOf693xE+ffhtDT1v/UxzPRgGg2YTry6J90GeFP TuSZC3G4fxRkT+G/7QYOilGZZWQeRW9Vui/eNdr3F3p9psRSaFbvJNG5sPcK0BshAY+l kYQrtnvzvt8WhDWib7B8a9o/FYYrbT83ryAAlV8c0lkVOO6KPmxvnZOYB3ayELEF9uvO fyjHfhOs0G45TnRjfjI1jpiM+UJeqfNgyRss+75qYDXeiaHRm7kopGoNy4X/Nz4vINXK VB/WvmlfNjGLJF79pU1/Aq38i7jT0QjZMlwxELPqwTYfDtsDGcLZAS9uFNaSF02YZLvI XjUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Fgm96KdkqPPp5AyePMeoZ4bVy8WajnICuOF6lgD+oIg=; b=WeGK64fBBD28kHL8kBA4SmEKK2WU/FlgQh++D2/Pltc1Rer40jqH8yIJdI6C3JsmMF w/Lj+MIndG9HoJNELwZU34HpnfvFaHPr2gVdrth1Pe46Xk8/1j/IZp+jThLcX4dmSA/e 7OWrCdxRuUYvSFr91vXjYTP/tNyIhjn43usFRw06fDc5OTiDHdD0M5AVOwFoGHrGBCpW Jokh02y4rhpAtkv/uXFU85KpXRXLxogKo5kO8orIasBV/hiwHN7zKDpiAqMFlACv92AU s0vfLSDOKiBhjY/wWrIimMTaxDuVJayp3dliY80HcDD1GoTJYa4YDSqr6vCEFrMjvvAH tgSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WLn4qJw0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d5si4470612edv.281.2021.03.19.11.05.31; Fri, 19 Mar 2021 11:05:55 -0700 (PDT) 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=pass header.i=@chromium.org header.s=google header.b=WLn4qJw0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230136AbhCSSEH (ORCPT + 99 others); Fri, 19 Mar 2021 14:04:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230063AbhCSSDo (ORCPT ); Fri, 19 Mar 2021 14:03:44 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A85FC061763 for ; Fri, 19 Mar 2021 11:03:44 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id c204so6437752pfc.4 for ; Fri, 19 Mar 2021 11:03:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=Fgm96KdkqPPp5AyePMeoZ4bVy8WajnICuOF6lgD+oIg=; b=WLn4qJw0mRnRd2MuhQP7t0sfnyhwEvjNu988xXSPLRxMyhbXuwpXBBTk46I7unAvON cjyhkk6qSlLOYR0UI87kTBxgP/Wnddx3aAKZdL5coNoywwluId0NvmkBbwQcv409IPbH mzySyBVh/E+KEz95rYinZ5MCAQ1HFNil/owiM= 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; bh=Fgm96KdkqPPp5AyePMeoZ4bVy8WajnICuOF6lgD+oIg=; b=dMvRFoen/Jtpp4Uffnd8RSDGnNL7tRTSabXhd8fZsrtbseT3GGw1P8nUU1O2a3/Flo 9v0EGoRIk/crXn+yHFY9NpRLfm/2gOHgwpMbGxD5X0eExXhQHbEE0wIMvNeqMDBabklw U8jky9qCxF8CuxhsNH58kqNNIIe+dCjW/fyKR4gIHqjTsXW6qqX9ccz9WYcG9Xe9X77x iy6JPtr282pMb6cYxfd0mAC2XB6L72VQXT++27kBu+xmskEiXh6Wmzfh70hWA8c7WfCU p48sbqQwwYjdJ4BPiLHicbNVJXEWGX6giv6UN/3c3VfVPfYijOmvacC4iesN6A3hyvI/ LQnQ== X-Gm-Message-State: AOAM531tSGg+ct5+ld9izm8O0GV2ge0sQrTwWya+uV2aexD8nSQzTN6B JZMseV9A0b9otb4MGUoWelzPpw== X-Received: by 2002:aa7:99c4:0:b029:1f6:c0bf:43d1 with SMTP id v4-20020aa799c40000b02901f6c0bf43d1mr10042556pfi.37.1616177023839; Fri, 19 Mar 2021 11:03:43 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id m16sm5544874pgj.26.2021.03.19.11.03.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Mar 2021 11:03:43 -0700 (PDT) Date: Fri, 19 Mar 2021 11:03:42 -0700 From: Kees Cook To: =?iso-8859-1?Q?Micka=EBl_Sala=FCn?= Cc: James Morris , Jann Horn , "Serge E . Hallyn" , Al Viro , Andrew Morton , Andy Lutomirski , Anton Ivanov , Arnd Bergmann , Casey Schaufler , David Howells , Jeff Dike , Jonathan Corbet , Michael Kerrisk , Richard Weinberger , Shuah Khan , Vincent Dagonneau , kernel-hardening@lists.openwall.com, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-security-module@vger.kernel.org, x86@kernel.org, =?iso-8859-1?Q?Micka=EBl_Sala=FCn?= Subject: Re: [PATCH v30 12/12] landlock: Add user and kernel documentation Message-ID: <202103191056.71AB0515A@keescook> References: <20210316204252.427806-1-mic@digikod.net> <20210316204252.427806-13-mic@digikod.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210316204252.427806-13-mic@digikod.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 16, 2021 at 09:42:52PM +0100, Micka?l Sala?n wrote: > From: Micka?l Sala?n > > This documentation can be built with the Sphinx framework. Well, yes. :) Maybe describe what the documentation covers instead here. Regardless: yay docs! This is great. > [...] > +Bind mounts and OverlayFS > +------------------------- > + > +Landlock enables to restrict access to file hierarchies, which means that these > +access rights can be propagated with bind mounts (cf. > +:doc:`/filesystems/sharedsubtree`) but not with :doc:`/filesystems/overlayfs`. > + > +A bind mount mirrors a source file hierarchy to a destination. The destination > +hierarchy is then composed of the exact same files, on which Landlock rules can > +be tied, either via the source or the destination path. These rules restrict > +access when they are encountered on a path, which means that they can restrict > +access to multiple file hierarchies at the same time, whether these hierarchies > +are the result of bind mounts or not. > + > +An OverlayFS mount point consists of upper and lower layers. These layers are > +combined in a merge directory, result of the mount point. This merge hierarchy > +may include files from the upper and lower layers, but modifications performed > +on the merge hierarchy only reflects on the upper layer. From a Landlock > +policy point of view, each OverlayFS layers and merge hierarchies are > +standalone and contains their own set of files and directories, which is > +different from bind mounts. A policy restricting an OverlayFS layer will not > +restrict the resulted merged hierarchy, and vice versa. Can you include some examples about what a user of landlock should do? i.e. what are some examples of unexpected results when trying to write policy that runs on top of overlayfs, etc? > [...] > +File renaming and linking > +------------------------- > + > +Because Landlock targets unprivileged access controls, it is needed to properly > +handle composition of rules. Such property also implies rules nesting. > +Properly handling multiple layers of ruleset, each one of them able to restrict > +access to files, also implies to inherit the ruleset restrictions from a parent > +to its hierarchy. Because files are identified and restricted by their > +hierarchy, moving or linking a file from one directory to another implies to > +propagate the hierarchy constraints. To protect against privilege escalations > +through renaming or linking, and for the sack of simplicity, Landlock currently typo: sack -> sake > [...] > +Special filesystems > +------------------- > + > +Access to regular files and directories can be restricted by Landlock, > +according to the handled accesses of a ruleset. However, files that do not > +come from a user-visible filesystem (e.g. pipe, socket), but can still be > +accessed through /proc/self/fd/, cannot currently be restricted. Likewise, > +some special kernel filesystems such as nsfs, which can be accessed through > +/proc/self/ns/, cannot currently be restricted. For now, these kind of special > +paths are then always allowed. Future Landlock evolutions will enable to > +restrict such paths with dedicated ruleset flags. With this series, can /proc (at the top level) be blocked? (i.e. can a landlock user avoid the weirdness by making /proc/$pid/ unavailable?) > +Ruleset layers > +-------------- > + > +There is a limit of 64 layers of stacked rulesets. This can be an issue for a > +task willing to enforce a new ruleset in complement to its 64 inherited > +rulesets. Once this limit is reached, sys_landlock_restrict_self() returns > +E2BIG. It is then strongly suggested to carefully build rulesets once in the > +life of a thread, especially for applications able to launch other applications > +that may also want to sandbox themselves (e.g. shells, container managers, > +etc.). How was this value (64) chosen? -- Kees Cook