]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
s390/smp: fix false positive kmemleak of mcesa data structure
authorChristian Borntraeger <borntraeger@de.ibm.com>
Thu, 18 May 2017 11:04:16 +0000 (13:04 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Mon, 12 Jun 2017 14:25:58 +0000 (16:25 +0200)
I get number of CPUs - 1 kmemleak hits like

unreferenced object 0x37ec6f000 (size 1024):
  comm "swapper/0", pid 1, jiffies 4294937330 (age 889.690s)
  hex dump (first 32 bytes):
    6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
    6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
  backtrace:
    [<000000000034a848>] kmem_cache_alloc+0x2b8/0x3d0
    [<00000000001164de>] __cpu_up+0x456/0x488
    [<000000000016f60c>] bringup_cpu+0x4c/0xd0
    [<000000000016d5d2>] cpuhp_invoke_callback+0xe2/0x9e8
    [<000000000016f3c6>] cpuhp_up_callbacks+0x5e/0x110
    [<000000000016f988>] _cpu_up+0xe0/0x158
    [<000000000016faf0>] do_cpu_up+0xf0/0x110
    [<0000000000dae1ee>] smp_init+0x126/0x130
    [<0000000000d9bd04>] kernel_init_freeable+0x174/0x2e0
    [<000000000089fc62>] kernel_init+0x2a/0x148
    [<00000000008adce2>] kernel_thread_starter+0x6/0xc
    [<00000000008adcdc>] kernel_thread_starter+0x0/0xc
    [<ffffffffffffffff>] 0xffffffffffffffff

The pointer of this data structure is stored in the prefix page of that
CPU together with some extra bits ORed into the the low bits.
Mark the data structure as non-leak.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/kernel/smp.c

index 363000a77ffc74c8afd101537d14535fe20d8933..1020a11a24e50ea8dd629876fda04ef3480058a1 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/err.h>
 #include <linux/spinlock.h>
 #include <linux/kernel_stat.h>
+#include <linux/kmemleak.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/irqflags.h>
@@ -207,6 +208,8 @@ static int pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu)
                                kmem_cache_alloc(pcpu_mcesa_cache, GFP_KERNEL);
                        if (!mcesa_origin)
                                goto out;
+                       /* The pointer is stored with mcesa_bits ORed in */
+                       kmemleak_not_leak((void *) mcesa_origin);
                        mcesa_bits = MACHINE_HAS_GS ? 11 : 0;
                }
        } else {