• Q
    mm/slab.c: kmemleak no scan alien caches · f631fcd0
    Qian Cai 提交于
    mainline inclusion
    from mainline-5.0
    commit 92d1d07daad6
    category: bugfix
    bugzilla: 11610
    CVE: NA
    
    ------------------------------------------------
    
    Kmemleak throws endless warnings during boot due to in
    __alloc_alien_cache(),
    
    alc = kmalloc_node(memsize, gfp, node);
    init_arraycache(&alc->ac, entries, batch);
    kmemleak_no_scan(ac);
    
    Kmemleak does not track the array cache (alc->ac) but the alien cache
    (alc) instead, so let it track the latter by lifting kmemleak_no_scan()
    out of init_arraycache().
    
    There is another place that calls init_arraycache(), but
    alloc_kmem_cache_cpus() uses the percpu allocation where will never be
    considered as a leak.
    
    [   32.258841] kmemleak: Found object by alias at 0xffff8007b9aa7e38
    [   32.258847] CPU: 190 PID: 1 Comm: swapper/0 Not tainted 5.0.0-rc2+ #2
    [   32.258851] Call trace:
    [   32.258858]  dump_backtrace+0x0/0x168
    [   32.258863]  show_stack+0x24/0x30
    [   32.258868]  dump_stack+0x88/0xb0
    [   32.258873]  lookup_object+0x84/0xac
    [   32.258877]  find_and_get_object+0x84/0xe4
    [   32.258882]  kmemleak_no_scan+0x74/0xf4
    [   32.258887]  setup_kmem_cache_node+0x2b4/0x35c
    [   32.258892]  __do_tune_cpucache+0x250/0x2d4
    [   32.258896]  do_tune_cpucache+0x4c/0xe4
    [   32.258901]  enable_cpucache+0xc8/0x110
    [   32.258905]  setup_cpu_cache+0x40/0x1b8
    [   32.258909]  __kmem_cache_create+0x240/0x358
    [   32.258913]  create_cache+0xc0/0x198
    [   32.258918]  kmem_cache_create_usercopy+0x158/0x20c
    [   32.258922]  kmem_cache_create+0x50/0x64
    [   32.258928]  fsnotify_init+0x58/0x6c
    [   32.258932]  do_one_initcall+0x194/0x388
    [   32.258937]  kernel_init_freeable+0x668/0x688
    [   32.258941]  kernel_init+0x18/0x124
    [   32.258946]  ret_from_fork+0x10/0x18
    [   32.258950] kmemleak: Object 0xffff8007b9aa7e00 (size 256):
    [   32.258954] kmemleak:   comm "swapper/0", pid 1, jiffies 4294697137
    [   32.258958] kmemleak:   min_count = 1
    [   32.258962] kmemleak:   count = 0
    [   32.258965] kmemleak:   flags = 0x1
    [   32.258969] kmemleak:   checksum = 0
    [   32.258972] kmemleak:   backtrace:
    [   32.258977]      kmemleak_alloc+0x84/0xb8
    [   32.258982]      kmem_cache_alloc_node_trace+0x31c/0x3a0
    [   32.258987]      __kmalloc_node+0x58/0x78
    [   32.258991]      setup_kmem_cache_node+0x26c/0x35c
    [   32.258996]      __do_tune_cpucache+0x250/0x2d4
    [   32.259001]      do_tune_cpucache+0x4c/0xe4
    [   32.259005]      enable_cpucache+0xc8/0x110
    [   32.259010]      setup_cpu_cache+0x40/0x1b8
    [   32.259014]      __kmem_cache_create+0x240/0x358
    [   32.259018]      create_cache+0xc0/0x198
    [   32.259022]      kmem_cache_create_usercopy+0x158/0x20c
    [   32.259026]      kmem_cache_create+0x50/0x64
    [   32.259031]      fsnotify_init+0x58/0x6c
    [   32.259035]      do_one_initcall+0x194/0x388
    [   32.259039]      kernel_init_freeable+0x668/0x688
    [   32.259043]      kernel_init+0x18/0x124
    [   32.259048] kmemleak: Not scanning unknown object at 0xffff8007b9aa7e38
    [   32.259052] CPU: 190 PID: 1 Comm: swapper/0 Not tainted 5.0.0-rc2+ #2
    [   32.259056] Call trace:
    [   32.259060]  dump_backtrace+0x0/0x168
    [   32.259065]  show_stack+0x24/0x30
    [   32.259070]  dump_stack+0x88/0xb0
    [   32.259074]  kmemleak_no_scan+0x90/0xf4
    [   32.259078]  setup_kmem_cache_node+0x2b4/0x35c
    [   32.259083]  __do_tune_cpucache+0x250/0x2d4
    [   32.259088]  do_tune_cpucache+0x4c/0xe4
    [   32.259092]  enable_cpucache+0xc8/0x110
    [   32.259096]  setup_cpu_cache+0x40/0x1b8
    [   32.259100]  __kmem_cache_create+0x240/0x358
    [   32.259104]  create_cache+0xc0/0x198
    [   32.259108]  kmem_cache_create_usercopy+0x158/0x20c
    [   32.259112]  kmem_cache_create+0x50/0x64
    [   32.259116]  fsnotify_init+0x58/0x6c
    [   32.259120]  do_one_initcall+0x194/0x388
    [   32.259125]  kernel_init_freeable+0x668/0x688
    [   32.259129]  kernel_init+0x18/0x124
    [   32.259133]  ret_from_fork+0x10/0x18
    
    Link: http://lkml.kernel.org/r/20190129184518.39808-1-cai@lca.pw
    Fixes: 1fe00d50 ("slab: factor out initialization of array cache")
    Signed-off-by: NQian Cai <cai@lca.pw>
    Reviewed-by: NAndrew Morton <akpm@linux-foundation.org>
    Cc: Christoph Lameter <cl@linux.com>
    Cc: Pekka Enberg <penberg@kernel.org>
    Cc: David Rientjes <rientjes@google.com>
    Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
    Cc: Catalin Marinas <catalin.marinas@arm.com>
    Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: NStephen Rothwell <sfr@canb.auug.org.au>
    Signed-off-by: Nzhong jiang <zhongjiang@huawei.com>
    Reviewed-by: NJing Xiangfeng <jingxiangfeng@huawei.com>
    Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
    f631fcd0
slab.c 110.9 KB