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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 21965C433E0 for ; Thu, 4 Feb 2021 14:46:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 92B2F64F58 for ; Thu, 4 Feb 2021 14:46:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 92B2F64F58 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C7B1F6B0005; Thu, 4 Feb 2021 09:46:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BDE596B0006; Thu, 4 Feb 2021 09:46:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A566A6B006C; Thu, 4 Feb 2021 09:46:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id 890686B0005 for ; Thu, 4 Feb 2021 09:46:25 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 40ADE8249980 for ; Thu, 4 Feb 2021 14:46:25 +0000 (UTC) X-FDA: 77780861130.04.mint81_3107b6e275dc Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 21F498004306 for ; Thu, 4 Feb 2021 14:46:25 +0000 (UTC) X-HE-Tag: mint81_3107b6e275dc X-Filterd-Recvd-Size: 6403 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Feb 2021 14:46:24 +0000 (UTC) Received: by mail-pg1-f180.google.com with SMTP id j2so2270195pgl.0 for ; Thu, 04 Feb 2021 06:46:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ONy/oQQmnX5TrrjNFytVoLv75B7UXC2fqKWnMIXbGzs=; b=JvJ1qeNfvw6BcOjaGVSW5FIeL8kmh8OwMEOC4re7970bU1N83umruRDn8+w+fLl4RN 63EvVEhR6dqS8hoY8mApckXYpIrU6MSmB0GOny3r0m0f58w83FXlYnb2jj4OZptsfkYl 6snfOqi/Hjk7v4Khp5TrGaVjItOSRxAJKXH0JgFYUJRg3aOfNVESawuqryyssousV9k9 i3sK42o8TJSD0eIFg4IRMJJRoikqyjyUprXOlu9kS8USrZn1RAcAQXL2Rq+gdOoUjfFE DcF7Fq0L6QsyUr0wnVQhXzIMUVbuz0O+5BklkUnjDBuM2+9p2OSsbBkYK6hE7aGyJuKq gAMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ONy/oQQmnX5TrrjNFytVoLv75B7UXC2fqKWnMIXbGzs=; b=YoDGPsCbX3hCph8cjGRpuBEkFFP9EBdhuwa06rUUGwbg9s1/Bci+Sus2cLceF1Wi60 CHAobT9FOLqypB5FwfgdtjrXKnXWpCpPy0tYSN7z5kaD+dWNPXPUm4GfGwddVB6P1eZy 6urOwsuE1SciHMUoGYpqgFmbiraBFzbsWtqSvzt7leQFBDWLhf9mloz3WvufvQWOUHME 2AUkoYuiXtfbTGuCkMJviqe7Mb3akMRrTBtUZZTkseadYB2UWKaXyfmU9L7CbCfljZor KhY6dzUKTkADSJS/Ynvh7XhyQ09rLx9pvPXgZZoM0VnUqbQopDtoIh94k003zH9fJBue 3trw== X-Gm-Message-State: AOAM532PRApLAujW+lUiCCYKHY15pOjw/3c+/+HZPNYP766na0iR29pS VX0fKqplYfOBAAwcoWKo2ik= X-Google-Smtp-Source: ABdhPJzai0dWbSt7+WLA3WtD42I4vYknfBo+7vrNRDV/4Nj5JBi54UmO9JfeYGktAdgIawh4bBqF1A== X-Received: by 2002:a62:a108:0:b029:1c1:119b:8713 with SMTP id b8-20020a62a1080000b02901c1119b8713mr8565016pff.74.1612449983550; Thu, 04 Feb 2021 06:46:23 -0800 (PST) Received: from localhost.localdomain (61-230-45-44.dynamic-ip.hinet.net. [61.230.45.44]) by smtp.gmail.com with ESMTPSA id z2sm6382878pfa.121.2021.02.04.06.46.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 06:46:22 -0800 (PST) From: Lecopzer Chen To: will@kernel.org 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, lecopzer@gmail.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 1/4] arm64: kasan: don't populate vmalloc area for CONFIG_KASAN_VMALLOC Date: Thu, 4 Feb 2021 22:46:12 +0800 Message-Id: <20210204144612.75582-1-lecopzer@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210204124543.GA20468@willie-the-truck> References: <20210204124543.GA20468@willie-the-truck> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 Sat, Jan 09, 2021 at 06:32:49PM +0800, Lecopzer Chen wrote: > > Linux support KAsan for VMALLOC since commit 3c5c3cfb9ef4da9 > > ("kasan: support backing vmalloc space with real shadow memory") > >=20 > > Like how the MODULES_VADDR does now, just not to early populate > > the VMALLOC_START between VMALLOC_END. > > similarly, the kernel code mapping is now in the VMALLOC area and > > should keep these area populated. > >=20 > > Signed-off-by: Lecopzer Chen > > --- > > arch/arm64/mm/kasan_init.c | 23 ++++++++++++++++++----- > > 1 file changed, 18 insertions(+), 5 deletions(-) > >=20 > > diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c > > index d8e66c78440e..39b218a64279 100644 > > --- a/arch/arm64/mm/kasan_init.c > > +++ b/arch/arm64/mm/kasan_init.c > > @@ -214,6 +214,7 @@ static void __init kasan_init_shadow(void) > > { > > u64 kimg_shadow_start, kimg_shadow_end; > > u64 mod_shadow_start, mod_shadow_end; > > + u64 vmalloc_shadow_start, vmalloc_shadow_end; > > phys_addr_t pa_start, pa_end; > > u64 i; > > =20 > > @@ -223,6 +224,9 @@ static void __init kasan_init_shadow(void) > > mod_shadow_start =3D (u64)kasan_mem_to_shadow((void *)MODULES_VADDR= ); > > mod_shadow_end =3D (u64)kasan_mem_to_shadow((void *)MODULES_END); > > =20 > > + vmalloc_shadow_start =3D (u64)kasan_mem_to_shadow((void *)VMALLOC_S= TART); > > + vmalloc_shadow_end =3D (u64)kasan_mem_to_shadow((void *)VMALLOC_END= ); > > + > > /* > > * We are going to perform proper setup of shadow memory. > > * At first we should unmap early shadow (clear_pgds() call below). > > @@ -241,12 +245,21 @@ static void __init kasan_init_shadow(void) > > =20 > > kasan_populate_early_shadow(kasan_mem_to_shadow((void *)PAGE_END), > > (void *)mod_shadow_start); > > - kasan_populate_early_shadow((void *)kimg_shadow_end, > > - (void *)KASAN_SHADOW_END); > > + if (IS_ENABLED(CONFIG_KASAN_VMALLOC)) { >=20 > Do we really need yet another CONFIG option for KASAN? What's the use-c= ase > for *not* enabling this if you're already enabling one of the KASAN > backends? As I know, KASAN_VMALLOC now only supports KASAN_GENERIC and also KASAN_VMALLOC uses more memory to map real shadow memory (1/8 of vmalloc = va). There should be someone can enable KASAN_GENERIC but can't use VMALLOC due to memory issue. =20 > > + kasan_populate_early_shadow((void *)vmalloc_shadow_end, > > + (void *)KASAN_SHADOW_END); > > + if (vmalloc_shadow_start > mod_shadow_end) >=20 > To echo Ard's concern: when is the above 'if' condition true? After reviewing this code, since VMALLOC_STAR is a compiler defined macro of MODULES_END, this if-condition will never be true. I also test it with removing this and works fine. I'll remove this in the next version patch, thanks a lot for pointing out this. BRs, Lecopzer