Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp499867pxb; Tue, 29 Mar 2022 06:58:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJMafpCvEKoN3k3spTTHZ1Ofgn3/1YLWNXGbg2Z8nqcbeKWN3dML+6IoZUPPuOl9A9zqnm X-Received: by 2002:a17:907:1c16:b0:6d7:622b:efea with SMTP id nc22-20020a1709071c1600b006d7622befeamr34200988ejc.110.1648562323193; Tue, 29 Mar 2022 06:58:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648562323; cv=none; d=google.com; s=arc-20160816; b=M/A5a/tUbGzO1yVjJm7gvviIIT8j/p60D46S7dLBioEQSwfXR1m3pSH+I1HOhMABR7 TkcMV6WA4oHvWJaA1QEXgE4/YfZlI9zS4HzwQfIQAf5JAmm0g6UVaq1IChdna5+BmVMw JAFfvc0218c+fbHumqRSXmJ+zZ623JzwrnNSJUpiwEdu/qJzfagv3ga/XQ/ZBjICLVRI lnEZpoQ6z/8MoLPuUejpuJA1t6e67mb4LAS5Zc3Wsbyi1SaSoZaLxFFLmLHoXB3nAwZS +SYuaSHFVygxh31jS0iK6nHRAKxLplTMr+TYptpnkIjeU3CU+jFvNT8gjnD9/w5DGVkr FsJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kB2kKSwGsrt5gu6e/aiWi+xTNISo9QbUzL0QL21AsHs=; b=vDCQnbc0yzEiaFAdJ0uqOwWmZYPdvP9GF6+Hcf5jBbl1FJBgFZm5AGj+UTDcYqV6LD nwiIybyYxeTJle6aP0I5S31DBzo+Z5jETzofk/FgC64WCambjxp0P+9TVHpBmrCT4rNu DEj0jQDQV/tadIAwDUGgc7l23DlcZggRAVan9bYdx8BHgXeJIqXwLDXAs8YxQMJ6GJnF TXDd81/hMGfa03ySPU8NFWLSeU2ybqDTfdG/TZd4c1l9rggRh9jqnvu0rcIS6iqmTeNw pNam/spFRPSyTXiyWSCj9/ne1DxSt/QPKN1tBwGA9MWs3YSN7XlEiVoPFYjodBNlgRfc jWIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=BPARrTXo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bv7-20020a170906b1c700b006df76385ca8si18001624ejb.328.2022.03.29.06.58.14; Tue, 29 Mar 2022 06:58:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=BPARrTXo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234959AbiC2MyC (ORCPT + 99 others); Tue, 29 Mar 2022 08:54:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237211AbiC2MxD (ORCPT ); Tue, 29 Mar 2022 08:53:03 -0400 Received: from smtp-42ac.mail.infomaniak.ch (smtp-42ac.mail.infomaniak.ch [IPv6:2001:1600:4:17::42ac]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 476981B7BF for ; Tue, 29 Mar 2022 05:51:08 -0700 (PDT) Received: from smtp-2-0000.mail.infomaniak.ch (unknown [10.5.36.107]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4KSTvb4K4XzMpylX; Tue, 29 Mar 2022 14:51:07 +0200 (CEST) Received: from localhost (unknown [23.97.221.149]) by smtp-2-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4KSTvb2X1mzlhSMV; Tue, 29 Mar 2022 14:51:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1648558267; bh=Myv+feEqRMvVi5vshp42PeNetgkHZQ6w/RvawsOsgJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BPARrTXoCBwk6sr/GS0DLrE1KC/kkizLhv/i3QRLmTTo0b1uBLDU/Ra1OqXy17jDV takscT6ICLibCT6uhpFy0hOxVdA2AQjn1XyaLWBBX+vJg/VaL/XHATt5DJNcHqRCsr wMHwzK0Vo3yQI28HNmmTdU5ffh3GZaCRqQamrww4= From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: James Morris , "Serge E . Hallyn" Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Al Viro , Jann Horn , John Johansen , Kees Cook , Konstantin Meskhidze , Paul Moore , Shuah Khan , Tetsuo Handa , linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= Subject: [PATCH v2 11/12] landlock: Document good practices about filesystem policies Date: Tue, 29 Mar 2022 14:51:16 +0200 Message-Id: <20220329125117.1393824-12-mic@digikod.net> In-Reply-To: <20220329125117.1393824-1-mic@digikod.net> References: <20220329125117.1393824-1-mic@digikod.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mickaël Salaün Reviewed-by: Paul Moore Signed-off-by: Mickaël Salaün Link: https://lore.kernel.org/r/20220329125117.1393824-12-mic@digikod.net --- Changes since v1: * Add Reviewed-by: Paul Moore. --- Documentation/userspace-api/landlock.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Documentation/userspace-api/landlock.rst b/Documentation/userspace-api/landlock.rst index b066d281f9f2..4b22c8cd76b4 100644 --- a/Documentation/userspace-api/landlock.rst +++ b/Documentation/userspace-api/landlock.rst @@ -156,6 +156,27 @@ ruleset. Full working code can be found in `samples/landlock/sandboxer.c`_. +Good practices +-------------- + +It is recommended setting access rights to file hierarchy leaves as much as +possible. For instance, it is better to be able to have ``~/doc/`` as a +read-only hierarchy and ``~/tmp/`` as a read-write hierarchy, compared to +``~/`` as a read-only hierarchy and ``~/tmp/`` as a read-write hierarchy. +Following this good practice leads to self-sufficient hierarchies that don't +depend on their location (i.e. parent directories). This is particularly +relevant when we want to allow linking or renaming. Indeed, having consistent +access rights per directory enables to change the location of such directory +without relying on the destination directory access rights (except those that +are required for this operation, see `LANDLOCK_ACCESS_FS_REFER` documentation). +Having self-sufficient hierarchies also helps to tighten the required access +rights to the minimal set of data. This also helps avoid sinkhole directories, +i.e. directories where data can be linked to but not linked from. However, +this depends on data organization, which might not be controlled by developers. +In this case, granting read-write access to ``~/tmp/``, instead of write-only +access, would potentially allow to move ``~/tmp/`` to a non-readable directory +and still keep the ability to list the content of ``~/tmp/``. + Layers of file path access rights --------------------------------- -- 2.35.1