Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1603495imd; Sun, 4 Nov 2018 06:09:23 -0800 (PST) X-Google-Smtp-Source: AJdET5c7ljXM0hnKNFwrXxS4lMWn1a/YcNOMc1pXGlvA1RrrGX1uQAYmAvT4JgGNydBxT3Ti24oz X-Received: by 2002:a17:902:4025:: with SMTP id b34-v6mr18853820pld.318.1541340563251; Sun, 04 Nov 2018 06:09:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541340563; cv=none; d=google.com; s=arc-20160816; b=gjTGTqOAuySJKcm3K95mDYA7zn7EpGx6FRPhAWRltzqT4za5Isl7wMBrcAZ311ct8r 5Q8eOOvT1mF/Kklg7AKbl+suacxt2uWmJJByh9i/UHt/DoWiasmdCVv8PfjOZKY+uA4V Y6evUrYTtCrwloKX7PWZTXRJ9krQntaqi/9Y/qExjTqmjCZk/zKlZYeofG37x4njTv+z 4tI1IuuytCyECwIzKPmG7lQmeVU1S25AHvKb/IeEhd4p9RFY6MTGPhYiMjs4gEb58BTQ vAQmDsUWnGsbVKDqhRYL9KJdNDSdBNrlByVh8eJMlYAEFW2glo63V0kg7rob3AQWf/BF JYeA== 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=76ApvZljo+sME/hPmhQo/yOucbcj4VyJVmF3aMJvUL8=; b=a8Lsp5WdLtDo/tJd+WW7uo+Rr6g7aAGiiWdrGZa9YO+Ua0SbBbOzGlCen2Q2Akl9Z2 dIGV0obuq7ulKZIeLa3WxxmxR55ThkvS3idGPubRd92Mrp2Wz2otSWsnYOnjgiICOZ+u GCG4GO4dFnNP8Ad2DZhc7/eoIPy+Q7uTLLCEYX0uuqHo7SSvzq0Lyx+MkLv9iAU94IJu mFH44TVcIc7clGSk+V9bVf0ifxIBa/CzF3YxjvIRTqzMCMc7fFxXpaoLICFRlXDBKk/i RBT13A9BhYsz0mHygpkWsYYgVX1LBB9b3YBOh98j4/TbwoT0E+YunTlWRm671XozMr0f Y6hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=N08Eu5hf; 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 a4-v6si10819400pln.67.2018.11.04.06.09.08; Sun, 04 Nov 2018 06:09:23 -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=N08Eu5hf; 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 S1730219AbeKDXHS (ORCPT + 99 others); Sun, 4 Nov 2018 18:07:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:44832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730164AbeKDXHQ (ORCPT ); Sun, 4 Nov 2018 18:07:16 -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 6A22320862; Sun, 4 Nov 2018 13:52:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541339533; bh=I9mqUG3c5wQhAoy2APweC3mft1peGKDwGooMeor2rKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N08Eu5hfFsQ3c1L2aOokOd7+IgaP1tRw8CIalmZwUFGQJCrwnBLvoLhTb6Z283qqt F4UNol7FDxVJCvLdEtHx6pdFfvnOZaX+mrn63Tj4i55sLShRa1C+uS2E142Uo9Smgp 6jkHiPKboGVXfDIFuE+CF7o1lgV51t+5LCazamMg= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christophe Leroy , Michael Ellerman , Sasha Levin Subject: [PATCH AUTOSEL 4.19 27/57] powerpc/mm: Don't report hugepage tables as memory leaks when using kmemleak Date: Sun, 4 Nov 2018 08:51:14 -0500 Message-Id: <20181104135144.88324-27-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181104135144.88324-1-sashal@kernel.org> References: <20181104135144.88324-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 e87f9ef9115b..7296a42eb62e 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -112,6 +113,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(ptl); return 0; -- 2.17.1