Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4254957iob; Sun, 8 May 2022 07:28:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSgtrXs3VAMI1X7FD0EgGWRPb/fDwbQ0YksqPQna1n9iFhPfyyfnqqU6YBEzSuBERyAs5H X-Received: by 2002:a17:906:57c1:b0:6d6:da73:e9c0 with SMTP id u1-20020a17090657c100b006d6da73e9c0mr11030774ejr.45.1652020087464; Sun, 08 May 2022 07:28:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652020087; cv=none; d=google.com; s=arc-20160816; b=xzJct2Cw0fvYlN3cs90Qf+IbdNI1qZuUZPvgIB9ow/MhSrRT7ikmqqTftGklu0CKRd hrzdXEKKxInMYdY2ZPhPSWqm6WcTrId+E5GBeHGakJGJEu51xb12pDpT9eP1YFxKo/JW 3xIU0XiOYhzezpgPaigcfaK0dpElaQyYXXw0ZyDmnYzsHJRZP79jH+AVVyCh+RdRH0QL SB580632gP1p6ur/UgTlKQ3miR5VawcD6wFCM011jhqBDkHwjewFIjxZx3EUYtaI34xV NqkdKXsHLeu7skdRJG8UbicPobo/ubsBPFfEuyMgmXIG6Ho5AWMc7/IQWjzmC7lDd7V6 Jtrw== 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=xCFXOjASyoK81jrw12MhlcxokhLig2ywuqOfna5dkLI=; b=LG6+DiNNGeaFUYZi2yhhEi9nmwzCMmxkoEhFEn32W2cgCasETbiGMoiA6okgs8jLzh oAM+Uysm1wMpYGuwey64l1Jb6Y87+j0m6q6U6Y8dzv84Ro99pIIK8nrUoykofxKZUz0b 4wpDl268mSvWePXbTEv2GXd2Z7/fXKqGC70VCBVVyRIMIFvrvs6pJ3RKJjbmHBNIwv1i 5J74g26H54m/5wlHsa4738ciz7dm6ar+ZeGSHIoOkYqCqhbcDczMRPa+uOlTBTaKODg6 /puS5m+uhi+1U0TzkBxW3RPBZZJscrcG2SlaClbiom26TbYPPkwudWVgThy8gENO84fR 502A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=tw5s6q2d; 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 h10-20020aa7cdca000000b00425e6997464si9332128edw.203.2022.05.08.07.27.22; Sun, 08 May 2022 07:28:07 -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=tw5s6q2d; 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 S1443586AbiEFQPC (ORCPT + 99 others); Fri, 6 May 2022 12:15:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443530AbiEFQNd (ORCPT ); Fri, 6 May 2022 12:13:33 -0400 Received: from smtp-42ac.mail.infomaniak.ch (smtp-42ac.mail.infomaniak.ch [84.16.66.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC17E6EB16; Fri, 6 May 2022 09:09:47 -0700 (PDT) Received: from smtp-3-0001.mail.infomaniak.ch (unknown [10.4.36.108]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4KvwWG3qdPzMqT9Z; Fri, 6 May 2022 18:09:46 +0200 (CEST) Received: from localhost (unknown [23.97.221.149]) by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4KvwWG1m5zzlhMBy; Fri, 6 May 2022 18:09:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1651853386; bh=rxl0iHTTGfZtLXdEAP4heAgGzDEhlZqrwHQX62+NSSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tw5s6q2dk4hi+eWeco/Nle53UauXNuxoh3VdZ5vyW2JZ7fyuBWxhhbAIKMiaT5ED2 T3Z9XYM0NJymUbP62U0shtInm/VZ8Cjr+k9b67PoHWi4H8C1pZFc+EiUxKR16aN6ir 6zCVRcWuxv24vPiiiStmhc+AdZT67eNP8BSQYrZU= 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 Subject: [PATCH v3 11/12] landlock: Document good practices about filesystem policies Date: Fri, 6 May 2022 18:11:01 +0200 Message-Id: <20220506161102.525323-12-mic@digikod.net> In-Reply-To: <20220506161102.525323-1-mic@digikod.net> References: <20220506161102.525323-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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Explain how to set access rights per hierarchy in an efficient and safe way, especially with the LANDLOCK_ACCESS_FS_REFER side effect (i.e. partial ordering and constraints for access rights per hierarchy). Reviewed-by: Paul Moore Signed-off-by: Mickaël Salaün Link: https://lore.kernel.org/r/20220506161102.525323-12-mic@digikod.net --- Changes since v1: * Add more explanation in the commit message. 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 ae2aea986aa6..7b4fe6218132 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