From patchwork Tue Feb 22 16:42:44 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: 12755654 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 15A19C433EF for ; Tue, 22 Feb 2022 16:42:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A7BE8D0002; Tue, 22 Feb 2022 11:42:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 82FDA8D0001; Tue, 22 Feb 2022 11:42:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A93A8D0002; Tue, 22 Feb 2022 11:42:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0126.hostedemail.com [216.40.44.126]) by kanga.kvack.org (Postfix) with ESMTP id 57B9D8D0001 for ; Tue, 22 Feb 2022 11:42:49 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 14887181CA08C for ; Tue, 22 Feb 2022 16:42:49 +0000 (UTC) X-FDA: 79170984858.16.9719401 Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by imf27.hostedemail.com (Postfix) with ESMTP id 6CB314000F for ; Tue, 22 Feb 2022 16:42:48 +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=1645548166; 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=L0rb8ZSbl/SnmXwb18UCF+iWR3hLMGloKfnfY++ehSwVZXNKDdgA7ogght5RzDBkphCIJ0 B4a9VWn0H9cvrJA+gEaWnDIA5Cxt8TnFTdLp+nW0UNiAT90aXcSsbQ0DJgj0LT7sgE04lc i0bGj+oH0iQrA5yhpdAbxfBDqbspqMo= 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] kasan: print virtual mapping info in reports Date: Tue, 22 Feb 2022 17:42:44 +0100 Message-Id: <6ebb11210ae21253198e264d4bb0752c1fad67d7.1645548053.git.andreyknvl@google.com> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 6CB314000F X-Stat-Signature: k4z3tq9jjhzj9yc8mms3o86ed7sfkh5u Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=L0rb8ZSb; spf=pass (imf27.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-HE-Tag: 1645548168-963160 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"); }