From patchwork Wed Feb 16 19:01:37 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: 12748927 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 EDA72C433EF for ; Wed, 16 Feb 2022 19:01:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 770826B0074; Wed, 16 Feb 2022 14:01:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 720886B0075; Wed, 16 Feb 2022 14:01:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CC346B0078; Wed, 16 Feb 2022 14:01:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0036.hostedemail.com [216.40.44.36]) by kanga.kvack.org (Postfix) with ESMTP id 451D36B0074 for ; Wed, 16 Feb 2022 14:01:43 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id DA44C8B339 for ; Wed, 16 Feb 2022 19:01:42 +0000 (UTC) X-FDA: 79149562044.15.B028C45 Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by imf01.hostedemail.com (Postfix) with ESMTP id 1E2564001F for ; Wed, 16 Feb 2022 19:01:41 +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=1645038100; 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=KdJNhqvT10fpX2TPTtNinLyaEIbw3AI3xc8h9ebWAy4=; b=cCAtLRxWwCZC99tDT8BMawYtJ0xaVEtPQkTx9SmYLx0XK02F59/j9/qSTpUrBIJDlISYDe qL4qYxiG7k+mmkWi7pzeYTNtdIH8HGLmqW2aZssgEvahVG+b+xkYZqdaWxl8PQP/bbQpJB q8MZO6RSO/5D+5K7dmr0cz1j9ilLQuw= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko , Andrew Morton Cc: Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Vincenzo Frascino , Catalin Marinas , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm] kasan: print virtual mapping info in reports Date: Wed, 16 Feb 2022 20:01:37 +0100 Message-Id: <5b120f7cadcc0e0d8d5f41fd0cff35981b3f7f3a.1645038022.git.andreyknvl@google.com> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=cCAtLRxW; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf01.hostedemail.com: domain of andrey.konovalov@linux.dev designates 94.23.1.103 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 1E2564001F X-Stat-Signature: bjacmjbc3ydex6id4tn4me6uj3b68au9 X-HE-Tag: 1645038101-835228 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 Reviewed-by: Marco Elver --- Note: no need to merge this patch into any of the KASAN vmalloc patches that are already in mm, better to keep it separate. --- mm/kasan/report.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mm/kasan/report.c b/mm/kasan/report.c index 137c2c0b09db..8002fb3c417d 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -260,8 +260,18 @@ 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); + + 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"); }