Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1594009imd; Sun, 4 Nov 2018 06:01:35 -0800 (PST) X-Google-Smtp-Source: AJdET5dm4DNWgGR15c/WW+iw2Hzr4jzo1lkIz1R0xQTN27uKqxLBL2O7WSeZZUtY7cjYHHSU0HUU X-Received: by 2002:a62:3301:: with SMTP id z1-v6mr18198565pfz.85.1541340095072; Sun, 04 Nov 2018 06:01:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541340095; cv=none; d=google.com; s=arc-20160816; b=TDQKnh0bwQfYubNJzu5QUDLZFT+/s/pspA9CXTTtfAMc/1ehzmxA8PdLu8ghw+LcVh w5gCJGKgKUDnBzlZxSnduX3im+Pm4wClc9BAwlPtRqHkUgfrweimZ0jefouLWD8AvOp4 e8WAyVtYgUV6i4cs/8VxqXgLqzDHrcBz8UW51JHxXNFGQXj3kmj5QbcsrmKcGz2uBxG+ gSrIqSgUFV+mSm8xTmzS2LaUfWluQucWl028mg8IykaJ/RdnDT9zJu91kNe7FqlDgIBo fmdcTDsuPg4qEUkPPf31rez9EcUDwc/9xHr2sB8Ycg7y3Fj/dM1OQkkwb7o3seYhAgN8 WT9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=HPSOzOcbCzMR08j7zK7kzr2A2oU2rKuCHqOpS6NQaqQ=; b=yNP08khhfKSNf/ASEprkLnsMYJFFNnxP8VYJF1OwrTitTqw0gtrW1xYZD4Y7e0TVVi 7RvHVOTimSLrMIdvpttGoxwoak8Zy/PxnEBKyEJkeukbbMUVELntBAf3mtYft00fRx6L UygC9LZ3UN4nDG6G7f3TW6g78A0yyF6uevdw2rpmaz2TcdQmkfaaF6RTDDzlpCdCE15q +4NuwARdM7gz+C3/0os/q5wa8zYTkAxgxLhuAZ3zgE4ocOCxqo63D97BCCgDKQLAWvm0 U0PNSkrZzi+o6EW30CrVP+oevBId2KSSwVMR2M9pvBH1imodhJQKB1IOpR3cv/6UrOEh gqug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FcAkby9B; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m26-v6si25461191pfe.80.2018.11.04.06.01.20; Sun, 04 Nov 2018 06:01:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FcAkby9B; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731840AbeKDXP1 (ORCPT + 99 others); Sun, 4 Nov 2018 18:15:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:47694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731246AbeKDXIm (ORCPT ); Sun, 4 Nov 2018 18:08:42 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D33C520862; Sun, 4 Nov 2018 13:53:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541339618; bh=TuI6gclktS8m6x9eTqcREjculI0oeYOv/ENqsMLXD+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FcAkby9BD9irrpVNcV8HqBDKcV5Qp3PfwBkFkfr7ewqOA5+N7/N9EGDj1CKQ/ZcD7 xdNUPJhuZnSn2EjTMviETMmCg1ma4ZLmimjLPCriRwjl6XdjjC02xBeovP03lNdTUg zX65hX5FEVSdeCUq+kL6QsNgJFwT2/IUJlSMgIPU= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christophe Leroy , Michael Ellerman , Sasha Levin Subject: [PATCH AUTOSEL 4.14 12/30] powerpc/mm: Don't report hugepage tables as memory leaks when using kmemleak Date: Sun, 4 Nov 2018 08:53:07 -0500 Message-Id: <20181104135325.88524-12-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181104135325.88524-1-sashal@kernel.org> References: <20181104135325.88524-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe Leroy [ Upstream commit 803d690e68f0c5230183f1a42c7d50a41d16e380 ] When a process allocates a hugepage, the following leak is reported by kmemleak. This is a false positive which is due to the pointer to the table being stored in the PGD as physical memory address and not virtual memory pointer. unreferenced object 0xc30f8200 (size 512): comm "mmap", pid 374, jiffies 4872494 (age 627.630s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [] huge_pte_alloc+0xdc/0x1f8 [<9e0df1e1>] hugetlb_fault+0x560/0x8f8 [<7938ec6c>] follow_hugetlb_page+0x14c/0x44c [] __get_user_pages+0x1c4/0x3dc [] __mm_populate+0xac/0x140 [<3215421e>] vm_mmap_pgoff+0xb4/0xb8 [] ksys_mmap_pgoff+0xcc/0x1fc [<4fcd760f>] ret_from_syscall+0x0/0x38 See commit a984506c542e2 ("powerpc/mm: Don't report PUDs as memory leaks when using kmemleak") for detailed explanation. To fix that, this patch tells kmemleak to ignore the allocated hugepage table. Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/mm/hugetlbpage.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index 4c9e5f9c7a44..e2d929ddad7f 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -110,6 +111,8 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, for (i = i - 1 ; i >= 0; i--, hpdp--) *hpdp = __hugepd(0); kmem_cache_free(cachep, new); + } else { + kmemleak_ignore(new); } spin_unlock(&mm->page_table_lock); return 0; -- 2.17.1