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=1796383037; b=SPq4iA9WyF8M+Z+B6v5BPEGynTNe/pvSm26y+Nk3o7cTeMJrmhBxyFcnWHZ0P1XEquOJ 1UD9q1zb1/ju0nM/MtvFMJVwgZp3GfZulwfLPLuwGKNuhI4PH6vKPxe0E7qHFE2FXhHU1 C7iy5zwt1z8G9KRwMaKLL08itndZHSbfu/7DXcwfMPDZxuiRZKQa1OX9c1sXkveaaXnx9 LdGavV7k1GMPRTsb7z2+HWYSl4dhyrZn/IzRdxxzDUpCBD4N6zHAp5Tc5bmfZ7g6tvrt1 g0p385e9dye7HfTodtQEh01L3ChKE0LSGmMuPTDdA6lF4yyAqH/6GO/J4IYPcgqQhqA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383037; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=940kL0u10rzLxkqNwvvLBpP5u84NCFPBdZvC9J2eN/o=; b=SRfyRqq2bWZ/dBIUe6yHOaSzf+KgH0Kjw4TThnTBZ/1dS0tKhcvDv2VQ7yv+lDh1M9nC +wv9V86vPeRmK2RyKEjX6QNo30GH0byG7KxNHH8oAtmRqpvFkQDjgXw8FX78FqOttzoNj UJyvtcyMfCgZLc5o4IqaWPIIQws/22QtSBqKfPOdM+Q2U/1nJTO8gU4x+i9tYzBD+7IWA p5Y5sW1g+tB0FYl4Mf7/HrQPM+4MA2mBIhoqKmdZwXO+moLktlp5N0jPU5e3w5I2B7VsD UdcfaB9TbKf5XRxkd/efTOmQLhuzRvZz/70MdOwJOsdvtukPjdWUSgDXQZBY6l/xIgw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=sdVzTwsm; 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 200C2606A32F; Fri, 4 Dec 2026 11:17:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=sdVzTwsm Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CDEF1F00A0C; Fri, 4 Dec 2026 11:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383036; bh=940kL0u10rzLxkqNwvvLBpP5u84NCFPBdZvC9J2eN/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=sdVzTwsmM3HipeJVXhcHYqtWj1H0SURF7TgYaK7Tl/y3tlSOcKbh1vhVv3s9DsjD9 /eS5DAzQ1QJIvBfvVIZh9ntE8QyIWTVH7V2HyBHoY90DiVriyWttHw+XFuhszHdSJV 63poXs1X2uIVT11Cmk2V1XT4CKU1VeYj7s4QrfPs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dwi Siswanto , =?UTF-8?q?G=C3=BCnther=20Noack?= , =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Sasha Levin Subject: [PATCH 6.18 672/703] landlock: Fix layer composition of LANDLOCK_ACCESS_FS_REFER Date: Fri, 4 Dec 2026 19:09:31 +0900 Message-ID: <20261204100645.680027864@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore 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 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- security/landlock/errata/abi-4.h | 21 +++++++++++++++++++++ security/landlock/ruleset.h | 13 ++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) --- 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) --- 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