Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1681853rwb; Sun, 14 Aug 2022 09:24:57 -0700 (PDT) X-Google-Smtp-Source: AA6agR5W8bgfEalqOP2tpuc63gwzTP1ZMsAEiw3QuZcYk68LXhV8Sl7N8m/ym7gzx1LDZ6uEs5dJ X-Received: by 2002:a17:90b:681:b0:1fa:7c0d:2480 with SMTP id m1-20020a17090b068100b001fa7c0d2480mr963566pjz.142.1660494297091; Sun, 14 Aug 2022 09:24:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660494297; cv=none; d=google.com; s=arc-20160816; b=OsABmkDNs6wwcEpy4685e5CdwKoRh0tbrhZrl9yuGiMDPxaamKuFbv6J1ibBKWYM1v CoQaYb3bXTzzG5uhdSwXYen9cM+DhmcRB0HBr8knT5bMDfIkQZF2734o9d1CE8qdU48b xbma7aEEeFozx+q84LK+K2Oh2Jr0gjW8Mtb9caRJU56yWIahhy8cm5RFRpgos95qZwEM +2c63uUTbOLrtBjroolXgr5WpgALP6LG4oe0axhCnvVTfNk2ovIi742RK57/5PmoIpEg kmBZoMnK3xhAc6PIL3WB7PzJ+uPS8aUqA5/dEg6qqbC5DKJ5zsf6MOnz4H02hc5A1/t1 2vMg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=s2djNZABbvmH2AvUX+S2K4U66TjxzdyJZ6lYmrkXhvM=; b=IirOuHHhXekogk2ffrtAu82rHtScChTG0MFupADZnB+RPYLn6v90Wc4VpGpYrQe08K 5R3wQ6/TEQ+VpbS6Y+h9sCridD/w6k12RMc6076i07m/fmDAP+s/7tCXT9pNXevSb2lw HiZ64wj01eoF70rDSHpzpOwlR98i664/JmUz69N2mvGS0R/9X0TCrtWP5i2ct+w10FC6 MBAh1CuRTi3a7Z8CyMQ4O77gzvP8Mfqe7Ki9FADroXGUWQt0J9dGFyjtgbDP+mhZWgxn YUnbKYdi3dbMJA+TL2BD7TVX84eHr80BVOJXPosiatLBgVWGXpA+8uift4tcXeS8yzy7 92Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GtAorFRN; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ck6-20020a17090afe0600b001f311d42a69si7372371pjb.41.2022.08.14.09.24.45; Sun, 14 Aug 2022 09:24:57 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=GtAorFRN; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240540AbiHNPd0 (ORCPT + 99 others); Sun, 14 Aug 2022 11:33:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240662AbiHNPcw (ORCPT ); Sun, 14 Aug 2022 11:32:52 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C07C51BEAE; Sun, 14 Aug 2022 08:30:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id D2C2ECE0B63; Sun, 14 Aug 2022 15:30:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A8DBC433C1; Sun, 14 Aug 2022 15:29:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660491001; bh=j0ae/WdP7gEyPtfKQLveka6TokTh1KSumwSZFAyHfIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GtAorFRNBgAJ3AH0EwM1n+k0WiDz7/GpAwo4dPV+DaetaLfU+pIVHn5Bahinvuj60 69FvOw6QdARAG7wG05677Nz0JvTHSh7SkZxDl9qeRXpnb6fJcLKzx/hYwnVUiX1twr K5CC/A8PzBkD5gpreAT1mI+k4oBas+hBH//jp8j/XJAdZ+erpJpkvs9ZcCIG1gVd+Z 8vnMjbpwVVPJ8ui41EeALhR7oSJ4F5/s46W32rJ8oDN/X61DxC2zva0nQb8aaPlr0i ynSAUlNQGsNZV3yxHX4ZAR1dBCzkLtPeqKeim+xPHQGHfvAtXtEBBHiRBkONKd0F/O 4329rJ3UdRg+g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lecopzer Chen , Linus Walleij , Russell King , Sasha Levin , linux@armlinux.org.uk, ryabinin.a.a@gmail.com, matthias.bgg@gmail.com, arnd@arndb.de, ardb@kernel.org, rostedt@goodmis.org, nick.hawkins@hpe.com, john@phrozen.org, linux-arm-kernel@lists.infradead.org, kasan-dev@googlegroups.com, linux-mediatek@lists.infradead.org Subject: [PATCH AUTOSEL 5.19 54/64] ARM: 9202/1: kasan: support CONFIG_KASAN_VMALLOC Date: Sun, 14 Aug 2022 11:24:27 -0400 Message-Id: <20220814152437.2374207-54-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220814152437.2374207-1-sashal@kernel.org> References: <20220814152437.2374207-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 From: Lecopzer Chen [ Upstream commit 565cbaad83d83e288927b96565211109bc984007 ] Simply make shadow of vmalloc area mapped on demand. Since the virtual address of vmalloc for Arm is also between MODULE_VADDR and 0x100000000 (ZONE_HIGHMEM), which means the shadow address has already included between KASAN_SHADOW_START and KASAN_SHADOW_END. Thus we need to change nothing for memory map of Arm. This can fix ARM_MODULE_PLTS with KASan, support KASan for higmem and support CONFIG_VMAP_STACK with KASan. Signed-off-by: Lecopzer Chen Tested-by: Linus Walleij Reviewed-by: Linus Walleij Signed-off-by: Russell King (Oracle) Signed-off-by: Sasha Levin --- arch/arm/Kconfig | 1 + arch/arm/mm/kasan_init.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 7630ba9cb6cc..545d2d4a492b 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -75,6 +75,7 @@ config ARM select HAVE_ARCH_KFENCE if MMU && !XIP_KERNEL select HAVE_ARCH_KGDB if !CPU_ENDIAN_BE32 && MMU select HAVE_ARCH_KASAN if MMU && !XIP_KERNEL + select HAVE_ARCH_KASAN_VMALLOC if HAVE_ARCH_KASAN select HAVE_ARCH_MMAP_RND_BITS if MMU select HAVE_ARCH_PFN_VALID select HAVE_ARCH_SECCOMP diff --git a/arch/arm/mm/kasan_init.c b/arch/arm/mm/kasan_init.c index 5ad0d6c56d56..29caee9c79ce 100644 --- a/arch/arm/mm/kasan_init.c +++ b/arch/arm/mm/kasan_init.c @@ -236,7 +236,11 @@ void __init kasan_init(void) clear_pgds(KASAN_SHADOW_START, KASAN_SHADOW_END); - kasan_populate_early_shadow(kasan_mem_to_shadow((void *)VMALLOC_START), + if (!IS_ENABLED(CONFIG_KASAN_VMALLOC)) + kasan_populate_early_shadow(kasan_mem_to_shadow((void *)VMALLOC_START), + kasan_mem_to_shadow((void *)VMALLOC_END)); + + kasan_populate_early_shadow(kasan_mem_to_shadow((void *)VMALLOC_END), kasan_mem_to_shadow((void *)-1UL) + 1); for_each_mem_range(i, &pa_start, &pa_end) { -- 2.35.1