From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=45.157.188.11 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796153915; b=BuAqsvdZKTDI1wNT08wcVCYmqua9TWJ1ESHJjilFSYoTw3rkANMmyDCCTbdXuLY2ufPY sLtoCi4OhJ2aAKmg4ObcuAqO8OI+YcJv5eGx957loVgno0bi2ho0gtpV4TPYhuJSiPcDy vf7qfbNk7r798aJNroV1AbFXLc+eY4J8cYYWcrcfLbRrN15CueDd+Qk7yXWjs6hzfxeOv BFrDE5Sfs2j2EmayOF6UBZd2QOvqP+8DrMIpOVc2MZoOJGQktY9erTbTawPGpIcSFLU+1 cHfVY/3FoDlYXxUlmHTumX8bdXH6A4nQj2umZMtPvPpJheGd1AiEm5tMVBhglFwPBwg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796153915; h=DMARC-Filter:Received:DKIM-Signature:Received:From:To:Cc:Subject: Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding: X-Infomaniak-Routing; bh=duP4uSdTNDfnW5sUwWrpI387+IIgmna69fdUoCATdNM=; b=Le6fb2D7aSzRchWpPJ2+HilzOzHpgf0/WPTq1ks1oFthEIXlpn6uxYPNLTw1VOK8PGNN sOYCSu70XtU/FjNNWg6KYJsT1GNbF1bRh+EksjKzuhAbnuOZjY6wS+hxzuqTJupdr+1Y4 mo/M434UqpaslRIRw6YtHgcTGUguL8LHMnjswG0mQ8qIMY77+5WSTnCHnN8RiK1Odr2Ju lEXiPVQZxmaG14piusJArcxGEyjLfXVpWdddL2NhbLw957prx0TML9p7slnhBs0TQR3J2 /Cfy3xx/SEIyoOLOuhfFHuKETa68BJmXyZnjJQtiVR60lo+1GiZxABAQn6J48fBzAPg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass header.d=digikod.net header.i=@digikod.net header.a=rsa-sha256 header.s=20191114 header.b=XEAdbaVd; arc=none smtp.remote-ip=45.157.188.11 Received: from smtp-bc0b.mail.infomaniak.ch (smtp-bc0b.mail.infomaniak.ch [45.157.188.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53660606A69B for ; Tue, 1 Dec 2026 19:38:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 53660606A69B Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.a=rsa-sha256 header.s=20191114 header.b=XEAdbaVd Received: from smtp-3-0001.mail.infomaniak.ch (smtp-3-0001.mail.infomaniak.ch [10.4.36.108]) by smtp-4-3000 (Postfix) with ESMTPS id 4jfB5D1151zVwJ; Tue, 1 Dec 2026 20:38:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digikod.net; s=20191114; t=1796153903; bh=duP4uSdTNDfnW5sUwWrpI387+IIgmna69fdUoCATdNM=; h=From:To:Cc:Subject:Date:From; b=XEAdbaVdrcGEsVOnVeDmMFthPset+MYMf8ftwt6QLwvdyA+GCZGE3u2NjzsI0l9er OTYcINAfw6LD42WBXkV+PJOHA1rennDa7mUEs1KWJzDewl/n8R6foMF9iSHmZneQte hE7ygJdyORNbKWzcj1aV563EdTO22Vdp4N0fkqKo= Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4jfB5B6fPQzpRX; Tue, 1 Dec 2026 20:38:22 +0100 (CET) From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: =?UTF-8?q?G=C3=BCnther=20Noack?= , Jonathan Corbet Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Christian Brauner , Randy Dunlap , Shawn Shao , Shuah Khan , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH] landlock: Clarify namespace and capability permission boundaries Date: Tue, 1 Dec 2026 20:38:13 +0100 Message-ID: <20261201193814.760891-1-mic@digikod.net> X-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Infomaniak-Routing: alpha A report [1] interpreted opening a reference to an existing namespace as an operation covered by LANDLOCK_PERMISSION_NAMESPACE_USE. The current wording invites that reading, but a namespace reference identifies a target without authorizing reassociation or capability exercise. Distinguish namespace creation and reassociation from opening existing namespaces. Describe capability exercise as an independent check so readers can tell how the two permissions limit reachable kernel code. Cc: Günther Noack Cc: Shawn Shao Link: https://patch.msgid.link/179566442733.1993761.8053687674090289362@163.com [1] Signed-off-by: Mickaël Salaün --- Documentation/userspace-api/landlock.rst | 54 +++++++++++------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/Documentation/userspace-api/landlock.rst b/Documentation/userspace-api/landlock.rst index 7cc5fde48262..174826793040 100644 --- a/Documentation/userspace-api/landlock.rst +++ b/Documentation/userspace-api/landlock.rst @@ -8,7 +8,7 @@ Landlock: unprivileged access control ===================================== :Author: Mickaël Salaün -:Date: November 2026 +:Date: December 2026 The goal of Landlock is to enable restriction of ambient rights (e.g. global filesystem or network access) for a set of processes. Because Landlock @@ -525,25 +525,23 @@ rights (``handled_access_*``) or cross-domain scopes (``scoped``), per-category permissions constrain the sandboxed process's own use of these enums; members not allowed by a rule are denied by default. -``LANDLOCK_PERMISSION_NAMESPACE_USE`` gates *acquisition of access* to -namespaces: creation via :manpage:`unshare(2)` / :manpage:`clone(2)` -/ :manpage:`clone3(2)`, entry via :manpage:`setns(2)`, and fd-reference -acquisition via :manpage:`open_tree(2)` / :manpage:`fsmount(2)`. Namespaces -the process is already a member of when the domain is enforced are implicitly -allowed (the process could not continue running otherwise); rules describe -which new namespace types the process may acquire. +``LANDLOCK_PERMISSION_NAMESPACE_USE`` restricts which namespace types a +process may create or reassociate with. It covers creation even when the +caller does not join the new namespace, but does not restrict opening an +existing namespace. Enforcing this permission does not revoke existing +namespace membership. + ``LANDLOCK_PERMISSION_CAPABILITY_USE`` gates the exercise of capabilities after the domain is enforced, regardless of how the capability was obtained (inherited credentials, ``CLONE_NEWUSER`` -grant, ``setuid``/file-cap-bearing :manpage:`execve(2)`, etc.). Configuring -both together restricts what privileges are available *and* the namespaces in -which they take effect, which matters because user namespace creation has no -capability check and grants all capabilities within the new namespace: gating -only one of the two leaves a kernel attack-surface widening path open. When a -domain handles both permissions, an operation is allowed only if each -independently allows it: :manpage:`unshare(2)` with ``CLONE_NEWNET`` then -requires both a rule allowing ``CLONE_NEWNET`` and a rule allowing -``CAP_SYS_ADMIN``. +grant, ``setuid``/file-cap-bearing :manpage:`execve(2)`, etc.). + +Together, the namespace and capability permissions limit reachable kernel code +by restricting namespace creation and reassociation separately from capability +exercise. An operation must be allowed by every handled permission that +applies to it. For example, when both of these permissions are handled, +:manpage:`unshare(2)` with ``CLONE_NEWNET`` requires rules allowing both +``CLONE_NEWNET`` and ``CAP_SYS_ADMIN``. ``LANDLOCK_PERMISSION_CAPABILITY_USE`` complements :manpage:`prctl(2)` ``PR_SET_NO_NEW_PRIVS`` but does not replace it. ``PR_SET_NO_NEW_PRIVS`` @@ -579,25 +577,21 @@ effect, so a rule compiled against future kernel headers loads without error on older kernels. Future kernels gain new members denied by default until a rule explicitly allows them. -The single ``LANDLOCK_PERMISSION_NAMESPACE_USE`` bit gates every kernel path -that grants the calling process access to a namespace of the controlled types, -whether by becoming a member of the namespace or by holding a file descriptor -that references it. The covered syscall paths are: - -* :manpage:`unshare(2)` with ``CLONE_NEW*``: the caller becomes a member of a - newly-created namespace. -* :manpage:`clone(2)` (or :manpage:`clone3(2)`) with ``CLONE_NEW*``: the - child becomes a member of a newly-created namespace. -* :manpage:`setns(2)`: the caller becomes a member of an existing namespace - referenced by file descriptor. +Examples of covered namespace creation and reassociation operations include: + +* :manpage:`unshare(2)` with ``CLONE_NEW*``: creates namespaces for the caller. +* :manpage:`clone(2)` (or :manpage:`clone3(2)`) with ``CLONE_NEW*``: creates + namespaces for the child. +* :manpage:`setns(2)`: requests reassociation with one or more existing + namespaces. * :manpage:`open_tree(2)` with ``OPEN_TREE_NAMESPACE``: the caller obtains a file descriptor referring to a newly-created mount namespace. * :manpage:`open_tree(2)` with ``OPEN_TREE_CLONE``: the caller obtains a file - descriptor referring to a newly-created anonymous mount namespace. + descriptor for a detached mount in a new anonymous mount namespace. * :manpage:`fsmount(2)` with ``FSMOUNT_NAMESPACE``: the caller obtains a file descriptor referring to a newly-created mount namespace. * :manpage:`fsmount(2)` (default): the caller obtains a file descriptor - referring to a newly-created anonymous mount namespace. + for a detached mount in a new anonymous mount namespace. Anonymous mount namespaces (created by ``open_tree(OPEN_TREE_CLONE)`` and the default :manpage:`fsmount(2)`) are intentionally covered by the bit even though base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244 -- 2.56.1