From patchwork Tue Feb 22 16:43:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: andrey.konovalov@linux.dev X-Patchwork-Id: 12755655 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 CDA42C433F5 for ; Tue, 22 Feb 2022 16:43:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 461008D0003; Tue, 22 Feb 2022 11:43:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4115A8D0001; Tue, 22 Feb 2022 11:43:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 28C6D8D0003; Tue, 22 Feb 2022 11:43:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0246.hostedemail.com [216.40.44.246]) by kanga.kvack.org (Postfix) with ESMTP id 17F038D0001 for ; Tue, 22 Feb 2022 11:43:15 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id BD127181CBDA2 for ; Tue, 22 Feb 2022 16:43:14 +0000 (UTC) X-FDA: 79170985908.26.DA419C9 Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by imf17.hostedemail.com (Postfix) with ESMTP id 3FEFD4000B for ; Tue, 22 Feb 2022 16:43:14 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1645548193; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ZEtbE1Y1jeIgzgzA2TFDElC+yLbMe5ouicxIZ65PMO0=; b=Dmf7G2E3813T6SbZtTPYV5Z62NEYe8WiJNPW2InQUtT3V3viJjjXWUOihuvC65CnU6M1ul 4xNhthUTSiv/QfzvX1Ig/johMVdIjXgDB99q8geowGW/gt5E7XBcccFJA/weV0ZoQBRyje iur5cEqLB5pdADH41rjUSh74M2YzxJg= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Mark Rutland , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm v2] kasan: print virtual mapping info in reports Date: Tue, 22 Feb 2022 17:43:08 +0100 Message-Id: <6ebb11210ae21253198e264d4bb0752c1fad67d7.1645548178.git.andreyknvl@google.com> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Rspam-User: Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Dmf7G2E3; spf=pass (imf17.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 3FEFD4000B X-Stat-Signature: fqau7ftqtuq3m7t5p1q6hwrnf8tgaysd X-HE-Tag: 1645548194-518671 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: From: Andrey Konovalov 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. Signed-off-by: Andrey Konovalov --- Note: no need to merge this patch into any of the KASAN vmalloc patches that are already in mm, better to keep it separate. Changes v1->v2: - Add find_vm_area() return value NULL check as suggested by Mark Rutland. --- mm/kasan/report.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mm/kasan/report.c b/mm/kasan/report.c index 137c2c0b09db..f64352008bb8 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -260,8 +260,21 @@ static void print_address_description(void *addr, u8 tag) 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"); }