From patchwork Fri Jun 3 03:54:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: patrick wang X-Patchwork-Id: 12868483 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 E1E31C433EF for ; Fri, 3 Jun 2022 03:54:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 09C016B0071; Thu, 2 Jun 2022 23:54:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 04F806B0073; Thu, 2 Jun 2022 23:54:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7A946B0074; Thu, 2 Jun 2022 23:54:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D97E56B0071 for ; Thu, 2 Jun 2022 23:54:24 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A78C633D7F for ; Fri, 3 Jun 2022 03:54:24 +0000 (UTC) X-FDA: 79535557248.03.5474725 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by imf17.hostedemail.com (Postfix) with ESMTP id 447944005F for ; Fri, 3 Jun 2022 03:53:47 +0000 (UTC) Received: by mail-pg1-f180.google.com with SMTP id u4so3346386pgk.11 for ; Thu, 02 Jun 2022 20:54:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ixm9po8hHhuybaWeKy+DsLdABD8VQEU/2biNYLl9X48=; b=JvK+ZO+UqjC5x3zZ24bDid7p3s9W56KNURdN+MOP2hkSWBJNmfAqaKaXGxaGGrVfDR TQ6jEzDDpNXhDrPtrk3t7P7bGX+FE3oPgWStb1NU2xSDZ1R+vWo1L8PWyaUfn2b9F9qv t2AH1GmBliPyDfIe+zkRzY5rDmYw37HNeOP1rOLDVCaI1ddxxwJmR+c2jMoaOiqQfASk egtJ4QlysqnZzkAVSyKf0ZpoG8F3XJVfi1oSejt+fSJrFWXPe9v0L7jQNgCSAkz1W3l6 SrDXHLMPNuLmf20zRj6HIgD/B+SgmB7A31UbB/VwH7Zg1lBQofcvWKMtjHARUDLcQHSl DfYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ixm9po8hHhuybaWeKy+DsLdABD8VQEU/2biNYLl9X48=; b=lkwmBqpO9oNZ2/W+D5elW5gHc0BJN2kAZORuKnvg6+GWIgqbvHBNjwiAW3GFj1TpF0 vXLIcY06oKAiSqouBEzEeG4E1XBvgVG1s9S8WZh5lOPmMKl+RI4nSzPSNy4fwY9h5U44 FPnC65O++x9kSHeEqG9KnlkxSJM6HPfc3fhIIAKK5A3kc/+R9IwO6zeOv/B8RzjN49kG vPJRmS6RVkHn/W2y3bXCXj5phat3TluaJUJchPpZC5e2A5Z32Vh3CpdPIHu8DDcqj36+ NKWtvk3CECXdohkoD2SubPkfdqiuYJhzYxy72lUhflyFjwoINK4p+vcw/MlprbXF/QPX CDCw== X-Gm-Message-State: AOAM530E2zoGXwiVZMDP7qgTNOiwAwIPoBtWSNNEsUzhS1Fdw9G8vyBJ XA3vtD6NOXn4tifZWxY4KhU= X-Google-Smtp-Source: ABdhPJz/DiL0xThxIVZwuDcs/w/1pOoA6JsosoT3BWml4IECbGTF4BcekRPpYsrqVs4NY2Ofew5tTg== X-Received: by 2002:a63:e443:0:b0:3f5:e5b3:437f with SMTP id i3-20020a63e443000000b003f5e5b3437fmr7155601pgk.423.1654228463082; Thu, 02 Jun 2022 20:54:23 -0700 (PDT) Received: from localhost ([101.86.206.159]) by smtp.gmail.com with ESMTPSA id t15-20020a17090340cf00b0016168e90f2csm4148863pld.208.2022.06.02.20.54.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 20:54:22 -0700 (PDT) From: Patrick Wang To: catalin.marinas@arm.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, yee.lee@mediatek.com, patrick.wang.shcn@gmail.com Subject: [PATCH v2 0/4] mm: kmemleak: store objects allocated with physical address separately and check when scan Date: Fri, 3 Jun 2022 11:54:11 +0800 Message-Id: <20220603035415.1243913-1-patrick.wang.shcn@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=JvK+ZO+U; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of patrick.wang.shcn@gmail.com designates 209.85.215.180 as permitted sender) smtp.mailfrom=patrick.wang.shcn@gmail.com X-Stat-Signature: kxyobdhzj6pmfe64hco9f8e1qw6qgbnr X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 447944005F X-HE-Tag: 1654228427-697918 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: The kmemleak_*_phys() interface uses "min_low_pfn" and "max_low_pfn" to check address. But on some architectures, kmemleak_*_phys() is called before those two variables initialized. The following steps will be taken: 1) Add OBJECT_PHYS flag and rbtree for the objects allocated with physical address 2) Store physical address in objects if allocated with OBJECT_PHYS 3) Check the boundary when scan instead of in kmemleak_*_phys() This patch set will solve: https://lore.kernel.org/r/20220527032504.30341-1-yee.lee@mediatek.com https://lore.kernel.org/r/9dd08bb5-f39e-53d8-f88d-bec598a08c93@gmail.com v1: https://lore.kernel.org/r/20220531150823.1004101-1-patrick.wang.shcn@gmail.com v1->v2: - add rbtree for the objects allocated with physical address - store physical address in objects if allocated with OBJECT_PHYS - check the upper object boundary as well and avoid duplicate check Patrick Wang (4): mm: kmemleak: add OBJECT_PHYS flag for objects allocated with physical address mm: kmemleak: add rbtree for objects allocated with physical address mm: kmemleak: handle address stored in object based on its type mm: kmemleak: kmemleak_*_phys() set address type and check PA when scan mm/kmemleak.c | 193 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 123 insertions(+), 70 deletions(-)