Message ID | 82d6efa1879a9ab0f0c35d7251284f403c3ac82a.1525798754.git.andreyknvl@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3BC7F60353 for <patchwork-linux-mm@patchwork.kernel.org>; Tue, 8 May 2018 17:21:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27DB6290B3 for <patchwork-linux-mm@patchwork.kernel.org>; Tue, 8 May 2018 17:21:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18E09290B9; Tue, 8 May 2018 17:21:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90E53290B3 for <patchwork-linux-mm@patchwork.kernel.org>; Tue, 8 May 2018 17:21:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EC316B02C6; Tue, 8 May 2018 13:21:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2C3BD6B02C7; Tue, 8 May 2018 13:21:25 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13CA96B02C8; Tue, 8 May 2018 13:21:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f69.google.com (mail-wm0-f69.google.com [74.125.82.69]) by kanga.kvack.org (Postfix) with ESMTP id A62D66B02C6 for <linux-mm@kvack.org>; Tue, 8 May 2018 13:21:24 -0400 (EDT) Received: by mail-wm0-f69.google.com with SMTP id e26-v6so4287196wmh.7 for <linux-mm@kvack.org>; Tue, 08 May 2018 10:21:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:in-reply-to:references; bh=QmNrLV2ouq37rJeTa4aJrb/A4HzlLl64fsXLaFH/79U=; b=aATJ+DQd09VKuc755+wF05+nEeJvEURXLnb0g03/OShGUV//3aCsSdMiszTj0MJV6w E4Yqpze4XnLVPnLXJsdFLpHRxxg4ilke+bv0N2b7IWotfhH1TW0YifeZ9WVPPrglCNRM 1Ot0frAdOo++YUJ5AFRCsuGSwXRJk9cyqexA8yuz6PvuOUL0FRHB1C51u+B+bOFezwOi w5mX1bKVkskzeH070eyNeznHoPNbEwD7ygZpX1TsEc7fZeH3d6Tj4/82O0qDnmoDEUgQ Yam7JVLONeTadUAdMtBgh6+2IHMEs72STBJ3F9VO3GTR5OWkyuH0jQhPIPuTPHtQ9675 0hVw== X-Gm-Message-State: ALQs6tCYorjpk2F9DmWwJvFeCd/DyeRo1Nfkps6tH5C909KGkoTkhBuQ dl3EdHgIQEU/+i/qT1P/kT46d/y4CEeL+iU3OmUx3TRloO/myTbU3/Dm26XwwuoWLdCx8ZAzsFr cLI9EySnWdznC5mrGlgvk1629kVf1pnSJGN44MDeV7rL0qAMPxl4UN+17JkfZcb7lPGsxMAb6kY 1GLAR8Ea4yNIfKaY2iYkEnzA+S+ca5IN6XnvUMBhNsPDJFI8AhgH/2+/GO2b//F/p6zhPcyrn/s vucO334hLB2pPmdvvRxFQRvPAL8gOIhwtBxRpcM7LksvcKcVzvtLusHejcuGmcpXwG2ECXimIeQ JaDyh/oFL/E6Kqu4dz485FEqfQP2eX937zr2MdjHaTcO14994KTdiyXZmLCXcLxP0qTI/nats1I / X-Received: by 2002:adf:9658:: with SMTP id c24-v6mr31010067wra.190.1525800084257; Tue, 08 May 2018 10:21:24 -0700 (PDT) X-Received: by 2002:adf:9658:: with SMTP id c24-v6mr31010017wra.190.1525800083523; Tue, 08 May 2018 10:21:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525800083; cv=none; d=google.com; s=arc-20160816; b=FbCpSTznz9gIDkeAtByYqTdl3lv4PDvTlIwsdf7QIHXCNHuFZiJrX0Jrmzm2tKxc7n 5A/2jiQIPSlbU9LIi8qVfjbaoU+dC9kttSuhQFPXiz4vnoBIyAww10CypZ+dFLGHBizE Cgwbc28cohDAX3fHPVuOj86te2wHOj1+rpw0IHEJfWhLm2aMxUJezhQVwI9bABAp3WRv BM8CcqNaZpNsblJYabBO8LNm8TgcOnF9U2Q7vTm9QKsONw7LMzc9SMwjXb4t4JcLxX42 vyrELu+Uz7nZbhvRCSL+yDcm69xqonhd9+xC3BhtCtUme20imHldxsFoNg2h9zh9PN0h 6wEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=QmNrLV2ouq37rJeTa4aJrb/A4HzlLl64fsXLaFH/79U=; b=Oz634Y7hKfSUebwAlv9nJQX3+5hJA9P72HzXJVnvDzvrVzPAMDN/FbyZCQLb2CqXbl fRAaTlN3dCc48Q/ZtQQHDqCo9ZmE2LWATjliLTJ0igg7wHFEFnYQ7dSLRguwiG54IqqY 1wd9ZnSN8Tn8yReSeEivr8CfsHSI7ePqnAvmAcnvL9mzeNiXcPIGC5QhalqveuN03Zm4 4s23nGqFxXxTZG/qzdAD/cDuj8ez7GqomXQIwWG7f0RjvLpnDK6MYYnj8O6/DiC4zO2Z 7UznmnfP+bF4PPAOvI+EtfZ+KH8GV3Q7Vfny1cdoUYfBtT6DxMZAC1VzS7ll76cZlvKR qCYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qcgIx79D; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id o66-v6sor12129412wrb.30.2018.05.08.10.21.23 for <linux-mm@kvack.org> (Google Transport Security); Tue, 08 May 2018 10:21:23 -0700 (PDT) Received-SPF: pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qcgIx79D; spf=pass (google.com: domain of andreyknvl@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=andreyknvl@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=QmNrLV2ouq37rJeTa4aJrb/A4HzlLl64fsXLaFH/79U=; b=qcgIx79Dqsm5W/4pF2jVzunC8anbYsrTSswHKkoap9SoyraY8bFdrjTIPh7P5iJrwG CA+rziEZPaWJjgmWQGNE/jkhqJYlhxS/djf9pv+17hf3VvLGbviNvsI//1V/+f9Ql37/ ZQWGdHj8MWuRArZh0LANOE91Rz8B7gjV0piQNPD3i1PzWqlJHnx751cg0vsxRTOzeyc8 VwH/sXLr7lapQsCRIlsy4p62lAi99czL/XC9AqqY3FlT7wrCChQmYaszz4Jyed2Gkihe OjnTKKgtAnw6XgHE18yZeSuUAlS+IWcLkUtYU/355fP0Floh54DEqp/fafhiRSAKhq2i 3P7w== X-Google-Smtp-Source: AB8JxZrE0Zvje53ekCiQ5091B1wopM1Hl9R4HO51zbca6GFvC0pbfWGM3M9JPHV9QhEjxLxu4c/plA== X-Received: by 2002:adf:8e44:: with SMTP id n62-v6mr33809816wrb.159.1525800082211; Tue, 08 May 2018 10:21:22 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id m134sm14178311wmg.4.2018.05.08.10.21.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 May 2018 10:21:21 -0700 (PDT) From: Andrey Konovalov <andreyknvl@google.com> To: Andrey Ryabinin <aryabinin@virtuozzo.com>, Alexander Potapenko <glider@google.com>, Dmitry Vyukov <dvyukov@google.com>, Jonathan Corbet <corbet@lwn.net>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will.deacon@arm.com>, Christopher Li <sparse@chrisli.org>, Christoph Lameter <cl@linux.com>, Pekka Enberg <penberg@kernel.org>, David Rientjes <rientjes@google.com>, Joonsoo Kim <iamjoonsoo.kim@lge.com>, Andrew Morton <akpm@linux-foundation.org>, Masahiro Yamada <yamada.masahiro@socionext.com>, Michal Marek <michal.lkml@markovi.net>, Andrey Konovalov <andreyknvl@google.com>, Mark Rutland <mark.rutland@arm.com>, Nick Desaulniers <ndesaulniers@google.com>, Yury Norov <ynorov@caviumnetworks.com>, Marc Zyngier <marc.zyngier@arm.com>, Kristina Martsenko <kristina.martsenko@arm.com>, Suzuki K Poulose <suzuki.poulose@arm.com>, Punit Agrawal <punit.agrawal@arm.com>, Dave Martin <dave.martin@arm.com>, Ard Biesheuvel <ard.biesheuvel@linaro.org>, James Morse <james.morse@arm.com>, Michael Weiser <michael.weiser@gmx.de>, Julien Thierry <julien.thierry@arm.com>, Tyler Baicar <tbaicar@codeaurora.org>, "Eric W . Biederman" <ebiederm@xmission.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@kernel.org>, Kees Cook <keescook@chromium.org>, Sandipan Das <sandipan@linux.vnet.ibm.com>, David Woodhouse <dwmw@amazon.co.uk>, Paul Lawrence <paullawrence@google.com>, Herbert Xu <herbert@gondor.apana.org.au>, Josh Poimboeuf <jpoimboe@redhat.com>, Geert Uytterhoeven <geert@linux-m68k.org>, Tom Lendacky <thomas.lendacky@amd.com>, Arnd Bergmann <arnd@arndb.de>, Dan Williams <dan.j.williams@intel.com>, Michal Hocko <mhocko@suse.com>, Jan Kara <jack@suse.cz>, Ross Zwisler <ross.zwisler@linux.intel.com>, =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= <jglisse@redhat.com>, Matthew Wilcox <mawilcox@microsoft.com>, "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>, Souptick Joarder <jrdr.linux@gmail.com>, Hugh Dickins <hughd@google.com>, Davidlohr Bueso <dave@stgolabs.net>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Philippe Ombredanne <pombredanne@nexb.com>, Kate Stewart <kstewart@linuxfoundation.org>, Laura Abbott <labbott@redhat.com>, Boris Brezillon <boris.brezillon@bootlin.com>, Vlastimil Babka <vbabka@suse.cz>, Pintu Agarwal <pintu.ping@gmail.com>, Doug Berger <opendmb@gmail.com>, Anshuman Khandual <khandual@linux.vnet.ibm.com>, Mike Rapoport <rppt@linux.vnet.ibm.com>, Mel Gorman <mgorman@suse.de>, Pavel Tatashin <pasha.tatashin@oracle.com>, Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>, kasan-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sparse@vger.kernel.org, linux-mm@kvack.org, linux-kbuild@vger.kernel.org Cc: Kostya Serebryany <kcc@google.com>, Evgeniy Stepanov <eugenis@google.com>, Lee Smith <Lee.Smith@arm.com>, Ramana Radhakrishnan <Ramana.Radhakrishnan@arm.com>, Jacob Bramley <Jacob.Bramley@arm.com>, Ruben Ayrapetyan <Ruben.Ayrapetyan@arm.com>, Kees Cook <keescook@google.com>, Jann Horn <jannh@google.com>, Mark Brand <markbrand@google.com>, Chintan Pandya <cpandya@codeaurora.org> Subject: [PATCH v1 06/16] khwasan, arm64: untag virt address in __kimg_to_phys Date: Tue, 8 May 2018 19:20:52 +0200 Message-Id: <82d6efa1879a9ab0f0c35d7251284f403c3ac82a.1525798754.git.andreyknvl@google.com> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog In-Reply-To: <cover.1525798753.git.andreyknvl@google.com> References: <cover.1525798753.git.andreyknvl@google.com> In-Reply-To: <cover.1525798753.git.andreyknvl@google.com> References: <cover.1525798753.git.andreyknvl@google.com> 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-mm.kvack.org> X-Virus-Scanned: ClamAV using ClamSMTP |
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index 6d084431b7f7..f206273469b5 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -92,6 +92,12 @@ #define KASAN_THREAD_SHIFT 0 #endif +#ifdef CONFIG_KASAN_HW +#define KASAN_TAG_SHIFTED(tag) ((unsigned long)(tag) << 56) +#define KASAN_SET_TAG(addr, tag) (((addr) & ~KASAN_TAG_SHIFTED(0xff)) | \ + KASAN_TAG_SHIFTED(tag)) +#endif + #define MIN_THREAD_SHIFT (14 + KASAN_THREAD_SHIFT) /* @@ -225,7 +231,12 @@ static inline unsigned long kaslr_offset(void) #define __is_lm_address(addr) (!!((addr) & BIT(VA_BITS - 1))) #define __lm_to_phys(addr) (((addr) & ~PAGE_OFFSET) + PHYS_OFFSET) + +#ifdef CONFIG_KASAN_HW +#define __kimg_to_phys(addr) (KASAN_SET_TAG((addr), 0xff) - kimage_voffset) +#else #define __kimg_to_phys(addr) ((addr) - kimage_voffset) +#endif #define __virt_to_phys_nodebug(x) ({ \ phys_addr_t __x = (phys_addr_t)(x); \
__kimg_to_phys (which is used by virt_to_phys) assumes that the top byte of the address is 0xff, which isn't always the case with KHWASAN enabled. The solution is to reset the tag in __kimg_to_phys. __lm_to_phys doesn't require any fixups, as it zeroes out the top byte with the current implementation. Signed-off-by: Andrey Konovalov <andreyknvl@google.com> --- arch/arm64/include/asm/memory.h | 11 +++++++++++ 1 file changed, 11 insertions(+)