Skip to contentSkip to conversation

mm-kmsan-implement-kmsan_memmove.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Apr 26, 2024

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm: kmsan: implement kmsan_memmove()
has been removed from the -mm tree. Its filename was
mm-kmsan-implement-kmsan_memmove.patch

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

------------------------------------------------------
From: Alexander Potapenko <[email protected]>
Subject: mm: kmsan: implement kmsan_memmove()
Date: Wed, 20 Mar 2024 11:18:49 +0100

Provide a hook that can be used by custom memcpy implementations to tell KMSAN that the metadata needs to be copied. Without that, false positive reports are possible in the cases where KMSAN fails to intercept memory initialization.

---

 include/linux/kmsan-checks.h |   15 +++++++++++++++
 mm/kmsan/hooks.c             |   11 +++++++++++
 2 files changed, 26 insertions(+)
include/linux/kmsan-checks.h renamed from include/linux/kmsan-checks.h~mm-kmsan-implement-kmsan_memmove +15 -0
@@ -61,6 +61,17 @@ void kmsan_check_memory(const void *addr
 void kmsan_copy_to_user(void __user *to, const void *from, size_t to_copy,
 			size_t left);
 
+/**
+ * kmsan_memmove() - Notify KMSAN about a data copy within kernel.
+ * @to:   destination address in the kernel.
+ * @from: source address in the kernel.
+ * @size: number of bytes to copy.
+ *
+ * Invoked after non-instrumented version (e.g. implemented using assembly
+ * code) of memmove()/memcpy() is called, in order to copy KMSAN's metadata.
+ */
+void kmsan_memmove(void *to, const void *from, size_t to_copy);
+
 #else
 
 static inline void kmsan_poison_memory(const void *address, size_t size,
@@ -78,6 +89,10 @@ static inline void kmsan_copy_to_user(vo
 {
 }
 
+static inline void kmsan_memmove(void *to, const void *from, size_t to_copy)
+{
+}
+
 #endif
 
 #endif /* _LINUX_KMSAN_CHECKS_H */
mm/kmsan/hooks.c renamed from mm/kmsan/hooks.c~mm-kmsan-implement-kmsan_memmove +11 -0
@@ -285,6 +285,17 @@ void kmsan_copy_to_user(void __user *to,
 }
 EXPORT_SYMBOL(kmsan_copy_to_user);
 
+void kmsan_memmove(void *to, const void *from, size_t size)
+{
+	if (!kmsan_enabled || kmsan_in_runtime())
+		return;
+
+	kmsan_enter_runtime();
+	kmsan_internal_memmove_metadata(to, (void *)from, size);
+	kmsan_leave_runtime();
+}
+EXPORT_SYMBOL(kmsan_memmove);
+
 /* Helper function to check an URB. */
 void kmsan_handle_urb(const struct urb *urb, bool is_out)
 {

_

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

kmsan-compiler_types-declare-__no_sanitize_or_inline.patch