From patchwork Fri May 6 06:01:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Sverdlin X-Patchwork-Id: 12840596 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 72337C433EF for ; Fri, 6 May 2022 06:17:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=V+weirgJOU19yHPv489rbT2BTWkDszdy3abVbnVufyw=; b=wNKqIDy3q7gJOL ajAfnrr9GInD+OlSQrOxGNOCYYqWvWvofw7IAnwLZ9wAJEVWcKJ6CSbDD4gVP7yYeSVqgxl91rv0S kSWTgmqnO5DolnBhfb4CPdnb8jrnqD3N6ybcpgW1OyHWhsDG3Pxm771oOXpdwYz5UxnuwodCtiqer czLiOg15SV0IDiRkpDRMgdrZRlkyZCgqI/uy5C5wFV37FifImJMOCRkrOGLvg8smsWSK1X7noLzLr 3rlxf5aGm4WO7aZkdc315+MEGTpXxHysUBt+zH58LI0PrUPuYX2jPQ1/VlaeA4ivN5k77yVcUnhai /LniGRHinTpzhspMehmw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nmrFk-001YUA-DO; Fri, 06 May 2022 06:15:48 +0000 Received: from mail-ve1eur02on0721.outbound.protection.outlook.com ([2a01:111:f400:fe06::721] helo=EUR02-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nmrFh-001YSi-CW for linux-arm-kernel@lists.infradead.org; Fri, 06 May 2022 06:15:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j9TH530hMOko4y+a3OZixMLL4FSUZTCGFVxsekcbEMpMBv24cmxpAs9+46/Ufve5cme+FAGrvm+6TgGmLHimymN1NelysnQYG/QMEGQYIOUJtmh3/HV/K5qbNaDVo5tTJ7JCKsuEPgvrZt5/pAn1rOHDtzx+3+ZRIy7KPCD1G5nxvYHia/QYfYqC3/ts+3adckH/ytdgQckyzUAHcgtSqZyk2dEAm5uHy9Tzo3LCPmPGoBYhY5YwaYU9bvOdxyRPYX55POv3xkTSrHhGKMcaQm5mMteX1/xAHzSaB9fWumUYsE/BlJEID6NwJTFJ2MM9GFiuS+nk1KFltO9pW2KbRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=El7Nc3mtKX+LWr3Br1RKEhRC/VMyrNOKCfkT1H7wHB4=; b=i3/IQ2t8UADmh/R/TUGJ0uWl8JvzTvFFGOcKj2/FGr3gGFiqFa07y66k+OXg89qzOPb/JZeuEp9XrxPzTKNCS+b/PXdwTX/4nSj8Gs2p6bJ5BssmhVOy/pkAockWmAjd17HOtcEmDrI1PyClHLQypkWrpGvHI7kJZXYcvBs9mRPKORfZWwPVoJrFOiL9b+vgqHdbWv13jD4sHWaHvJ6Jpawzx5SSVyM4gX3pRSOs9FFkow4keEH6prZUztS5sRNbXQK/jVxBL20BhyBmNlatIJem8kE4YdlVJ3izr9DvVAm+CqrljM6uIKg80zolrqvqHIs8FVkN3/ukJOzR5/beTw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.2.8) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nokia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nokia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.onmicrosoft.com; s=selector1-nokia-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=El7Nc3mtKX+LWr3Br1RKEhRC/VMyrNOKCfkT1H7wHB4=; b=yqvyLYXpuZ31Ftm/2IBSSZJX6Fo3TYvjUBToUm8huS7OmAmhIQfHPn7dcmxePA3kveKkgmDz14zydeoCESeC5o01fGXV/xClQP8uKlXpThORMfsCIyk5tPsqJZzMiJP6ObbVDjVWGfL9MHsWrhknWLTF2/c/1VOKT9hzTooYnoc= Received: from DU2PR04CA0267.eurprd04.prod.outlook.com (2603:10a6:10:28e::32) by HE1PR0701MB2345.eurprd07.prod.outlook.com (2603:10a6:3:6c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.18; Fri, 6 May 2022 06:01:25 +0000 Received: from DBAEUR03FT012.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28e:cafe::74) by DU2PR04CA0267.outlook.office365.com (2603:10a6:10:28e::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.27 via Frontend Transport; Fri, 6 May 2022 06:01:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.2.8) smtp.mailfrom=nokia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia.com; Received-SPF: Pass (protection.outlook.com: domain of nokia.com designates 131.228.2.8 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.2.8; helo=fihe3nok0734.emea.nsn-net.net; Received: from fihe3nok0734.emea.nsn-net.net (131.228.2.8) by DBAEUR03FT012.mail.protection.outlook.com (100.127.142.126) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.15 via Frontend Transport; Fri, 6 May 2022 06:01:24 +0000 Received: from ulegcparamis.emea.nsn-net.net (ulegcparamis.emea.nsn-net.net [10.151.74.146]) by fihe3nok0734.emea.nsn-net.net (GMO) with ESMTP id 24661GKm018644; Fri, 6 May 2022 06:01:16 GMT From: Alexander A Sverdlin To: kasan-dev@googlegroups.com Cc: Alexander Sverdlin , Russell King , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] ARM: kasan: Support CONFIG_KASAN_VMALLOC Date: Fri, 6 May 2022 08:01:12 +0200 Message-Id: <20220506060113.14881-1-alexander.sverdlin@nokia.com> X-Mailer: git-send-email 2.10.2 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 713b2b9f-6663-482e-3fe7-08da2f25da59 X-MS-TrafficTypeDiagnostic: HE1PR0701MB2345:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LCndEZ7kDQgrKM6WQIG7+/l6CITyedr4GCGis7nNQ8mUqgXk/w3rsgHZIDK8y9W/k5x8lxAUD6hxqBTBoCCGXH54oMSwNaMqL34N7j5O1Rl61yNtNjc75TDeX/H4by/O8ozeuPwmBJ/6QD6rIDDdsXCcfnx1r4UHCxzk3PVpGHw4H0PVu9JcMp4xdeFGUxl4HOlX8SjBGsND2sQUZOAihsELFWps1Ssqx2nTW8CIuSF2LOEwuautBHVbkpi5aFgI3hGygrtQYomL6cBPnJO9LzG1gXb85xWGMKUyfW/PjjzIq2dJmDCNbbx6Mwj4s3LkUC3lhtogAULkjz+yRytCBgjfMmQFt9SVc1ELeg8dmGtmoY1DHZzLTRdRx25bsUOfVUK6QjbudDtQn44QNweiru2MpF6BTyebu0NSL48vOmW6Lp1CDEI41l5VzdrtWvSM2IQId38BhVzleNXMnpVGANg7ZH3OkMfvaB7yVrPTkhPFErJ2/5j3m5QaWv+YBpP7qLY6lyqOGwbjWCkEZg5Mko8c/5YRqiBkDyRsYAgqzdRpb8bHTaOnsTEbvIhvbCw3RzhTvKqRFTdnsNg3YxGZadBMIESPPXPo6LKid4KPVnAvmGTHhiKmvFZr9wLoUlh3q2zlWv0h0PyDeDLkSekNuZvxSHZOBv4IAkvRo+nXYWH7CBXpIi2oqqKivL7O6vEoPt07OzfC79LERn5/Lc5u9PvESeol36M8NS1i+A8j/3B9eQlLnyHWPNPTyIQYcR15 X-Forefront-Antispam-Report: CIP:131.228.2.8; CTRY:FI; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:fihe3nok0734.emea.nsn-net.net; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(36756003)(26005)(82960400001)(81166007)(36860700001)(47076005)(336012)(83380400001)(2906002)(508600001)(40460700003)(5660300002)(86362001)(8936002)(186003)(316002)(2616005)(6666004)(356005)(82310400005)(70206006)(70586007)(8676002)(4326008)(6916009)(54906003)(1076003)(36900700001); DIR:OUT; SFP:1102; X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2022 06:01:24.8986 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 713b2b9f-6663-482e-3fe7-08da2f25da59 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.2.8]; Helo=[fihe3nok0734.emea.nsn-net.net] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT012.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0701MB2345 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220505_231545_456510_A83985DE X-CRM114-Status: UNSURE ( 9.95 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Alexander Sverdlin Create KASAN mapping between VMALLOC_START and VMALLOC_END instead of early shadow if KASAN_VMALLOC is configured. Signed-off-by: Alexander Sverdlin --- arch/arm/Kconfig | 1 + arch/arm/mm/kasan_init.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 2e8091e..f440cf5 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 5ad0d6c5..c2f49f7 100644 --- a/arch/arm/mm/kasan_init.c +++ b/arch/arm/mm/kasan_init.c @@ -236,7 +236,12 @@ 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)) + create_mapping((void *)VMALLOC_START, (void *)VMALLOC_END); + else + 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) {