From nobody Thu Jun 25 04:46:45 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 360DBC433EF for ; Tue, 22 Feb 2022 16:43:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234272AbiBVQnl (ORCPT ); Tue, 22 Feb 2022 11:43:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232544AbiBVQnk (ORCPT ); Tue, 22 Feb 2022 11:43:40 -0500 Received: from out1.migadu.com (out1.migadu.com [IPv6:2001:41d0:2:863f::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88F74C7D7B for ; Tue, 22 Feb 2022 08:43:14 -0800 (PST) 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 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 t= ag) pr_err(" %pS\n", addr); } =20 + if (is_vmalloc_addr(addr)) { + struct vm_struct *va =3D 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 =3D 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"); } =20 --=20 2.25.1