linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Mickaël Salaün" <mic@digikod.net>
To: Kees Cook <keescook@chromium.org>
Cc: "James Morris" <jmorris@namei.org>,
	"Jann Horn" <jannh@google.com>,
	"Serge E . Hallyn" <serge@hallyn.com>,
	"Al Viro" <viro@zeniv.linux.org.uk>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Andy Lutomirski" <luto@amacapital.net>,
	"Anton Ivanov" <anton.ivanov@cambridgegreys.com>,
	"Arnd Bergmann" <arnd@arndb.de>,
	"Casey Schaufler" <casey@schaufler-ca.com>,
	"David Howells" <dhowells@redhat.com>,
	"Jeff Dike" <jdike@addtoit.com>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Michael Kerrisk" <mtk.manpages@gmail.com>,
	"Richard Weinberger" <richard@nod.at>,
	"Shuah Khan" <shuah@kernel.org>,
	"Vincent Dagonneau" <vincent.dagonneau@ssi.gouv.fr>,
	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,
	"Mickaël Salaün" <mic@linux.microsoft.com>
Subject: Re: [PATCH v30 12/12] landlock: Add user and kernel documentation
Date: Tue, 23 Mar 2021 20:25:00 +0100	[thread overview]
Message-ID: <206f1577-0607-1e01-16c2-219418eea332@digikod.net> (raw)
In-Reply-To: <81c76347-9e92-244f-6f32-600984a6c5cb@digikod.net>



On 19/03/2021 19:54, Mickaël Salaün wrote:
> 
> On 19/03/2021 19:03, Kees Cook wrote:
>> On Tue, Mar 16, 2021 at 09:42:52PM +0100, Mickaël Salaün wrote:
>>> From: Mickaël Salaün <mic@linux.microsoft.com>
>>>
>>> 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.

What about that?

Add a first document describing userspace API: how to define and enforce
a Landlock security policy.  This is explained with a simple example.
The Landlock system calls are described with their expected behavior and
current limitations.

Another document is dedicated to kernel developers, describing guiding
principles and some important kernel structures.

This documentation can be built with the Sphinx framework.


>>
>>> [...]
>>> +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?
> 
> Landlock works well with overlayfs, at least from my point of view. It
> may be a bit disturbing with bind mount though, but it is the same with
> other access-controls (e.g. DAC). Landlock users should just think about
> file hierarchies and create their policies accordingly. A user should
> not try to adapt a policy according to his/her understanding of
> overlayfs, but just think about file hierarchies.
> 
>>
>>> [...]
>>> +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
> 
> Indeed
> 
>>
>>> [...]
>>> +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?)
> 
> /proc can be blocked, but not /proc/*/ns/* because of disconnected
> roots. I plan to address this.
> 
>>
>>> +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?
>>
> 
> It was first an implementation constraint to limit the memory allocated
> for each rule, but it could now be increased if needed. The
> implementation still uses u64 for the sake of simplicity, but we could
> switch to a bitmap type.
> 

  reply	other threads:[~2021-03-23 19:25 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-16 20:42 [PATCH v30 00/12] Landlock LSM Mickaël Salaün
2021-03-16 20:42 ` [PATCH v30 01/12] landlock: Add object management Mickaël Salaün
2021-03-19 18:13   ` Kees Cook
2021-03-19 18:57     ` Mickaël Salaün
2021-03-16 20:42 ` [PATCH v30 02/12] landlock: Add ruleset and domain management Mickaël Salaün
2021-03-19 18:40   ` Kees Cook
2021-03-19 19:03     ` Mickaël Salaün
2021-03-19 19:15       ` Kees Cook
2021-03-24 20:31       ` James Morris
2021-03-25  9:29         ` Mickaël Salaün
2021-03-23  0:13   ` Jann Horn
2021-03-16 20:42 ` [PATCH v30 03/12] landlock: Set up the security framework and manage credentials Mickaël Salaün
2021-03-19 18:45   ` Kees Cook
2021-03-19 19:07     ` Mickaël Salaün
2021-03-16 20:42 ` [PATCH v30 04/12] landlock: Add ptrace restrictions Mickaël Salaün
2021-03-19 18:45   ` Kees Cook
2021-03-16 20:42 ` [PATCH v30 05/12] LSM: Infrastructure management of the superblock Mickaël Salaün
2021-03-19 17:24   ` Kees Cook
2021-03-16 20:42 ` [PATCH v30 06/12] fs,security: Add sb_delete hook Mickaël Salaün
2021-03-19 17:24   ` Kees Cook
2021-03-16 20:42 ` [PATCH v30 07/12] landlock: Support filesystem access-control Mickaël Salaün
2021-03-18 23:10   ` James Morris
2021-03-19 18:57   ` Kees Cook
2021-03-19 19:19     ` Mickaël Salaün
2021-03-23 19:30       ` Mickaël Salaün
2021-03-23  0:13   ` Jann Horn
2021-03-23 15:55     ` Mickaël Salaün
2021-03-23 17:49       ` Jann Horn
2021-03-23 19:22         ` Mickaël Salaün
2021-03-24  3:10           ` Jann Horn
2021-03-16 20:42 ` [PATCH v30 08/12] landlock: Add syscall implementations Mickaël Salaün
2021-03-19 19:06   ` Kees Cook
2021-03-19 21:53     ` Mickaël Salaün
2021-03-24 15:03       ` Mickaël Salaün
2021-03-16 20:42 ` [PATCH v30 09/12] arch: Wire up Landlock syscalls Mickaël Salaün
2021-03-16 20:42 ` [PATCH v30 10/12] selftests/landlock: Add user space tests Mickaël Salaün
2021-03-19 17:56   ` Kees Cook
2021-03-19 18:41     ` Mickaël Salaün
2021-03-19 19:11       ` Kees Cook
2021-03-19 21:57         ` Mickaël Salaün
2021-03-16 20:42 ` [PATCH v30 11/12] samples/landlock: Add a sandbox manager example Mickaël Salaün
2021-03-19 17:26   ` Kees Cook
2021-03-16 20:42 ` [PATCH v30 12/12] landlock: Add user and kernel documentation Mickaël Salaün
2021-03-19 18:03   ` Kees Cook
2021-03-19 18:54     ` Mickaël Salaün
2021-03-23 19:25       ` Mickaël Salaün [this message]
2021-03-24 16:21       ` Mickaël Salaün
2021-03-18 23:26 ` [PATCH v30 00/12] Landlock LSM James Morris
2021-03-19 15:52   ` Mickaël Salaün

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=206f1577-0607-1e01-16c2-219418eea332@digikod.net \
    --to=mic@digikod.net \
    --cc=akpm@linux-foundation.org \
    --cc=anton.ivanov@cambridgegreys.com \
    --cc=arnd@arndb.de \
    --cc=casey@schaufler-ca.com \
    --cc=corbet@lwn.net \
    --cc=dhowells@redhat.com \
    --cc=jannh@google.com \
    --cc=jdike@addtoit.com \
    --cc=jmorris@namei.org \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mic@linux.microsoft.com \
    --cc=mtk.manpages@gmail.com \
    --cc=richard@nod.at \
    --cc=serge@hallyn.com \
    --cc=shuah@kernel.org \
    --cc=vincent.dagonneau@ssi.gouv.fr \
    --cc=viro@zeniv.linux.org.uk \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).