From patchwork Wed Feb 8 23:19:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaac Manjarres X-Patchwork-Id: 13133778 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 85B22C636D3 for ; Wed, 8 Feb 2023 23:20:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C77DF6B0071; Wed, 8 Feb 2023 18:20:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C27D66B0072; Wed, 8 Feb 2023 18:20:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B17536B0074; Wed, 8 Feb 2023 18:20:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A334D6B0071 for ; Wed, 8 Feb 2023 18:20:08 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 611141402A9 for ; Wed, 8 Feb 2023 23:20:08 +0000 (UTC) X-FDA: 80445694896.11.B6B76F0 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf06.hostedemail.com (Postfix) with ESMTP id 97233180019 for ; Wed, 8 Feb 2023 23:20:06 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=mBb39kHZ; spf=pass (imf06.hostedemail.com: domain of 3JS7kYw4KCDgcmUUWgUhdUllYmaiiafY.Wigfchor-ggepUWe.ila@flex--isaacmanjarres.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3JS7kYw4KCDgcmUUWgUhdUllYmaiiafY.Wigfchor-ggepUWe.ila@flex--isaacmanjarres.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675898406; 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: references:dkim-signature; bh=+6M1s6jVzcZP7H16vCeUwIRH/hJEUzDrlIpdlKRJhik=; b=sbeN4FhZvKOg4tqmm3GPtmbBrYPb5GvcKqvXV+HB8xtHlmLE2UrfF6E7DdByk+vO+CaEcP adHnoT9eaYVqaR/hszOpIvpOF1Gmx3Xqn925A+2IbtK+PYSOufBETGm+JYmS/Floro7VRV cMxQ5ejF8Uxw/kjEtECOY92ahha3cZ8= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=mBb39kHZ; spf=pass (imf06.hostedemail.com: domain of 3JS7kYw4KCDgcmUUWgUhdUllYmaiiafY.Wigfchor-ggepUWe.ila@flex--isaacmanjarres.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3JS7kYw4KCDgcmUUWgUhdUllYmaiiafY.Wigfchor-ggepUWe.ila@flex--isaacmanjarres.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675898406; a=rsa-sha256; cv=none; b=1b5PCxvtsfDwNU3dFSjuOOWFdg4eYHdBz4w6SBrlivclK71TTkXjssVZn0yOt40/cLa4yX tTauVseWTCnFKQx5Bqu5EhsxvbxwR+2mMf2suUnXGOy/AZYaR8NTOU9+rk6MyWc15zPFC3 FpEsQw6H1zbbpSIFB0YEanHOIvABtYw= Received: by mail-yb1-f202.google.com with SMTP id p202-20020a25d8d3000000b00858a2a2cc15so209373ybg.21 for ; Wed, 08 Feb 2023 15:20:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=+6M1s6jVzcZP7H16vCeUwIRH/hJEUzDrlIpdlKRJhik=; b=mBb39kHZdGoftt6jokvxEpIxgXyE4g6cQI9YaKv/PO27i8fxX5pxrgNtuSU0GYHGFA cyHDBjQvthf3Xqw3OAGereXg+BotnoemG2a/dE5BTEleBFRgWKQNEh6jreR/WPI48/GM Dj9tsoy79KreWNfUsTCXK3RjIqtqZlZswVAIP9vw8aNZcpc2sPui2Mkb0B+xocImQ46D KmSFO2GEEvWNAxrPT715rdP2wtkq8kMwIz8CMxOThFa1t79/5WUj6tHqxDCEG75EIhiP F3W91ygmCRpKyGWxKsAqsOwF3+6dI3J2f26Y08qbJASOUuC5yLyJGRe8/uafGcjrXoTh 5L0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=+6M1s6jVzcZP7H16vCeUwIRH/hJEUzDrlIpdlKRJhik=; b=o8k2jxpf8bTynoyT6Z5XXGkvigUlXxIGEe81ZPDn4AhpIztW9rgbUVWBbgjWaXKHXi fRTiZyEWipwWuII7iEq00hSqXaW2yT/CIE/Gm/QsYUqc/TTxZ+5O95dahI8dv3TGE/Bj jOoY8f2SXPHE36B6La0jpt8y4wCVXpNW/ocNKUzqXmzxlGVuMOQAwcqBlunCvpCrDwaS wAjsGHpbLVC1wiLQ00Kef2ZBryMq1ztM2uns/S4PpnCkkFo6pGV9mRWu8N+IsmyUlEAw dneOaTmknbHehOJuQUKDlObhQxUs9RVpOIFUwP2paRElL6eMLwX+IPXsOx6wGSDHEqfa e6vw== X-Gm-Message-State: AO0yUKVFTFtU8dtDyQ4QELJs9rWJgtZswFJvTy0KYzdWtuhlnichIb6E rqlvC2CzN2KKBZnj7k8YumEbVv0iL92aZPE8VAnmuA== X-Google-Smtp-Source: AK7set/kS9P6unQBcb+71E7vO8XBeo8f3HWqwTvhJ1RMmwL44a8INIhB2P197E46QbsxqxFdPinayks2Z3H4MVENs7mucQ== X-Received: from isaacmanjarres.irv.corp.google.com ([2620:15c:2d:3:32e8:a89:521e:3f2e]) (user=isaacmanjarres job=sendgmr) by 2002:a0d:d543:0:b0:52b:ecfa:575a with SMTP id x64-20020a0dd543000000b0052becfa575amr2ywd.0.1675898405151; Wed, 08 Feb 2023 15:20:05 -0800 (PST) Date: Wed, 8 Feb 2023 15:19:59 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.1.581.gbfd45094c4-goog Message-ID: <20230208232001.2052777-1-isaacmanjarres@google.com> Subject: [PATCH v2 0/1] Fix kmemleak crashes when scanning CMA regions From: "Isaac J. Manjarres" To: Rob Herring , Frank Rowand , "Russell King (Oracle)" , Mike Rapoport , "Kirill A. Shutemov" , Nick Kossifidis , Catalin Marinas Cc: Andrew Morton , Saravana Kannan , linux-mm@kvack.org, "Isaac J. Manjarres" , kernel-team@android.com, "Rafael J. Wysocki" , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 97233180019 X-Stat-Signature: ex3hsu5rbene3qijwytrxpa8ap13hyj5 X-Rspam-User: X-HE-Tag: 1675898406-499131 X-HE-Meta: U2FsdGVkX1+a2zH5BRDomCAzjHcxg2iNs/tUbFggRXU796oCCzoNZ/HJPEAClGF9EcRGdwk3r+7MYBJKODnlQwtcZqlbq8ewY60huIc3Dz/np27g/rGz5qDk4iLXi2oomnuPoPf+Ta6W9VJVANN/1NSNrk9kbjTZp3PLH4NrjXJyzv6sFLs2IBMWGLHIqctGVIetKOw0Wecy2wzBjaF4icfIjoMjYLX3kSUO9QkxGK/lLmM1VvYwNm8qIGkldelHQL7m1QkmjBt43yaYcpNgdiUwhFyHCq3B3jGB39ZoGpY3rb98lr9xrdDiP/H38SNaGrZe6vpKMgtX08vhCZ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zrs7pt7hHWJ6CpQiJQzWc13uJ3yx/BBOzIQmDmWyIQnzBAi1Xiv78D/B6mBgHQvOuScuxJeR43R3BUDpDRkYZr67dYbKe6kNjCMka1WNm+76W/GDJ9IgrKSRKm25QfKXLYOSPw3Ixp+uJwh8if4H6wmUixUifthA3WFCbhnIjdBeyNyxOJ2p4N/zoONcEpJomsjgrM111noKGKPbMvQ5nj23tKne64rkCo7dmFZ3RPd64Zw== 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: When trying to boot a device with an ARM64 kernel with the following config options enabled: CONFIG_DEBUG_PAGEALLOC=y CONFIG_DEBUG_PAGEALLOC_ENABLE_DEFAULT=y CONFIG_DEBUG_KMEMLEAK=y a crash is encountered when kmemleak starts to scan the list of gray or allocated objects that it maintains. Upon closer inspection, it was observed that these page-faults always occurred when kmemleak attempted to scan a CMA region. At the moment, kmemleak is made aware of CMA regions that are specified through the devicetree to be dynamically allocated within a range of addresses. However, kmemleak should not need to scan CMA regions or any reserved memory region, as those regions can be used for DMA transfers between drivers and peripherals, and thus wouldn't contain anything useful for kmemleak. Additionally, since CMA regions are unmapped from the kernel's address space when they are freed to the buddy allocator at boot when CONFIG_DEBUG_PAGEALLOC is enabled, kmemleak shouldn't attempt to access those memory regions, as that will trigger a crash. Thus, kmemleak should ignore all dynamically allocated reserved memory regions. v1 ==> v2: - Simplified the original approach of informing kmemleak about all CMA regions in the system to just having kmemleak ignore CMA regions it is currently aware of. Isaac J. Manjarres (1): of: reserved_mem: Have kmemleak ignore dynamically allocated reserved mem drivers/of/of_reserved_mem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)