lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <09962dd580a56e308d98b7bd5829dc57928bcc40.1739866028.git.maciej.wieczor-retman@intel.com>
Date: Tue, 18 Feb 2025 09:15:20 +0100
From: Maciej Wieczor-Retman <maciej.wieczor-retman@...el.com>
To: kees@...nel.org,
	julian.stecklina@...erus-technology.de,
	kevinloughlin@...gle.com,
	peterz@...radead.org,
	tglx@...utronix.de,
	justinstitt@...gle.com,
	catalin.marinas@....com,
	wangkefeng.wang@...wei.com,
	bhe@...hat.com,
	ryabinin.a.a@...il.com,
	kirill.shutemov@...ux.intel.com,
	will@...nel.org,
	ardb@...nel.org,
	jason.andryuk@....com,
	dave.hansen@...ux.intel.com,
	pasha.tatashin@...een.com,
	ndesaulniers@...gle.com,
	guoweikang.kernel@...il.com,
	dwmw@...zon.co.uk,
	mark.rutland@....com,
	broonie@...nel.org,
	apopple@...dia.com,
	bp@...en8.de,
	rppt@...nel.org,
	kaleshsingh@...gle.com,
	richard.weiyang@...il.com,
	luto@...nel.org,
	glider@...gle.com,
	pankaj.gupta@....com,
	andreyknvl@...il.com,
	pawan.kumar.gupta@...ux.intel.com,
	kuan-ying.lee@...onical.com,
	tony.luck@...el.com,
	tj@...nel.org,
	jgross@...e.com,
	dvyukov@...gle.com,
	baohua@...nel.org,
	samuel.holland@...ive.com,
	dennis@...nel.org,
	akpm@...ux-foundation.org,
	thomas.weissschuh@...utronix.de,
	surenb@...gle.com,
	kbingham@...nel.org,
	ankita@...dia.com,
	nathan@...nel.org,
	maciej.wieczor-retman@...el.com,
	ziy@...dia.com,
	xin@...or.com,
	rafael.j.wysocki@...el.com,
	andriy.shevchenko@...ux.intel.com,
	cl@...ux.com,
	jhubbard@...dia.com,
	hpa@...or.com,
	scott@...amperecomputing.com,
	david@...hat.com,
	jan.kiszka@...mens.com,
	vincenzo.frascino@....com,
	corbet@....net,
	maz@...nel.org,
	mingo@...hat.com,
	arnd@...db.de,
	ytcoode@...il.com,
	xur@...gle.com,
	morbo@...gle.com,
	thiago.bauermann@...aro.org
Cc: linux-doc@...r.kernel.org,
	kasan-dev@...glegroups.com,
	linux-kernel@...r.kernel.org,
	llvm@...ts.linux.dev,
	linux-mm@...ck.org,
	linux-arm-kernel@...ts.infradead.org,
	x86@...nel.org
Subject: [PATCH v2 04/14] kasan: sw_tags: Support tag widths less than 8 bits

From: Samuel Holland <samuel.holland@...ive.com>

Allow architectures to override KASAN_TAG_KERNEL in asm/kasan.h. This
is needed on RISC-V, which supports 57-bit virtual addresses and 7-bit
pointer tags. For consistency, move the arm64 MTE definition of
KASAN_TAG_MIN to asm/kasan.h, since it is also architecture-dependent;
RISC-V's equivalent extension is expected to support 7-bit hardware
memory tags.

Reviewed-by: Andrey Konovalov <andreyknvl@...il.com>
Signed-off-by: Samuel Holland <samuel.holland@...ive.com>
Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@...el.com>
---
 arch/arm64/include/asm/kasan.h   |  6 ++++--
 arch/arm64/include/asm/uaccess.h |  1 +
 include/linux/kasan-tags.h       | 13 ++++++++-----
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/arch/arm64/include/asm/kasan.h b/arch/arm64/include/asm/kasan.h
index e1b57c13f8a4..4ab419df8b93 100644
--- a/arch/arm64/include/asm/kasan.h
+++ b/arch/arm64/include/asm/kasan.h
@@ -6,8 +6,10 @@
 
 #include <linux/linkage.h>
 #include <asm/memory.h>
-#include <asm/mte-kasan.h>
-#include <asm/pgtable-types.h>
+
+#ifdef CONFIG_KASAN_HW_TAGS
+#define KASAN_TAG_MIN			0xF0 /* minimum value for random tags */
+#endif
 
 #define arch_kasan_set_tag(addr, tag)	__tag_set(addr, tag)
 #define arch_kasan_reset_tag(addr)	__tag_reset(addr)
diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
index 5b91803201ef..f890dadc7b4e 100644
--- a/arch/arm64/include/asm/uaccess.h
+++ b/arch/arm64/include/asm/uaccess.h
@@ -22,6 +22,7 @@
 #include <asm/cpufeature.h>
 #include <asm/mmu.h>
 #include <asm/mte.h>
+#include <asm/mte-kasan.h>
 #include <asm/ptrace.h>
 #include <asm/memory.h>
 #include <asm/extable.h>
diff --git a/include/linux/kasan-tags.h b/include/linux/kasan-tags.h
index 4f85f562512c..e07c896f95d3 100644
--- a/include/linux/kasan-tags.h
+++ b/include/linux/kasan-tags.h
@@ -2,13 +2,16 @@
 #ifndef _LINUX_KASAN_TAGS_H
 #define _LINUX_KASAN_TAGS_H
 
+#include <asm/kasan.h>
+
+#ifndef KASAN_TAG_KERNEL
 #define KASAN_TAG_KERNEL	0xFF /* native kernel pointers tag */
-#define KASAN_TAG_INVALID	0xFE /* inaccessible memory tag */
-#define KASAN_TAG_MAX		0xFD /* maximum value for random tags */
+#endif
+
+#define KASAN_TAG_INVALID	(KASAN_TAG_KERNEL - 1) /* inaccessible memory tag */
+#define KASAN_TAG_MAX		(KASAN_TAG_KERNEL - 2) /* maximum value for random tags */
 
-#ifdef CONFIG_KASAN_HW_TAGS
-#define KASAN_TAG_MIN		0xF0 /* minimum value for random tags */
-#else
+#ifndef KASAN_TAG_MIN
 #define KASAN_TAG_MIN		0x00 /* minimum value for random tags */
 #endif
 
-- 
2.47.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ