The commit is pushed to "branch-rh7-3.10.0-229.7.2-ovz" and will appear at 
https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.6.6
------>
commit 5a39d8752462593deb7d24f021f2b5fe5956ad8f
Author: Andrey Ryabinin <aryabi...@odin.com>
Date:   Thu Sep 3 19:27:39 2015 +0400

    ms/mm: slub: introduce metadata_access_enable()/metadata_access_disable()
    
    https://jira.sw.ru/browse/PSBM-26429
    
    From: Andrey Ryabinin <a.ryabi...@samsung.com>
    
    commit a79316c6178ca419e35feef47d47f50b4e0ee9f2 upstream.
    
    It's ok for slub to access memory that marked by kasan as inaccessible
    (object's metadata).  Kasan shouldn't print report in that case because
    these accesses are valid.  Disabling instrumentation of slub.c code is not
    enough to achieve this because slub passes pointer to object's metadata
    into external functions like memchr_inv().
    
    We don't want to disable instrumentation for memchr_inv() because this is
    quite generic function, and we don't want to miss bugs.
    
    metadata_access_enable/metadata_access_disable used to tell KASan where
    accesses to metadata starts/end, so we could temporarily disable KASan
    reports.
    
    Signed-off-by: Andrey Ryabinin <a.ryabi...@samsung.com>
    Cc: Dmitry Vyukov <dvyu...@google.com>
    Cc: Konstantin Serebryany <k...@google.com>
    Cc: Dmitry Chernenkov <dmit...@google.com>
    Signed-off-by: Andrey Konovalov <adech...@gmail.com>
    Cc: Yuri Gribov <tetra2...@gmail.com>
    Cc: Konstantin Khlebnikov <koc...@gmail.com>
    Cc: Sasha Levin <sasha.le...@oracle.com>
    Cc: Christoph Lameter <c...@linux.com>
    Cc: Joonsoo Kim <iamjoonsoo....@lge.com>
    Cc: Dave Hansen <dave.han...@intel.com>
    Cc: Andi Kleen <a...@firstfloor.org>
    Cc: Ingo Molnar <mi...@elte.hu>
    Cc: Thomas Gleixner <t...@linutronix.de>
    Cc: "H. Peter Anvin" <h...@zytor.com>
    Cc: Christoph Lameter <c...@linux.com>
    Cc: Pekka Enberg <penb...@kernel.org>
    Cc: David Rientjes <rient...@google.com>
    Signed-off-by: Andrew Morton <a...@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torva...@linux-foundation.org>
    Signed-off-by: Andrey Ryabinin <aryabi...@odin.com>
    
    Signed-off-by: Andrey Ryabinin <aryabi...@odin.com>
---
 mm/slub.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/mm/slub.c b/mm/slub.c
index 306cfc4..d775ccb 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -20,6 +20,7 @@
 #include <linux/proc_fs.h>
 #include <linux/notifier.h>
 #include <linux/seq_file.h>
+#include <linux/kasan.h>
 #include <linux/kmemcheck.h>
 #include <linux/cpu.h>
 #include <linux/cpuset.h>
@@ -464,12 +465,30 @@ static char *slub_debug_slabs;
 static int disable_higher_order_debug;
 
 /*
+ * slub is about to manipulate internal object metadata.  This memory lies
+ * outside the range of the allocated object, so accessing it would normally
+ * be reported by kasan as a bounds error.  metadata_access_enable() is used
+ * to tell kasan that these accesses are OK.
+ */
+static inline void metadata_access_enable(void)
+{
+       kasan_disable_current();
+}
+
+static inline void metadata_access_disable(void)
+{
+       kasan_enable_current();
+}
+
+/*
  * Object debugging
  */
 static void print_section(char *text, u8 *addr, unsigned int length)
 {
+       metadata_access_enable();
        print_hex_dump(KERN_ERR, text, DUMP_PREFIX_ADDRESS, 16, 1, addr,
                        length, 1);
+       metadata_access_disable();
 }
 
 static struct track *get_track(struct kmem_cache *s, void *object,
@@ -499,7 +518,9 @@ static void set_track(struct kmem_cache *s, void *object,
                trace.max_entries = TRACK_ADDRS_COUNT;
                trace.entries = p->addrs;
                trace.skip = 3;
+               metadata_access_enable();
                save_stack_trace(&trace);
+               metadata_access_disable();
 
                /* See rant in lockdep.c */
                if (trace.nr_entries != 0 &&
@@ -672,7 +693,9 @@ static int check_bytes_and_report(struct kmem_cache *s, 
struct page *page,
        u8 *fault;
        u8 *end;
 
+       metadata_access_enable();
        fault = memchr_inv(start, value, bytes);
+       metadata_access_disable();
        if (!fault)
                return 1;
 
@@ -765,7 +788,9 @@ static int slab_pad_check(struct kmem_cache *s, struct page 
*page)
        if (!remainder)
                return 1;
 
+       metadata_access_enable();
        fault = memchr_inv(end - remainder, POISON_INUSE, remainder);
+       metadata_access_disable();
        if (!fault)
                return 1;
        while (end > fault && end[-1] == POISON_INUSE)
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to