Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp354991pxm; Wed, 23 Feb 2022 01:41:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxgD1fvjo1ejjDYjlZYrt2k+T7yNRllMfi6aHTiH9j3If4Bx6RQFbDPlj0Dv4W9IFWr7Koi X-Received: by 2002:a50:d4d2:0:b0:410:9fa2:60d6 with SMTP id e18-20020a50d4d2000000b004109fa260d6mr30164249edj.35.1645609305551; Wed, 23 Feb 2022 01:41:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645609305; cv=none; d=google.com; s=arc-20160816; b=Nzfp7FzalFvWiCKp8CSmWP7nkUjaKFpTiNLTU+QqgvQ1AiFJYIirVgx7swP5LRbuld Ey7BCq4Ygg1gPw9TQOKVtgai5LpA8RpmQgI9lwXGu0kwwuo4NrEXPSILm3VIX6jBnm9z VeL66KdIjcSO1jx90LbtMQn2ON/F8atUUhBeRTeKfLkTX26V99SWhcHfTFpfB2uoZGPT 1wKlugibQIZzU73seicFXOFCcRbOtsouh9YjvZCtCkwzCwSz8SXjdNfUVhrK+kiw2eUf PNZnOkcXuB7VWPHA4Unh91aj42PpEybpBhsUCtCmthNQkjSocXDTJuujFNk4TL138xHu v/rA== 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=ZEtbE1Y1jeIgzgzA2TFDElC+yLbMe5ouicxIZ65PMO0=; b=HF+6OsXFf7w4PLoh5Fm9K/sOsZcfBoxGLl3evz5siAg4sbZprIdaWxF+BGaeXT0iDE IERpRMaoMqQX4s0hrVT7sDDPiBwTHY6xav7/4VEfwd2jW29xC8TJsBIZkJpGZtgQoLdU kagkastqfR1rtIDy1q8a0IVE2IfNmxgmlCXI0qUctBA4u/MB0mQTb6G292Zmh+i8NpRM APp8daSE3JK8TQIbHymI8tlQOBL+B4rOd2bv0TmEmsugHG377jn+DEq2+hgU/Vx3KdIE cgR4UDqLds3eyptWxHs3UvQEr0UtPQHJHlryWbIIgMfPALXBORjYF3J9QBmPirAbS4xE 9EVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Dmf7G2E3; 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 s14si15446921edi.476.2022.02.23.01.41.21; Wed, 23 Feb 2022 01:41:45 -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=Dmf7G2E3; 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 S234269AbiBVQnk (ORCPT + 99 others); Tue, 22 Feb 2022 11:43:40 -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: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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. 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"); } -- 2.25.1