From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF235C61DA4 for ; Thu, 9 Feb 2023 18:55:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D2066B0078; Thu, 9 Feb 2023 13:55:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 581BD6B007B; Thu, 9 Feb 2023 13:55:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 422746B007D; Thu, 9 Feb 2023 13:55:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3175F6B0078 for ; Thu, 9 Feb 2023 13:55:52 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 05D631C66A8 for ; Thu, 9 Feb 2023 18:55:51 +0000 (UTC) X-FDA: 80448657744.20.55F18E0 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf19.hostedemail.com (Postfix) with ESMTP id 540861A000A for ; Thu, 9 Feb 2023 18:55:50 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675968950; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1UJtw283ny+J7njJ6hYafOf/9J8l46/eZgcs8hEo0Io=; b=5wIbAgALqOHy9JhLybSZBtlS38Pe/GK2hk5CBXtSV+xHWsMKw9vvMvVSueK/fl1ugQvHtt zUt4UkcWLdeHISJYJYM2ggee+j6jpMJNK1wlDwWY0DJSxRABPIKJDm494jeZ03nCGak2Yi IpGSe2NfZFwDD2izknisfTdctlsUzvs= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675968950; a=rsa-sha256; cv=none; b=g/OfeATuCNqWqT4NP2j8aiwhgjBltRpD1R5f7oOoHBMTbKdPyZB9NhBF4wS0mHDeYPLEU7 XLFAqumrTZGtgT2OOiFQ3c9Y7/iL2B5nXNVc4bJ5YD3j3hWsdhlzUg/LkHSSqsq+AsakJB oNPBggY7kNN3P+5hYkR+4+PWAoB2KZY= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5E67261A39; Thu, 9 Feb 2023 18:55:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2466C433D2; Thu, 9 Feb 2023 18:55:45 +0000 (UTC) Date: Thu, 9 Feb 2023 18:55:42 +0000 From: Catalin Marinas To: "Isaac J. Manjarres" Cc: Rob Herring , Frank Rowand , "Russell King (Oracle)" , Mike Rapoport , "Kirill A. Shutemov" , Nick Kossifidis , Andrew Morton , Saravana Kannan , linux-mm@kvack.org, kernel-team@android.com, "Rafael J. Wysocki" , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Rob Herring Subject: Re: [PATCH v2 1/1] of: reserved_mem: Have kmemleak ignore dynamically allocated reserved mem Message-ID: References: <20230208232001.2052777-1-isaacmanjarres@google.com> <20230208232001.2052777-2-isaacmanjarres@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230208232001.2052777-2-isaacmanjarres@google.com> X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: 47td73f18zcb8qzzbminwarb81fzh83u X-Rspamd-Queue-Id: 540861A000A X-HE-Tag: 1675968950-987039 X-HE-Meta: U2FsdGVkX19WK1DbL+Sp2ZjsmvMIbHSzNvzc05DLuUTEiPVqqg0H3nz+dtB4pRorzNYK5EW5hAJi3io0BcDcHW8PIjg+KIGO2N3UvujkWhdtzWR43jRx4CulZrlJrFMRGdkhreFTkwz4L/I66oDAW4JRQ5iTK0mavHii3U3u4Zw+YDpEs2eF4rvigwvV2JaQ3x3MiFF4unf1nm+vynkm8h+SLihp+QofTMuDRSaFVBbYo4HCX9NjM/MlCW6VNF4h0J14OKCRX56tGASU/NeCayanOYdu8/bxSyF3cdjIyWiIDe1ir9YZ7ywVr0nwRHIf+zSyYy+A9+q8bpkoYhIYCE2yzKI7mjc2XxYdrzXB9W82W//tK8YM7ENrSOjT+kMrQvxOLJNNK6JqLEmJsWRRTJAunHvDdGfvUjJ6vHicKqoUw7c/yzOcnxrnni+mEOogF7Nx9N9/bhfeHsrnB1QwKBV0CrjzH/vHxPYDxjhIICRTm7E024z4rQLijdPkY8iqFx/lAtIJw9+Dpie9YhQqY4nLPugdTLnVFW2zN8vNaGZ0flrf5C333+WkDrbFLUxnoapF5pdUNUo7OepotcjM/nEh7BstEJfQb2wCNIdXQ+VE87kGH8nmz3obQEpVnO8pD03K/ZobeoGoOPszs0UzeC/VUrav+n4OPI21Fjx+KYLzaxyEGXPxk7mg2HmqBI20+yubdfEPJ9x9f5LeOMhyqXRjGqkjmrKx/cNn5sATd6GrCq1uhg3tAwD+mlaryNfY8y3aMiyAiXjE3Fl46upBUVQjzISSd5FEURljDLxmNQWKj9xacRvVnw3k3huBzb8yI/niP8pIBtxMME1a+8hhyob0lxuN3ajcPxATDIFIvjm9Cr69yPVPN9WicCRDDHUs1LYo1y/yBHallZy020ZsYzGy974oLqfM+Rf/Ni2v4X/NgfLTOxaaQ57rEzGOEifl16qZIc6cGXyV0/nE0ai 4diekE9P yXAx+0j61aKw5+ilGIhqSs2DnGuwRV4TKJzMMcZP+tUQHEVcLromxEX5As2bAvtZRCo5y/xJWj9xeRTRH3raHLdz9opvmDQD1lYGLEm+128MCsg1sLGTFypN8YLkQXGVBUykD4qlw7/c6E4hpC8pFgSVcexBD8hc4QDSwesxwSEhBTmF55sK2S+5V4whEWB119N+oWpkxGNFMN4kqAikhTdcx7yQHvzKiMBucNViGxsnP4BH5Z0s+d3lY5ooKhDUKdMW7VI4zbPWNEt3lZI03NenIRexku17uYHiOjumCkPBtLiEnw8uIGcQkuOZ7BGsLNaLV8yXSBVmN+xqraF8NjuKPtF0MyqBdV3uN4Pw7wdAzqcWyTep2b/t8sV5XXPIOkAbKmUe7uh2fBFtsT1/ym+1gJQKoCrxTn15Wn53MVo1gaaHJdMUB+LA3daVqiaUIf4g5w7Vi+dvZzKHbI+xLD108hIbYi2099ShEC5i4lK5+UQWEjkKzjNK3/ZeYKu0ee9by/g3cuN/VOPkT3T4qeADszwh02C/7vBzouPhiWpoGRVck7Jp0heqRYleUefqEWGG7a8BV42p+Ht0NOPoHec3Q5MLy6ZNcpQ6BE8Og5JqsXPXDno4TW482qZZ/xjAMwnWOFGNlxuL9fJYMV9Igz0fquIhjYbDYWsTyf16ti3QedX7gYkmQSaZFLLoZC7ehbQfLiV5p5yUxKTY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Feb 08, 2023 at 03:20:00PM -0800, Isaac J. Manjarres wrote: > Currently, kmemleak ignores dynamically allocated reserved memory > regions that don't have a kernel mapping. However, regions that do > retain a kernel mapping (e.g. CMA regions) do get scanned by kmemleak. > > This is not ideal for two reasons: > > 1. kmemleak works by scanning memory regions for pointers to > allocated objects to determine if those objects have been leaked > or not. However, reserved memory regions can be used between drivers > and peripherals for DMA transfers, and thus, would not contain pointers > to allocated objects, making it unnecessary for kmemleak to scan > these reserved memory regions. > > 2. When CONFIG_DEBUG_PAGEALLOC is enabled, along with kmemleak, the > CMA reserved memory regions are unmapped from the kernel's address > space when they are freed to buddy at boot. These CMA reserved regions > are still tracked by kmemleak, however, and when kmemleak attempts to > scan them, a crash will happen, as accessing the CMA region will result > in a page-fault, since the regions are unmapped. > > Thus, use kmemleak_ignore_phys() for all dynamically allocated reserved > memory regions, instead of those that do not have a kernel mapping > associated with them. > > Cc: # 5.15+ > Fixes: a7259df76702 ("memblock: make memblock_find_in_range method private") > Signed-off-by: Isaac J. Manjarres Acked-by: Catalin Marinas