Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp255110pxm; Tue, 22 Feb 2022 09:58:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3hnygsQpiJcHwbJwvHUlJ2+pGLh5aOSmue1zKzt6YkEr2x6F61Fs6st2qoji701iS73N2 X-Received: by 2002:a17:906:b356:b0:6cf:3810:dcf1 with SMTP id cd22-20020a170906b35600b006cf3810dcf1mr20236603ejb.761.1645552683814; Tue, 22 Feb 2022 09:58:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645552683; cv=none; d=google.com; s=arc-20160816; b=pBNoSmotvYNHVrPr4VKhbHOpfJDRXpifW5IomrUf5KBm8hMaI2MczO0yLFCU3ucBCA qbYz4ZO2DcTaBJWIqdoGSAkrlz9WCbkvTPsKpy2J/ZMJwddAYkdLzuvNgfRitMgXxkHV kzDILeH4BAtBSfd/lBYt/HnheZtLxE/pM389S4bUWXghsWcpIhBUhhhYeWdTzP3gFwvK xEPoJvGuafGIGnW0+VrldALuoawVoA6goE5wNJBT2mLFP9ZgB0ajcX1iwP30/+vfLwpo Q9EpO+A3Tr7fPJ/3GPtV0xY/Ht1FM4ZVq86Nmh8SdhufaEaQPUOJQH2LnY25NomSwofh JyFQ== 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=yNIhRAATUTX+kIeojdTN1OF7kgtG7abyCbvLyCkqOsRyDVFphCv/MU616rPQqV3j/U 7mK/8cMZEziku8Oj7qn+J85faUIJbk0uSSKQE0Ak4MImhBg+GhLp5qfmNGx2fVNeQOBs QJOgi02lv3mcKOOPmIUdjy0Fg5cQDlnvd8x/rOo9cYq7yx5xLFreJGvj14c43+D1awO/ 200PVitHERmBpC29yBAdU+FRR+bEVvqaNM2sSnbp171lboRIO0PleBG6Nc54Jsbj+h5r hy/VHv1FLdNuQvBcPmZdEbVqsPV3eyEQbqTF0o5EcotljB709/PYWA0bF5vGkXa65FSS LOAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=L0rb8ZSb; 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 hz1si13592929ejc.57.2022.02.22.09.57.40; Tue, 22 Feb 2022 09:58:03 -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=L0rb8ZSb; 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 S234251AbiBVQnP (ORCPT + 99 others); Tue, 22 Feb 2022 11:43:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234249AbiBVQnN (ORCPT ); Tue, 22 Feb 2022 11:43:13 -0500 Received: from out1.migadu.com (out1.migadu.com [IPv6:2001:41d0:2:863f::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 198E1C7D6E for ; Tue, 22 Feb 2022 08:42:47 -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=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 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