]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
revert kasan-remove-kfence-leftovers
authorAndrew Morton <akpm@linux-foundation.org>
Thu, 31 Dec 2020 22:04:37 +0000 (22:04 +0000)
committerJohannes Weiner <hannes@cmpxchg.org>
Thu, 31 Dec 2020 22:04:37 +0000 (22:04 +0000)
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Alexander Potapenko <glider@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/kasan/kasan.h
mm/kasan/shadow.c

index cc4d9e1d49b1d046d579863ec36461152f4a2d12..725a472e8ea7b465efdf5a00c729dba753fa0036 100644 (file)
@@ -3,6 +3,7 @@
 #define __MM_KASAN_KASAN_H
 
 #include <linux/kasan.h>
+#include <linux/kfence.h>
 #include <linux/stackdepot.h>
 
 #ifdef CONFIG_KASAN_HW_TAGS
@@ -304,12 +305,20 @@ static inline u8 random_tag(void) { return 0; }
 
 static inline void poison_range(const void *address, size_t size, u8 value)
 {
+       /* Skip KFENCE memory if called explicitly outside of sl*b. */
+       if (is_kfence_address(address))
+               return;
+
        hw_set_mem_tag_range(kasan_reset_tag(address),
                        round_up(size, KASAN_GRANULE_SIZE), value);
 }
 
 static inline void unpoison_range(const void *address, size_t size)
 {
+       /* Skip KFENCE memory if called explicitly outside of sl*b. */
+       if (is_kfence_address(address))
+               return;
+
        hw_set_mem_tag_range(kasan_reset_tag(address),
                        round_up(size, KASAN_GRANULE_SIZE), get_tag(address));
 }
index 7c2c08c55f3252349b4447f0ceedad4121045dfa..e9efe88f76792c119b4fad70cc3ae84df255dfe6 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/kasan.h>
 #include <linux/kernel.h>
+#include <linux/kfence.h>
 #include <linux/kmemleak.h>
 #include <linux/memory.h>
 #include <linux/mm.h>
@@ -84,6 +85,10 @@ void poison_range(const void *address, size_t size, u8 value)
        address = kasan_reset_tag(address);
        size = round_up(size, KASAN_GRANULE_SIZE);
 
+       /* Skip KFENCE memory if called explicitly outside of sl*b. */
+       if (is_kfence_address(address))
+               return;
+
        shadow_start = kasan_mem_to_shadow(address);
        shadow_end = kasan_mem_to_shadow(address + size);
 
@@ -101,6 +106,14 @@ void unpoison_range(const void *address, size_t size)
         */
        address = kasan_reset_tag(address);
 
+       /*
+        * Skip KFENCE memory if called explicitly outside of sl*b. Also note
+        * that calls to ksize(), where size is not a multiple of machine-word
+        * size, would otherwise poison the invalid portion of the word.
+        */
+       if (is_kfence_address(address))
+               return;
+
        poison_range(address, size, tag);
 
        if (size & KASAN_GRANULE_MASK) {