From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B8A3146A66; Tue, 17 Mar 2026 17:16:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773767795; cv=none; b=Iyq4YfNf5ES+vM7C9W/WgRaIcsuTY61G3irdG+b0b2sXWN7wyBd6tayblaBFFDPC5xfFm9WXmFanKjTGJPIPhi9qliHbhYvRRQ+cw4HD1dyz4z59CjlhGetJ2m7GRFnM7h4Qqsrn1yd0Wv3uieWOhks41HGVOdrFJvohuxTw848= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773767795; c=relaxed/simple; bh=6LEST4Vvy79hdyVkiEhuVA6muvl9jLv6yxY4fV12FKw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cXp5CS6jhRjEK0q2CSxB3cJaHRx4JwfefwnKmWQQQOkMSGzamkDfs4k38h9xj2r+zso6/4nfwEiFFQzHIrtNFkO/rkNEpQU1b6nCEKr1xw0qIAHMZH/y/IbFX0tLdvh0X28qnnCdu4RjIFbRS0Dip6JsGMV/uRn+xQe/cM489YY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qelD90gm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="qelD90gm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3D5EC4CEF7; Tue, 17 Mar 2026 17:16:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1773767795; bh=6LEST4Vvy79hdyVkiEhuVA6muvl9jLv6yxY4fV12FKw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qelD90gm1BSNMcQH7abS7LyNh/tgf9tNGwhxELlN+5iwRBGPDbmEM/Arw9i5e6Wpz iSOrOcwsmA+9hNJtmi1JHMmGewHDZlzwB0+tAE6vRuaZGyL3NuvJr+14VsarjestJX qCrqGxfeHRQqwsbpMnjxgZUpN+CaB6r7XDo+OvTI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alexander Potapenko , Marco Elver , Andrey Konovalov , Andrey Ryabinin , Dmitry Vyukov , Ernesto Martinez Garcia , Kees Cook , Andrew Morton Subject: [PATCH 6.18 159/333] mm/kfence: disable KFENCE upon KASAN HW tags enablement Date: Tue, 17 Mar 2026 17:33:08 +0100 Message-ID: <20260317163005.257027761@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260317162959.345812316@linuxfoundation.org> References: <20260317162959.345812316@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexander Potapenko commit 09833d99db36d74456a4d13eb29c32d56ff8f2b6 upstream. KFENCE does not currently support KASAN hardware tags. As a result, the two features are incompatible when enabled simultaneously. Given that MTE provides deterministic protection and KFENCE is a sampling-based debugging tool, prioritize the stronger hardware protections. Disable KFENCE initialization and free the pre-allocated pool if KASAN hardware tags are detected to ensure the system maintains the security guarantees provided by MTE. Link: https://lkml.kernel.org/r/20260213095410.1862978-1-glider@google.com Fixes: 0ce20dd84089 ("mm: add Kernel Electric-Fence infrastructure") Signed-off-by: Alexander Potapenko Suggested-by: Marco Elver Reviewed-by: Marco Elver Cc: Andrey Konovalov Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Ernesto Martinez Garcia Cc: Greg KH Cc: Kees Cook Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- mm/kfence/core.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) --- a/mm/kfence/core.c +++ b/mm/kfence/core.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -883,6 +884,20 @@ void __init kfence_alloc_pool_and_metada return; /* + * If KASAN hardware tags are enabled, disable KFENCE, because it + * does not support MTE yet. + */ + if (kasan_hw_tags_enabled()) { + pr_info("disabled as KASAN HW tags are enabled\n"); + if (__kfence_pool) { + memblock_free(__kfence_pool, KFENCE_POOL_SIZE); + __kfence_pool = NULL; + } + kfence_sample_interval = 0; + return; + } + + /* * If the pool has already been initialized by arch, there is no need to * re-allocate the memory pool. */