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 39BFC86334; Thu, 15 Jan 2026 17:16:13 +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=1768497373; cv=none; b=gWtnYejtCtQ+2R+EGXWf7df7KXr7klqnCBCljiHAVxESLpRUIAcZpIy1qynaiRsqhppaxtDZwb71hDl9iAuEITsKQJCcA0R3jcvLFADD1V4ODBJF6LkhOAZKszilaAKb9uAQFPDrHXtGFL8wknIqPleLIjDPNAqr+9cymjZJ4AI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768497373; c=relaxed/simple; bh=/Xfu+GLfL/gNB3NygmKWW1xZCpnYx7ANVJgGf5YJpZw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T0KaK9Tv/IUfE83U72fbGApYiv1Gr3Y8q02GQo3bqcHRxt6H8XypryiMkkkSip46grdAJ4aGVORf08ZlabmrV4LlVcP8KNd1kOYwnGbFG2RFBX+aBgFN5mPbTlsbRjnxREhHfIoje4CeI/4OpL2uez8v7RHVWX1xBaqufgITivY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NfYFN6zG; 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="NfYFN6zG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 917B0C116D0; Thu, 15 Jan 2026 17:16:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1768497373; bh=/Xfu+GLfL/gNB3NygmKWW1xZCpnYx7ANVJgGf5YJpZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NfYFN6zGRsrcHuFoCT3gRs6DOb+yJrac+VHA4RC3CYh8k/VOAW7Qd+XRHsAe0q8sQ KWqIT91Vvvii75tpM02TWRZ1P4wrRVV8zHssmy9Xa+CKLKVxO5IyXTwr49UMqkiwep wnJkPq4yTaE3HJ3ChxaSMRctOYlPphwcc1ThEH5E= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Arnd Bergmann , Nick Desaulniers , Andrew Morton , Will Deacon , Arvind Sankar , Masahiro Yamada , llvm@lists.linux.dev, Kees Cook , Nathan Chancellor , Miguel Ojeda , Marco Elver , Sasha Levin Subject: [PATCH 5.15 057/554] compiler-gcc.h: Define __SANITIZE_ADDRESS__ under hwaddress sanitizer Date: Thu, 15 Jan 2026 17:42:03 +0100 Message-ID: <20260115164248.309136820@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115164246.225995385@linuxfoundation.org> References: <20260115164246.225995385@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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kees Cook [ Upstream commit 9a48e7564ac83fb0f1d5b0eac5fe8a7af62da398 ] When Clang is using the hwaddress sanitizer, it sets __SANITIZE_ADDRESS__ explicitly: #if __has_feature(address_sanitizer) || __has_feature(hwaddress_sanitizer) /* Emulate GCC's __SANITIZE_ADDRESS__ flag */ #define __SANITIZE_ADDRESS__ #endif Once hwaddress sanitizer was added to GCC, however, a separate define was created, __SANITIZE_HWADDRESS__. The kernel is expecting to find __SANITIZE_ADDRESS__ in either case, though, and the existing string macros break on supported architectures: #if (defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)) && \ !defined(__SANITIZE_ADDRESS__) where as other architectures (like arm32) have no idea about hwaddress sanitizer and just check for __SANITIZE_ADDRESS__: #if defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__) This would lead to compiler foritfy self-test warnings when building with CONFIG_KASAN_SW_TAGS=y: warning: unsafe memmove() usage lacked '__read_overflow2' symbol in lib/test_fortify/read_overflow2-memmove.c warning: unsafe memcpy() usage lacked '__write_overflow' symbol in lib/test_fortify/write_overflow-memcpy.c ... Sort this out by also defining __SANITIZE_ADDRESS__ in GCC under the hwaddress sanitizer. Suggested-by: Arnd Bergmann Cc: Nick Desaulniers Cc: Andrew Morton Cc: Will Deacon Cc: Arvind Sankar Cc: Masahiro Yamada Cc: llvm@lists.linux.dev Signed-off-by: Kees Cook Reviewed-by: Nathan Chancellor Acked-by: Miguel Ojeda Reviewed-by: Marco Elver Link: https://lore.kernel.org/r/20211020200039.170424-1-keescook@chromium.org Stable-dep-of: ced37e9ceae5 ("x86/dumpstack: Prevent KASAN false positive warnings in __show_regs()") Signed-off-by: Sasha Levin --- include/linux/compiler-gcc.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index b9d5f9c373a09..06c1cf2ab0244 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -123,6 +123,14 @@ #define __no_sanitize_coverage #endif +/* + * Treat __SANITIZE_HWADDRESS__ the same as __SANITIZE_ADDRESS__ in the kernel, + * matching the defines used by Clang. + */ +#ifdef __SANITIZE_HWADDRESS__ +#define __SANITIZE_ADDRESS__ +#endif + /* * Turn individual warnings and errors on and off locally, depending * on version. -- 2.51.0