Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp365713pxx; Thu, 29 Oct 2020 04:42:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyX845JamvdPYTXAcJ07Zp8U1J+WXSg8hqEaB4mqROBfy7+tg4zu589uHOuxVRsdafuUqyE X-Received: by 2002:a17:906:6702:: with SMTP id a2mr3495977ejp.309.1603971749721; Thu, 29 Oct 2020 04:42:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603971749; cv=none; d=google.com; s=arc-20160816; b=XDYuYGHGIJiHEnxQ3Rw1LAqjjAN9a2R15mVXV6MpNP+Vl+NCjSxZ+7Hf4qyCsN+r8m WANk3F3Of1O1YmfZU6GZh/tc+3CIMqoAUIBwboZ1yrdcUCuWzzUypN9XJ7LHPCIydozI UfhF00aZNWsjFN6AErNOktuEZI2/LnrnNiPK/3sJLOFLQTTYtJoD7tsVN7BVwiQ1oWy4 dUdCw2nXOW9v+Pp75+Wzxhsi/7WZqb4ZpIVddhJWqDB/JuEuqbV6gJq1Y9EbnU4llAc2 8Q40g3m9o3LLU3dukAlucnvgr8QijvDSzapeVpobmXJ5Onp/G3mRmgGgQo4B6PrwlCjs GdYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=5r6S/perIJu6LuxaQ+aAeWS4vGmH3/ZLmb2+H/O9zfs=; b=TGsRu/NJ6heIQJWc2tRYkegEDnHDn0M++P+5dFmCCRVDwCLY4IoZLNN2GMw9inYHMs w/wROhJxCLfdLFzSeDFJ3nN4/BGom/KoQxCnUfJi3sEYtK9Rz0LZjJgrar7FGYr73rCG E5HwygMDooD0hLIaERJ4MUJkUvTc2+6jm5WLcRNKzawXEDa7KWFAE7h/WRuD90fM3/7Q to25FOvxBNsiywpA1pOLnI3LwUQ41qdPCfWSo7WcAiltEJ+zFlh1/nztLcEPl2alqnkM sKncU1J/T3nu7qWPqXt92VAYVXuyVsyti4KYL+L1UYqSWlmbTcuDbSw3SyUh67q+b+Rc ijMw== ARC-Authentication-Results: i=1; mx.google.com; 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 g11si1803785edn.315.2020.10.29.04.42.07; Thu, 29 Oct 2020 04:42:29 -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; 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 S1725859AbgJ2Lip (ORCPT + 99 others); Thu, 29 Oct 2020 07:38:45 -0400 Received: from smtp-42ac.mail.infomaniak.ch ([84.16.66.172]:59013 "EHLO smtp-42ac.mail.infomaniak.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725849AbgJ2Lid (ORCPT ); Thu, 29 Oct 2020 07:38:33 -0400 Received: from smtp-2-0001.mail.infomaniak.ch (unknown [10.5.36.108]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4CMNjx2wM5zlkXcn; Thu, 29 Oct 2020 12:38:29 +0100 (CET) Received: from ns3096276.ip-94-23-54.eu (unknown [94.23.54.103]) by smtp-2-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4CMNjv2kl6zlh8TS; Thu, 29 Oct 2020 12:38:27 +0100 (CET) Subject: Re: [PATCH v22 12/12] landlock: Add user and kernel documentation To: Jann Horn Cc: James Morris , "Serge E . Hallyn" , Al Viro , Andy Lutomirski , Anton Ivanov , Arnd Bergmann , Casey Schaufler , Jeff Dike , Jonathan Corbet , Kees Cook , Michael Kerrisk , Richard Weinberger , Shuah Khan , Vincent Dagonneau , Kernel Hardening , Linux API , linux-arch , "open list:DOCUMENTATION" , linux-fsdevel , kernel list , "open list:KERNEL SELFTEST FRAMEWORK" , linux-security-module , the arch/x86 maintainers , =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= References: <20201027200358.557003-1-mic@digikod.net> <20201027200358.557003-13-mic@digikod.net> From: =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= Message-ID: Date: Thu, 29 Oct 2020 12:38:26 +0100 User-Agent: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/10/2020 02:07, Jann Horn wrote: > On Tue, Oct 27, 2020 at 9:04 PM Mickaël Salaün wrote: >> This documentation can be built with the Sphinx framework. >> >> Cc: James Morris >> Cc: Jann Horn >> Cc: Kees Cook >> Cc: Serge E. Hallyn >> Signed-off-by: Mickaël Salaün >> Reviewed-by: Vincent Dagonneau > [...] >> diff --git a/Documentation/userspace-api/landlock.rst b/Documentation/userspace-api/landlock.rst > [...] >> +Landlock rules >> +============== >> + >> +A Landlock rule enables to describe an action on an object. An object is > > s/enables to describe/describes/ OK. > >> +currently a file hierarchy, and the related filesystem actions are defined in >> +`Access rights`_. A set of rules is aggregated in a ruleset, which can then >> +restrict the thread enforcing it, and its future children. >> + >> +Defining and enforcing a security policy >> +---------------------------------------- >> + >> +We first need to create the ruleset that will contain our rules. For this >> +example, the ruleset will contain rules which only allow read actions, but >> +write actions will be denied. The ruleset then needs to handle both of these >> +kind of actions. To have a backward compatibility, these actions should be >> +ANDed with the supported ones. > > This sounds as if there is a way for userspace to discover which > actions are supported by the running kernel; but we don't have > anything like that, right? Right, it dates from the landlock_get_features(2), which is now gone but may be replaced by something else in the future. I'll remove that. > > If we want to make that possible, we could maybe change > sys_landlock_create_ruleset() so that if > ruleset_attr.handled_access_fs contains bits we don't know, we clear > those bits and then copy the struct back to userspace? And then > userspace can retry the syscall with the cleared bits? Or something > along those lines? Yes, but I would prefer clear syscall which don't read and write from/to the same argument. I'm working on a more generic solution. It should not be an issue for now. > > [...] >> +We can now add a new rule to this ruleset thanks to the returned file >> +descriptor referring to this ruleset. The rule will only enable to read the > > s/enable to read/allow reading/ OK. > >> +file hierarchy ``/usr``. Without another rule, write actions would then be >> +denied by the ruleset. To add ``/usr`` to the ruleset, we open it with the >> +``O_PATH`` flag and fill the &struct landlock_path_beneath_attr with this file >> +descriptor. > [...] >> +Inheritance >> +----------- >> + >> +Every new thread resulting from a :manpage:`clone(2)` inherits Landlock domain >> +restrictions from its parent. This is similar to the seccomp inheritance (cf. >> +:doc:`/userspace-api/seccomp_filter`) or any other LSM dealing with task's >> +:manpage:`credentials(7)`. For instance, one process's thread may apply >> +Landlock rules to itself, but they will not be automatically applied to other >> +sibling threads (unlike POSIX thread credential changes, cf. >> +:manpage:`nptl(7)`). >> + >> +When a thread sandbox itself, we have the grantee that the related security > > s/sandbox/sandboxes/ > s/grantee/guarantee/ OK. > >> +policy will stay enforced on all this thread's descendants. This enables to >> +create standalone and modular security policies per application, which will > > s/enables to create/allows creating/ OK. > > >> +automatically be composed between themselves according to their runtime parent >> +policies.