Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp1208399pxb; Wed, 16 Feb 2022 13:36:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyV9w/7S1LfPJLO4rzOMx3bU9Mz539Ltw0fjm6VrcZ+QkiMUWfB8IjW5zPOkv8I+RdnVZKb X-Received: by 2002:a17:902:9886:b0:14d:a230:d41 with SMTP id s6-20020a170902988600b0014da2300d41mr4131521plp.159.1645047373506; Wed, 16 Feb 2022 13:36:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645047373; cv=none; d=google.com; s=arc-20160816; b=iR0RAbi249lKCNnhs5xYd+D9ZtdfLfguF+59q/L1nQfA9acg+5BwqdTDJ9+SwDhjGq ep/WkuormdeHxXQUn0KyEsCobfIhOikIsbiV0/YCkxadmClH725yl9agxDaPiAbAtFjB kI+ZYAZtd38Kr4qShGbgysciJIwO/pzTU7/POt7uO3/yWBVKLel/wR7QZkZrRRGDlYsp DcbqeQ3/smi4W/+0+Ra5hDzJkwvhD/9boPssvaahJ5A+3OPTbZ0kA9GTAF02oDHWYvQ3 SwUgUsDJXZg5yXTraW1oKhiE4Iu34O0Ml0ZJcFWx/psUUG9PdlEFWdJ7cPHhRE7cajqf mEPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=KdJNhqvT10fpX2TPTtNinLyaEIbw3AI3xc8h9ebWAy4=; b=kuZUFwM7dSNwT7yfVf5DIuD2feIsUAFHzjCsaz8pQqec/kNpYYXw9a279u78fvcBww QgZa1+bTtbFI6/HH3cNOn7ntb7Bcdfho4PFlNrK0GlZqp53SIER9Uf/pB2e9fS1Dtn/E TzpdV1NlVTJwUBTbURXHc1OWWQprIfe2vpvz4fO7eVsRfK1QyDTjDNjxwwoHlADEiRaQ pwzQLCqUzSZe0a8bmRNubqt5ocPUb/t2sipyodHrZrIJb1Fj3DEiYFgfhpU1oIMTvmi3 3FBfC/zcmZHFVvnsz0ypz/0AzyeiMZ+9A6/ZnjEBc/bD5EhJ7T+y3G8CSCwrnbsEyq3v BuMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=cCAtLRxW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bd9si18631659plb.486.2022.02.16.13.35.56; Wed, 16 Feb 2022 13:36:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=cCAtLRxW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237964AbiBPTB6 (ORCPT + 99 others); Wed, 16 Feb 2022 14:01:58 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:35824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237717AbiBPTB5 (ORCPT ); Wed, 16 Feb 2022 14:01:57 -0500 Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCEAF14012 for ; Wed, 16 Feb 2022 11:01:42 -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=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 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. --- 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"); } -- 2.25.1