Skip to contentSkip to conversation

mm-kfence-disable-kmsan-when-checking-the-canary.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Jun 29, 2024

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm: kfence: disable KMSAN when checking the canary
has been removed from the -mm tree. Its filename was
mm-kfence-disable-kmsan-when-checking-the-canary.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Ilya Leoshkevich <[email protected]>
Subject: mm: kfence: disable KMSAN when checking the canary
Date: Fri, 21 Jun 2024 13:35:03 +0200

KMSAN warns about check_canary() accessing the canary.

The reason is that, even though set_canary() is properly instrumented and sets shadow, slub explicitly poisons the canary's address range afterwards.

Unpoisoning the canary is not the right thing to do: only check_canary() is supposed to ever touch it. Instead, disable KMSAN checks around canary read accesses.

Cc Alexander Gordeev <[email protected]>
Cc Christian Borntraeger <[email protected]>
Cc Christoph Lameter <[email protected]>
Cc David Rientjes <[email protected]>
Cc Dmitry Vyukov <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Hyeonggon Yoo <[email protected]>
Cc Joonsoo Kim <[email protected]>
Cc Marco Elver <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Masami Hiramatsu (Google) <[email protected]>
Cc Pekka Enberg <[email protected]>
Cc Roman Gushchin <[email protected]>
Cc Steven Rostedt (Google) <[email protected]>
Cc Sven Schnelle <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Vlastimil Babka <[email protected]>

---

 mm/kfence/core.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
mm/kfence/core.c renamed from mm/kfence/core.c~mm-kfence-disable-kmsan-when-checking-the-canary +9 -2
@@ -305,8 +305,14 @@ metadata_update_state(struct kfence_meta
 	WRITE_ONCE(meta->state, next);
 }
 
+#ifdef CONFIG_KMSAN
+#define check_canary_attributes noinline __no_kmsan_checks
+#else
+#define check_canary_attributes inline
+#endif
+
 /* Check canary byte at @addr. */
-static inline bool check_canary_byte(u8 *addr)
+static check_canary_attributes bool check_canary_byte(u8 *addr)
 {
 	struct kfence_metadata *meta;
 	unsigned long flags;
@@ -341,7 +347,8 @@ static inline void set_canary(const stru
 		*((u64 *)addr) = KFENCE_CANARY_PATTERN_U64;
 }
 
-static inline void check_canary(const struct kfence_metadata *meta)
+static check_canary_attributes void
+check_canary(const struct kfence_metadata *meta)
 {
 	const unsigned long pageaddr = ALIGN_DOWN(meta->addr, PAGE_SIZE);
 	unsigned long addr = pageaddr;

_

Patches currently in -mm which might be from [email protected] are