Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752047AbdHaPzc (ORCPT ); Thu, 31 Aug 2017 11:55:32 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36270 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751814AbdHaPoI (ORCPT ); Thu, 31 Aug 2017 11:44:08 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thierry Reding , Michal Nazarewicz , Marek Szyprowski , Joonsoo Kim , "Aneesh Kumar K.V" , Catalin Marinas , Stephen Rothwell , Andrew Morton , Linus Torvalds Subject: [PATCH 3.18 10/24] mm/cma: make kmemleak ignore CMA regions Date: Thu, 31 Aug 2017 17:43:46 +0200 Message-Id: <20170831154105.688629546@linuxfoundation.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170831154105.116844281@linuxfoundation.org> References: <20170831154105.116844281@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2085 Lines: 63 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? [akpm@linux-foundation.org: add comment] [akpm@linux-foundation.org: fix comment, per Catalin] [sfr@canb.auug.org.au: 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 #include #include +#include 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; }