From patchwork Fri Mar 25 01:12:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12791172 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 413AAC433EF for ; Fri, 25 Mar 2022 01:12:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D4F0E8D001E; Thu, 24 Mar 2022 21:12:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CFCB18D0005; Thu, 24 Mar 2022 21:12:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BEC6F8D001E; Thu, 24 Mar 2022 21:12:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id AD7A18D0005 for ; Thu, 24 Mar 2022 21:12:13 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A59F26035A for ; Fri, 25 Mar 2022 01:12:13 +0000 (UTC) X-FDA: 79281132546.13.1017113 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf19.hostedemail.com (Postfix) with ESMTP id 0A09D1A0030 for ; Fri, 25 Mar 2022 01:12:12 +0000 (UTC) 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 727C4618C5; Fri, 25 Mar 2022 01:12:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC81EC340EE; Fri, 25 Mar 2022 01:12:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1648170731; bh=RPS66mLY40uI7CEhGYfZFqqxIgB4RPI/gfzwyJYAVB8=; h=Date:To:From:In-Reply-To:Subject:From; b=VzuZPvGwr82PnQ7KgUnkbt/5DAtiej7C3uoqr5NCSS70ylCvW4Psv0DAR9s/2I1m3 oqqYyserZmuq27LctMKTO4X5I8aRrHZozobQ74LcsvUcy2FXwP3QYsqhnbiIT5eb2V I+6JXukwRq3x8mKN/9AHwWK9kWnopKLNTxeF6oaI= Date: Thu, 24 Mar 2022 18:12:11 -0700 To: ryabinin.a.a@gmail.com,mark.rutland@arm.com,glider@google.com,elver@google.com,dvyukov@google.com,andreyknvl@google.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220324180758.96b1ac7e17675d6bc474485e@linux-foundation.org> Subject: [patch 072/114] kasan: print virtual mapping info in reports Message-Id: <20220325011211.CC81EC340EE@smtp.kernel.org> X-Stat-Signature: yi7mryfk7fysgornf5x11bf4jj11x5an Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=VzuZPvGw; spf=pass (imf19.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 0A09D1A0030 X-HE-Tag: 1648170732-606528 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000011, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Andrey Konovalov Subject: kasan: print virtual mapping info in reports Print virtual mapping range and its creator in reports affecting virtual mappings. Also get physical page pointer for such mappings, so page information gets printed as well. Link: https://lkml.kernel.org/r/6ebb11210ae21253198e264d4bb0752c1fad67d7.1645548178.git.andreyknvl@google.com Signed-off-by: Andrey Konovalov Cc: Mark Rutland Cc: Marco Elver Cc: Alexander Potapenko Cc: Dmitriy Vyukov Cc: Andrey Ryabinin Signed-off-by: Andrew Morton --- mm/kasan/report.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) --- a/mm/kasan/report.c~kasan-print-virtual-mapping-info-in-reports +++ a/mm/kasan/report.c @@ -260,8 +260,21 @@ static void print_address_description(vo pr_err(" %pS\n", addr); } + if (is_vmalloc_addr(addr)) { + struct vm_struct *va = find_vm_area(addr); + + if (va) { + pr_err("The buggy address belongs to the virtual mapping at\n" + " [%px, %px) created by:\n" + " %pS\n", + va->addr, va->addr + va->size, va->caller); + + page = vmalloc_to_page(page); + } + } + if (page) { - pr_err("The buggy address belongs to the page:\n"); + pr_err("The buggy address belongs to the physical page:\n"); dump_page(page, "kasan: bad access detected"); }