Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp407705pxb; Thu, 17 Feb 2022 06:44:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+PzlQogdgFMb0twGJZStJM+2mTgVgV0V95X/QDpCOlTCKmUYPjw5ODL0+iGpFAZ55T2+0 X-Received: by 2002:a05:6a00:1146:b0:4c9:ede0:725a with SMTP id b6-20020a056a00114600b004c9ede0725amr3223172pfm.35.1645109080670; Thu, 17 Feb 2022 06:44:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645109080; cv=none; d=google.com; s=arc-20160816; b=ejiJJNNI5srwJxY1ESAQ+FRqcDwZU5zjCr2iUPvEcxb8exEzLXYqgpocB4Iu9hFnph QJXFrxQsYy2L2uiEl+Sh3yQa3S5tZ5Et+Cx3iRF7aA0u7kucR+dXCRCodIvqFbKzWDo6 mE+DsraZSNNAqRv4lr+mfb6wFUsn6a0Kg1cAITN+XzFi8cw4gBrN8ISEenF+Dgxvnhjk 57QGWAbmQLr8egqn6RjZBqv/OwA1iR8zahmJ0Yg1yLEaMHK9TQRJF48qcrhVHlwSDTVD Q9idrbV+aGn9XYokb8dgWQ/c2zm0YwFBXvGHOUg49umGjSnByuO8xvz8Tim7vHb+lana OrUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=wqjOKyX5mo72rmXkkW7lIDDgIvAz/bzzAnn/O4gcYFU=; b=T+Bhyt0aVWQVwbkhuxvthirBCOy1yoVKB8h7F7lGzB0rAo/wBCYBUuuxXpCTIrcNr6 GXUU0pfwTA7VAYzfTGyULrim0gFbnS2msXaomTuVhKchS1QCrB7Z0L5zveES3lEjB0GZ 5OVszTxGht94W0svrtLZlrja3cBgX1LrcM5RnOwxPdWM9u0XJkzAe3SgKkg0r2F7P8x+ c0Hgp2QHT9h+bp7/574+axuMAHp0pIbb8/qBkDwfbv4BmRTTsL55b+zT36vAcyx6STuO wuKchxZIwNQb+VrCArZesVgfC1QffOsI7/KcX7Ly2da+5pXe4t7Y/w8qcsgwouHlHWsL wmCw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id me9si1074805pjb.16.2022.02.17.06.44.24; Thu, 17 Feb 2022 06:44:40 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240107AbiBQMAa (ORCPT + 99 others); Thu, 17 Feb 2022 07:00:30 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234641AbiBQMA3 (ORCPT ); Thu, 17 Feb 2022 07:00:29 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0E829294126 for ; Thu, 17 Feb 2022 04:00:15 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CC7DD113E; Thu, 17 Feb 2022 04:00:14 -0800 (PST) Received: from lakrids (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 65E833F66F; Thu, 17 Feb 2022 04:00:12 -0800 (PST) Date: Thu, 17 Feb 2022 12:00:09 +0000 From: Mark Rutland To: andrey.konovalov@linux.dev Cc: Marco Elver , Alexander Potapenko , Andrew Morton , 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: Re: [PATCH mm] kasan: print virtual mapping info in reports Message-ID: References: <5b120f7cadcc0e0d8d5f41fd0cff35981b3f7f3a.1645038022.git.andreyknvl@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5b120f7cadcc0e0d8d5f41fd0cff35981b3f7f3a.1645038022.git.andreyknvl@google.com> X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, 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 On Wed, Feb 16, 2022 at 08:01:37PM +0100, andrey.konovalov@linux.dev wrote: > 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); The return value of find_vm_area() needs a NULL check here; is_vmalloc_addr(addr) just checks that `addr` is within the vmalloc VA range, and doesn't guarantee that there is a vmap_area associated with that `addr`. Without the NULL-check, we'll blow up on the `va->addr` dereference and will fail to make the report, which would be unfortunate. Thanks, Mark. > + > + 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 >