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=1796355593; b=NfuBVroc3dNOj9G2q8IDtUYV3JtMpKvXXpavg993s1XMYnow1UPwYmtJNhJWZPx1c3+x u67GgSUvAr7RI76XZAkUTSkePgLsHSeeATJ8yCdktdukBGCtrQpJFPdf0LnRuoBWMsMsC SM9lowGLV+nhfjs201Hnf9O/sCFOZBODYbFPFPmXsPqrOr51N7jcgJkz2AmzMI4+Hwyuj ctJjimYBYIUqUimq8JqR5gcwdDbbI4QRgt9YoCNentHG2FAuTZwMuaDfcSmKrzFlZvqA0 spGg5Zo/1c8oAgqvUhV408KzPj/FPdMsu0EeB+8mOzDTpwrtmIfgLC11N/Ytj2E8mOg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796355593; 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=aVJWOq1NTtehmt/m8Qvhy8XIxV4VpJwI3VHkapc2A7k=; b=xQR56tZpUXSL3twwyQx7i9wkbq7zt7G6SPU3Fkh8hFkQQJZridv7fNJ+WY8eBmM52DCN uRB1Vwb60L4tkmmhDwD7nsN6IsUgCE5t7Zh3rpdGZBWB5siNlCDisckHaoT00ePrtAK7J rwmjjV6b6W6fihKikkfayYZW8/q7gsY9FZaKDbmvCmiCZYvdX3buJWnWCWI7GlC2pjlO6 eq9jn0ArKE3Rl5zFqyRFYVlC8kAQYogSizD5dRtD0Er0lkwpKT/1n7kegCxcKnc/yDuvt dArbTKxfZqGIIQNULf3wmnTgLPEYGzX3iJZNE7UTIdHon1U0tics8L59LTnps7DVykQ== 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=bix+Kt+a; 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 7B0C5606A322 for ; Fri, 4 Dec 2026 03:39:53 +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=bix+Kt+a Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1E481F00897; Fri, 4 Dec 2026 03:39:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796355593; bh=aVJWOq1NTtehmt/m8Qvhy8XIxV4VpJwI3VHkapc2A7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bix+Kt+afjoElx9kXCxmcxwCPAjsQli79cpmm+5XhTqJ1JEPjAgBnMZJ7YYWkUFOp lpKKpNj5qZa9rILrvXgTCMhgdSMTTIMNVBr69TVXa36PfAtW2ZLdEVorKgIzZRt+o5 irHvu7lWASSh792waThl3Fej4E9HDyU3MSoSrESfuAkIOOREDyQg5Qw/+SVqTgJ8z2 IRyWRnxARssxxOWYd243v3LYaE9qEUQqfMo6tsweV8lKS6ONYVnYmZPxeFc6GoC800 3/HpvuYQke/707XuTQfmAGp9xEDi0lcf+vA6Ya4u+tjpq7oERo5M+3ubC9bXDY2jbp RudkWlRkmlooA== 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.18.y] landlock: Fix layer composition of LANDLOCK_ACCESS_FS_REFER Date: Thu, 3 Dec 2026 22:39:51 -0500 Message-ID: <20261204033945.2454373-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026120247-washcloth-paprika-566b@gregkh> References: <2026120247-washcloth-paprika-566b@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 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 e8bd30df56af1..235a31b2f685a 100644 --- a/security/landlock/ruleset.h +++ b/security/landlock/ruleset.h @@ -282,9 +282,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