From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 981ADC433E0 for ; Thu, 4 Feb 2021 17:57:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1607A64EB9 for ; Thu, 4 Feb 2021 17:57:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1607A64EB9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8897B6B0005; Thu, 4 Feb 2021 12:57:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 811396B0006; Thu, 4 Feb 2021 12:57:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B3DE6B006E; Thu, 4 Feb 2021 12:57:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0226.hostedemail.com [216.40.44.226]) by kanga.kvack.org (Postfix) with ESMTP id 4E2DD6B0005 for ; Thu, 4 Feb 2021 12:57:09 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 0A348180AD817 for ; Thu, 4 Feb 2021 17:57:09 +0000 (UTC) X-FDA: 77781341778.21.frame52_5813668275de Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id D4DAD180442C0 for ; Thu, 4 Feb 2021 17:57:08 +0000 (UTC) X-HE-Tag: frame52_5813668275de X-Filterd-Recvd-Size: 4063 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Feb 2021 17:57:08 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 6061964E16; Thu, 4 Feb 2021 17:57:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612461427; bh=3sPIg9fnAown5IUecDaUUMqiHn7bKJeyVpbW19hTsso=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fvZC0GgAhbuDO6RriMojAl/CW+Fp3wdv9ID1v6pR5TsmJRuUTuY3Yk4dEnvXcfstE 2S7BoGrI11pVfImSibDzFy3l9+tRdSS1jqpVHwGPN7ldhHUL7Eo7iHkJpEWpD4s8Bf zMI+nTiKiWxrJBnGhVEcPL5AXZCxn8enHrCLxdMpdeWuscnZO2q5FFeiVKzA9TThTO 3fjCXiLzybhHWpVLQQwBDyNuF0tsp+E6UarJkit7bwil7PB1+jaiRS0y/s/8cB+W6s V05v52MdeOXWXxplLWoeWSwvs3oOISA6vUGgdjFq3yd2r5u7TEvsQ39PFF3KlW0cWF ztCFT1Up4ukXg== Date: Thu, 4 Feb 2021 17:57:00 +0000 From: Will Deacon To: Lecopzer Chen Cc: akpm@linux-foundation.org, andreyknvl@google.com, ardb@kernel.org, aryabinin@virtuozzo.com, broonie@kernel.org, catalin.marinas@arm.com, dan.j.williams@intel.com, dvyukov@google.com, glider@google.com, gustavoars@kernel.org, kasan-dev@googlegroups.com, lecopzer.chen@mediatek.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-mm@kvack.org, linux@roeck-us.net, robin.murphy@arm.com, rppt@kernel.org, tyhicks@linux.microsoft.com, vincenzo.frascino@arm.com, yj.chiang@mediatek.com Subject: Re: [PATCH v2 0/4] arm64: kasan: support CONFIG_KASAN_VMALLOC Message-ID: <20210204175659.GC21303@willie-the-truck> References: <20210204124914.GC20468@willie-the-truck> <20210204155346.88028-1-lecopzer@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210204155346.88028-1-lecopzer@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) 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: On Thu, Feb 04, 2021 at 11:53:46PM +0800, Lecopzer Chen wrote: > > On Sat, Jan 09, 2021 at 06:32:48PM +0800, Lecopzer Chen wrote: > > > Linux supports KAsan for VMALLOC since commit 3c5c3cfb9ef4da9 > > > ("kasan: support backing vmalloc space with real shadow memory") > > > > > > Acroding to how x86 ported it [1], they early allocated p4d and pgd, > > > but in arm64 I just simulate how KAsan supports MODULES_VADDR in arm64 > > > by not to populate the vmalloc area except for kimg address. > > > > The one thing I've failed to grok from your series is how you deal with > > vmalloc allocations where the shadow overlaps with the shadow which has > > already been allocated for the kernel image. Please can you explain? > > > The most key point is we don't map anything in the vmalloc shadow address. > So we don't care where the kernel image locate inside vmalloc area. > > kasan_map_populate(kimg_shadow_start, kimg_shadow_end,...) > > Kernel image was populated with real mapping in its shadow address. > I `bypass' the whole shadow of vmalloc area, the only place you can find > about vmalloc_shadow is > kasan_populate_early_shadow((void *)vmalloc_shadow_end, > (void *)KASAN_SHADOW_END); > > ----------- vmalloc_shadow_start > | | > | | > | | <= non-mapping > | | > | | > |-----------| > |///////////|<- kimage shadow with page table mapping. > |-----------| > | | > | | <= non-mapping > | | > ------------- vmalloc_shadow_end > |00000000000| > |00000000000| <= Zero shadow > |00000000000| > ------------- KASAN_SHADOW_END > > vmalloc shadow will be mapped 'ondemend', see kasan_populate_vmalloc() > in mm/vmalloc.c in detail. > So the shadow of vmalloc will be allocated later if anyone use its va. Indeed, but the question I'm asking is what happens when an on-demand shadow allocation from vmalloc overlaps with the shadow that we allocated early for the kernel image? Sounds like I have to go and read the code... Will