[lkml]   [2017]   [Aug]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 3.18 10/24] mm/cma: make kmemleak ignore CMA regions
3.18-stable review patch.  If anyone has any objections, please let me know.


From: Thierry Reding <>

commit 620951e2745750de1482128615adc15b74ee37ed upstream.

kmemleak will add allocations as objects to a pool. The memory allocated
for each object in this pool is periodically searched for pointers to
other allocated objects. This only works for memory that is mapped into
the kernel's virtual address space, which happens not to be the case for
most CMA regions.

Furthermore, CMA regions are typically used to store data transferred to
or from a device and therefore don't contain pointers to other objects.

Without this, the kernel crashes on the first execution of the
scan_gray_list() because it tries to access highmem. Perhaps a more
appropriate fix would be to reject any object that can't map to a kernel
virtual address?

[ add comment]
[ fix comment, per Catalin]
[ include linux/io.h for phys_to_virt()]
Signed-off-by: Thierry Reding <>
Cc: Michal Nazarewicz <>
Cc: Marek Szyprowski <>
Cc: Joonsoo Kim <>
Cc: "Aneesh Kumar K.V" <>
Cc: Catalin Marinas <>
Signed-off-by: Stephen Rothwell <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
Signed-off-by: Greg Kroah-Hartman <>

mm/cma.c | 6 ++++++
1 file changed, 6 insertions(+)

--- a/mm/cma.c
+++ b/mm/cma.c
@@ -33,6 +33,7 @@
#include <linux/log2.h>
#include <linux/cma.h>
#include <linux/highmem.h>
+#include <linux/io.h>

struct cma {
unsigned long base_pfn;
@@ -325,6 +326,11 @@ int __init cma_declare_contiguous(phys_a

+ /*
+ * kmemleak scans/reads tracked objects for pointers to other
+ * objects but this address isn't mapped and accessible
+ */
+ kmemleak_ignore(phys_to_virt(addr));
base = addr;

 \ /
  Last update: 2017-08-31 17:57    [W:0.075 / U:0.052 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site