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=1796355233; b=LLmsX2UvFiGHlOhqcg63ooINAkhbhetFbB72P6Bll75u9c7NUE7EEnqDTodzR4cHYNuz c4QrVnnloUMdhUWt1nD2c7aiMiJ8HDYIwJpT8o7BDdWzl1D/CavkY9oVRpE3CiJ0+OopP P6NLDHjDUbx0HIittd7jbiZXR59P0yYwOTPYp2baB8wywbIsdVvBSzzn3aypPk/WY05pm v9TevheVJHPpUqhlzj0jtK2L69YVSKFQtiYgUwDnJRNwU20cQ08J2XJsIZC+SUmWNsE7B lwn840wBHdULYRxDXstJkVOp80aeTbB/JQ+O8Z3DRiB2xwYMmNcCg6Wz8N5BaVarAcw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796355233; 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=2n7HSO/W+hnq4YOt6QR2tSGdGmoScrhD+5HNAl9M3lY=; b=u3tung23HvHZCbzXdEE+4v0HSe7vtG3ZrFv3TZ/J58r9B5SW7NaZsF9t9dlGHB9jy73e rohiKAoW9FZFtzagMwi/xtiJzwGib3wCXWry4LEhWfGUqctSgw0brhdJIUWjnDdRNsPzT 3P6Hyz2FTjdg6ZiC7UCMO9f6oFX/GYlaAchK7ffLNE1LdNfiRvTkKECs4czHYjkP/P3ke U43mBbdhWS8+kEw/d8JYJ+Fhq7XE8pJOUNuesIe/M5MmvhVqBBNJvC4tYnxcV9hpY1iI1 RPZKppTq5ankjxfrlsvYTQ4rk8qa0ssZHNx3zrLXccO0WEmGrcNP600xtdPNbAJUpFQ== 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=ERHHsJMg; 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 62179606A322 for ; Fri, 4 Dec 2026 03:33: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=ERHHsJMg Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F3621F00897; Fri, 4 Dec 2026 03:33:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796355233; bh=2n7HSO/W+hnq4YOt6QR2tSGdGmoScrhD+5HNAl9M3lY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ERHHsJMg+y8W/4vHeEBN5cgPVb2DkRKYAUGAF9Y9TVJ4qwG5YYojEt11igmAZSPFk 75omQz2mbFNoDMRvySwxDup+4lhvoCKiauRZgeK3JGsPxQ+/RaeHw+sDv/L4K094RY OdI1x3GlISVhno5bhpoSW7+xBDdnhwwNeFlVxDJxCgymQNEZPD7ZcPGSYO179wlWkx 7kfsSSFPNtlvjPx4nhOsuxL/ggCkCcVQS7PiCiC/4McGVlteFxxgYDAUX/3MCwdsil L5fGjn9nDwzRpSixFNFkn7n3eAKxljYSRdmxDI94g2ERmM/I561S0rO+kIbXTlX9Ci 6ssXlZ3mK1qyw== 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 7.3.y 2/2] landlock: Fix layer composition of LANDLOCK_ACCESS_FS_REFER Date: Thu, 3 Dec 2026 22:33:50 -0500 Message-ID: <20261204033343.2425352-2-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261204033343.2425352-1-sashal@kernel.org> References: <2026120246-game-askew-4ecc@gregkh> <20261204033343.2425352-1-sashal@kernel.org> 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/domain.h | 13 ++++++++++--- security/landlock/errata/abi-4.h | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/security/landlock/domain.h b/security/landlock/domain.h index c46f962ef86d4..ed4daad2257c9 100644 --- a/security/landlock/domain.h +++ b/security/landlock/domain.h @@ -257,9 +257,16 @@ static inline access_mask_t landlock_get_fs_access_mask(const struct landlock_domain *const domain, const u16 layer_level) { - /* Handles all initially denied by default access rights. */ - return domain->layers[layer_level].handled.fs | - _LANDLOCK_ACCESS_FS_INITIALLY_DENIED; + access_mask_t handled = domain->layers[layer_level].handled.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 diff --git a/security/landlock/errata/abi-4.h b/security/landlock/errata/abi-4.h index fe11ec7d7ddf5..9784ca6450730 100644 --- a/security/landlock/errata/abi-4.h +++ b/security/landlock/errata/abi-4.h @@ -20,3 +20,24 @@ * that rely on these protocols while using Landlock network 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) -- 2.53.0