From patchwork Sat Jan 9 10:32:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lecopzer Chen X-Patchwork-Id: 12008075 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,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 3E6BBC433DB for ; Sat, 9 Jan 2021 10:33:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AE5C820897 for ; Sat, 9 Jan 2021 10:33:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE5C820897 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 C37696B0122; Sat, 9 Jan 2021 05:33:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BE7FF6B017E; Sat, 9 Jan 2021 05:33:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A60696B0181; Sat, 9 Jan 2021 05:33:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id 904AE6B0122 for ; Sat, 9 Jan 2021 05:33:09 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 53F5E181AEF2A for ; Sat, 9 Jan 2021 10:33:09 +0000 (UTC) X-FDA: 77685874098.28.cream13_0914cc8274fa Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 34FF76C11 for ; Sat, 9 Jan 2021 10:33:09 +0000 (UTC) X-HE-Tag: cream13_0914cc8274fa X-Filterd-Recvd-Size: 4915 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Sat, 9 Jan 2021 10:33:08 +0000 (UTC) Received: by mail-pl1-f176.google.com with SMTP id b8so7043387plx.0 for ; Sat, 09 Jan 2021 02:33:08 -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:mime-version :content-transfer-encoding; bh=REJcHYfVpby7r9Plat861Deb3UCTNl3jWnkLKDVNOTw=; b=Kor0HaVeHVs7YYUOQZ05gUWuNtOwjxDYJqWrgBtIAReqrojCFtPViV7k6RPsAv6KD+ f3IMeYXvvn1OfPUsolfH+e6FpkPp3SRA3NbBmcDgWzOQx/iUnhc/KMx0UZmDIBmSYEEW hLZFffygYj/kiMSxPIfZ9uuc330Ur7esfHBk3+ac035nG2W9MG9VrCZdpsun99HqjhyS ToVa3OiwtZxg2MPh03Cj6VtFS01xIZmWga7Ym75rEvfoDaTBbxuU2tUQNnTI7mI7Tu2o K09njQke4fOs1NAcnnhRwaTawGcK0IQxkfgY71NVOV2FMbuc0n9Z99ICnLp4kEBSkyGi TcFQ== 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:mime-version :content-transfer-encoding; bh=REJcHYfVpby7r9Plat861Deb3UCTNl3jWnkLKDVNOTw=; b=LlCMQl/1fI5lgS9HZXTdbKrTm7x8HM80oKNkUR5S8bebP6S6DQa6sODDRl5WKI7Iva phOsIRqGWiBUrkUUGbnY3RAtI+0Ingr6v+31WvFGkWlfgH6GYkZnj7b6xAY9C3sy35pp aFFHThL4bdo+LPqNGPpMQhm5rOvDwql3kwvh4ZJCNbYLk0VKsgJa/Yt5+qKHHLPMNWeg Iyq8nzP3zk1aqaLZURogDEYc4iGjRhNGEcQE7te3phzbi6EnA5XfBucsbeGR/QgqbgHH WhHZ4rz46fwZLAd1Ipt4wMlK3MK2NxpsVwUJSUI6PrJUs2nMofMwsYNKr/MAbn+IYpMy jmlg== X-Gm-Message-State: AOAM532+wAsmRk/y6iFXX401+8t93i99SBbMmvV9ARnSC0OWe4S4cBdr 8FxeBJCT2kYNeA8txOSXh/4= X-Google-Smtp-Source: ABdhPJyq/Xepgo8/6OP79ismqH9P0ePsxiRCe0nTJ19J50oo5g+37mqRX3WbEC47TgFeliE56SPwKw== X-Received: by 2002:a17:90b:512:: with SMTP id r18mr7980605pjz.166.1610188387613; Sat, 09 Jan 2021 02:33:07 -0800 (PST) Received: from localhost.localdomain (61-230-13-78.dynamic-ip.hinet.net. [61.230.13.78]) by smtp.gmail.com with ESMTPSA id w200sm11691572pfc.14.2021.01.09.02.33.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jan 2021 02:33:07 -0800 (PST) From: Lecopzer Chen To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org Cc: dan.j.williams@intel.com, aryabinin@virtuozzo.com, glider@google.com, dvyukov@google.com, akpm@linux-foundation.org, linux-mediatek@lists.infradead.org, yj.chiang@mediatek.com, will@kernel.org, catalin.marinas@arm.com, ardb@kernel.org, andreyknvl@google.com, broonie@kernel.org, linux@roeck-us.net, rppt@kernel.org, tyhicks@linux.microsoft.com, robin.murphy@arm.com, vincenzo.frascino@arm.com, gustavoars@kernel.org, Lecopzer Chen , Lecopzer Chen Subject: [PATCH v2 0/4] arm64: kasan: support CONFIG_KASAN_VMALLOC Date: Sat, 9 Jan 2021 18:32:48 +0800 Message-Id: <20210109103252.812517-1-lecopzer@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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: 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. Test environment: 4G and 8G Qemu virt, 39-bit VA + 4k PAGE_SIZE with 3-level page table, test by lib/test_kasan.ko and lib/test_kasan_module.ko It also works in Kaslr with CONFIG_RANDOMIZE_MODULE_REGION_FULL and randomize module region inside vmalloc area. [1]: commit 0609ae011deb41c ("x86/kasan: support KASAN_VMALLOC") Signed-off-by: Lecopzer Chen Acked-by: Andrey Konovalov Tested-by: Andrey Konovalov v2 -> v1 1. kasan_init.c tweak indent 2. change Kconfig depends only on HAVE_ARCH_KASAN 3. support randomized module region. v1: https://lore.kernel.org/lkml/20210103171137.153834-1-lecopzer@gmail.com/ Lecopzer Chen (4): arm64: kasan: don't populate vmalloc area for CONFIG_KASAN_VMALLOC arm64: kasan: abstract _text and _end to KERNEL_START/END arm64: Kconfig: support CONFIG_KASAN_VMALLOC arm64: kaslr: support randomized module area with KASAN_VMALLOC arch/arm64/Kconfig | 1 + arch/arm64/kernel/kaslr.c | 18 ++++++++++-------- arch/arm64/kernel/module.c | 16 +++++++++------- arch/arm64/mm/kasan_init.c | 29 +++++++++++++++++++++-------- 4 files changed, 41 insertions(+), 23 deletions(-) Tested-by: Ard Biesheuvel