mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-08 06:03:24 +00:00
kmemleak: Trace the kmalloc_large* functions in slub
The kmalloc_large() and kmalloc_large_node() functions were missed when adding the kmemleak hooks to the slub allocator. However, they should be traced to avoid false positives. Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Cc: Christoph Lameter <cl@linux-foundation.org> Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
This commit is contained in:
parent
2587362eaf
commit
e4f7c0b44a
@ -11,6 +11,7 @@
|
|||||||
#include <linux/workqueue.h>
|
#include <linux/workqueue.h>
|
||||||
#include <linux/kobject.h>
|
#include <linux/kobject.h>
|
||||||
#include <linux/kmemtrace.h>
|
#include <linux/kmemtrace.h>
|
||||||
|
#include <linux/kmemleak.h>
|
||||||
|
|
||||||
enum stat_item {
|
enum stat_item {
|
||||||
ALLOC_FASTPATH, /* Allocation from cpu slab */
|
ALLOC_FASTPATH, /* Allocation from cpu slab */
|
||||||
@ -233,6 +234,7 @@ static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
|
|||||||
unsigned int order = get_order(size);
|
unsigned int order = get_order(size);
|
||||||
void *ret = (void *) __get_free_pages(flags | __GFP_COMP, order);
|
void *ret = (void *) __get_free_pages(flags | __GFP_COMP, order);
|
||||||
|
|
||||||
|
kmemleak_alloc(ret, size, 1, flags);
|
||||||
trace_kmalloc(_THIS_IP_, ret, size, PAGE_SIZE << order, flags);
|
trace_kmalloc(_THIS_IP_, ret, size, PAGE_SIZE << order, flags);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
10
mm/slub.c
10
mm/slub.c
@ -21,7 +21,6 @@
|
|||||||
#include <linux/kmemcheck.h>
|
#include <linux/kmemcheck.h>
|
||||||
#include <linux/cpu.h>
|
#include <linux/cpu.h>
|
||||||
#include <linux/cpuset.h>
|
#include <linux/cpuset.h>
|
||||||
#include <linux/kmemleak.h>
|
|
||||||
#include <linux/mempolicy.h>
|
#include <linux/mempolicy.h>
|
||||||
#include <linux/ctype.h>
|
#include <linux/ctype.h>
|
||||||
#include <linux/debugobjects.h>
|
#include <linux/debugobjects.h>
|
||||||
@ -2835,13 +2834,15 @@ EXPORT_SYMBOL(__kmalloc);
|
|||||||
static void *kmalloc_large_node(size_t size, gfp_t flags, int node)
|
static void *kmalloc_large_node(size_t size, gfp_t flags, int node)
|
||||||
{
|
{
|
||||||
struct page *page;
|
struct page *page;
|
||||||
|
void *ptr = NULL;
|
||||||
|
|
||||||
flags |= __GFP_COMP | __GFP_NOTRACK;
|
flags |= __GFP_COMP | __GFP_NOTRACK;
|
||||||
page = alloc_pages_node(node, flags, get_order(size));
|
page = alloc_pages_node(node, flags, get_order(size));
|
||||||
if (page)
|
if (page)
|
||||||
return page_address(page);
|
ptr = page_address(page);
|
||||||
else
|
|
||||||
return NULL;
|
kmemleak_alloc(ptr, size, 1, flags);
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_NUMA
|
#ifdef CONFIG_NUMA
|
||||||
@ -2926,6 +2927,7 @@ void kfree(const void *x)
|
|||||||
page = virt_to_head_page(x);
|
page = virt_to_head_page(x);
|
||||||
if (unlikely(!PageSlab(page))) {
|
if (unlikely(!PageSlab(page))) {
|
||||||
BUG_ON(!PageCompound(page));
|
BUG_ON(!PageCompound(page));
|
||||||
|
kmemleak_free(x);
|
||||||
put_page(page);
|
put_page(page);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user