From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796355891; b=VAP+62ZN/9674vsx8uSRhncqDIFnKKB2NcvJJ+LEMypFWM5avU2wgG+e72WPn73JUO6Q qO0bW+L67ZQtBaAGzmur4ADTaqs/5fKnq+bDHc/9+nLhnPOaZwyM91YDG4G7jFEnEJbxD gQsJxSkv0KAz8n82SRM0/ZQUWJv9MvFMrBNNmRmEwd7c9EzdirEs+GNhcj5MTRT0MyJJi guNZmA4A6qyHZNhwSZ4031FAriMsXkLwZ2ApQ+qkBWLT1alGQh4ZHrspTGLYLaD8pESYh VWp+lctA49IKMuV0zHnDKm0Xl0nwNmWHjE3FZbD8ZQu+7PRpBfLX5p0tRE4IsYyH4OQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796355891; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=pNAy9K42AY9LIkDW/oVZ4HyeSlWwswIp7jZT8QTXtKE=; b=Z+ahGTs4ZB/5EaEqDd3t1TGhK/ILSWQFvBCEsfaULFyxoTsT5Cp7i2LQLlqBOnKW0lC8 j9Kbq7yf6Wf5q8UvNIDBGGky+s1vhtwXyygKUzG74lzVnINnpZR31bCBMTgdFPSAjSgYz gljHEhKlJvMU0m4D0q29/fk+VsInqOtSXqZaxVgAxn5kWXlnyI+VGF6sjKNGmil9hVZUB vp601vw5oSfMKxdCdH+NAD0gFGMpUOJ/tVlzMFugP9/KmdZ/JFJGUy/pVM7KxXm9+ouzo fB1AJDDOOZwV5nMPedIsSjVVh2aBgj79e/LaIsRB+X1xQnJ9EuCwuG44mFmOuXPQ+AQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ClGshn55; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7B66606A322 for ; Fri, 4 Dec 2026 03:44:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ClGshn55 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D88B71F000CE; Fri, 4 Dec 2026 03:44:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796355890; bh=pNAy9K42AY9LIkDW/oVZ4HyeSlWwswIp7jZT8QTXtKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ClGshn55BDjReA0sEu4Ia+lY3KmjsHWPNqd5kFhZjOAW6OTi+MtOkDLFzuZ59+5hY IhDGpa0VaVjPg24TvfYvARtcuV7AepB9eTK1f6s1b4vkp9I+WkQgIMC15v4Q10DB9H yiHHUvcqDSlbeirt5xRB+yXQoHpVx6hwoSrCrIfffjRaTh4My8yqdP4hUgoJzts3Sh XOwtpRz4jE4dx6QQUoRUBFjrLjm4NdbFBK5PFALGBsRWT/Ok3KC/zdmK/EkhqRQ4ef a7NZg+9VBSi42G5hoHNV1XEFqYR4rPyGtiXsVCufbAJ3JgBA1k3NpW5QGC9xz/N6gj 3F++zscxa94ng== From: Sasha Levin To: stable@vger.kernel.org Cc: =?UTF-8?q?G=C3=BCnther=20Noack?= , Dwi Siswanto , =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Sasha Levin Subject: [PATCH 6.12.y] landlock: Fix layer composition of LANDLOCK_ACCESS_FS_REFER Date: Thu, 3 Dec 2026 22:44:48 -0500 Message-ID: <20261204034431.2482574-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026120247-unbitten-unfair-1357@gregkh> References: <2026120247-unbitten-unfair-1357@gregkh> X-Mailing-List: stable@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 From: Günther Noack [ Upstream commit 0ad8ea7fa7dc0f0d0e45f7ed4933d5433dac4291 ] In landlock_get_fs_access_mask(), only add the LANDLOCK_ACCESS_FS_REFER right if any filesystem access rights are handled at all. This prevents us from accidentally treating non-filesystem layers as if they handled LANDLOCK_ACCESS_FS_REFER. landlock_get_fs_access_mask() is used when initializing the layer masks for doing access right checks, so this bug meant that we unintentionally denied "refer" (e.g., link, rename) operations in layered cases, where the same operation would have been accepted if only either one of the two layers had been enforced. If the rulesets individually allow an operation, the composition of these rulesets should also allow it. The bug only manifests as soon as one other layer handles filesystem access rights. Otherwise, Landlock filesystem path walk is guarded by an early exit for the case that no filesystem-enforcing layer exists. Reported-by: Dwi Siswanto Closes: https://github.com/landlock-lsm/linux/issues/67 Closes: https://github.com/landlock-lsm/go-landlock/issues/66 Fixes: fff69fb03dde ("landlock: Support network rules with TCP bind and connect") Cc: stable@vger.kernel.org Signed-off-by: Günther Noack Link: https://patch.msgid.link/20261113-b4-landlock-refer-nonfs-layer-v3-1-02d7e42bcdfd@gmail.com Signed-off-by: Mickaël Salaün [ sashal: Adapted the fix to the older layout by patching landlock_get_fs_access_mask() in ruleset.h (struct landlock_ruleset, unprefixed INITIALLY_DENIED macro) and fitting the erratum hunk to different context in abi-4.h. ] Signed-off-by: Sasha Levin --- security/landlock/errata/abi-4.h | 21 +++++++++++++++++++++ security/landlock/ruleset.h | 13 ++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/security/landlock/errata/abi-4.h b/security/landlock/errata/abi-4.h index c052ee54f89f6..e678a4d79d535 100644 --- a/security/landlock/errata/abi-4.h +++ b/security/landlock/errata/abi-4.h @@ -13,3 +13,24 @@ * protocols to operate without unnecessary restrictions. */ LANDLOCK_ERRATUM(1) + +/** + * DOC: erratum_5 + * + * Erratum 5: Denial of ``LANDLOCK_ACCESS_FS_REFER`` in layered domains + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This fix addresses an issue where ``LANDLOCK_ACCESS_FS_REFER`` was implicitly + * handled in domain layers that handle no filesystem access rights. + * + * With this fix, a reparenting operation is allowed in a layered Landlock + * domain if and only if each layer, enforced on its own, would allow it. + * + * Impact: + * + * In kernels without this fix, if a domain combined a layer that handles + * filesystem access rights with a layer that doesn't, the resulting layered + * domain would deny all ``LANDLOCK_ACCESS_FS_REFER`` operations, even when the + * filesystem layer granted these operations with a rule. + */ +LANDLOCK_ERRATUM(5) diff --git a/security/landlock/ruleset.h b/security/landlock/ruleset.h index 631e24d4ffe96..aaa3651c761ce 100644 --- a/security/landlock/ruleset.h +++ b/security/landlock/ruleset.h @@ -364,9 +364,16 @@ static inline access_mask_t landlock_get_fs_access_mask(const struct landlock_ruleset *const ruleset, const u16 layer_level) { - /* Handles all initially denied by default access rights. */ - return ruleset->access_masks[layer_level].fs | - LANDLOCK_ACCESS_FS_INITIALLY_DENIED; + access_mask_t handled = ruleset->access_masks[layer_level].fs; + + /* + * Handles all initially denied by default access rights, but only for + * layers handling filesystem accesses. + */ + if (handled) + handled |= LANDLOCK_ACCESS_FS_INITIALLY_DENIED; + + return handled; } static inline access_mask_t -- 2.53.0