From patchwork Thu Sep 7 17:36:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tycho Andersen X-Patchwork-Id: 9942597 Return-Path: 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 7EB5A600CB for ; Thu, 7 Sep 2017 17:38:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70839285B5 for ; Thu, 7 Sep 2017 17:38:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65518285C2; Thu, 7 Sep 2017 17:38:53 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 764E0285B5 for ; Thu, 7 Sep 2017 17:38:52 +0000 (UTC) Received: (qmail 21588 invoked by uid 550); 7 Sep 2017 17:37:28 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 20332 invoked from network); 7 Sep 2017 17:37:22 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=docker.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gPBkcwV8I8ovVs8hl0Jt3QDlZ+AWnNzzuaWaCbwltCc=; b=UQT/+av6H2IprAZ3qVuYlwJaBtColFc2zo/nKRiyBnqwMCqhQVzBbrPN5HUAEvcCxp BswIp4XEYLGwEr0wVHPz7d8wmZuJolswskpZrXjrEkGkWUjxzXwouTg5jtL9XtG67Gjy KPYJAecIftXid0pSQ7qr8IgULNKgKo8Q9pDGE= 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; bh=gPBkcwV8I8ovVs8hl0Jt3QDlZ+AWnNzzuaWaCbwltCc=; b=AUVKkHHOty0Du3sbnRE2KOYlN8LgDYKNNhIxqQjMFsuYwTvBIGbWoWjl7Yacztqnru 8qVF7jfcWul4wvGXgosA+cqLhwp+bNYlo4HIA1/kT0TpbXmxm8gkh96X8CyNd+nu4I7i 5hN4e9hNAUvLPyvxAA4GLhNUQaxTP4PhsGXxutlJ1PMK9IT1l9qwt7EuQ/1dpeQshZoL AX3u1FoyPoaserkEYhL7d5s/Y2ShNWPq6NtIPGoJfcQ3rmg/wnVjiUvh7g2IOvr5xgvw Od25/bgbRwPQ075B+5DEsYNRQ3Hh9p7Pur+Ya1tQA+ckhI6YaFTMaMaWOcggI4hPPjQf T+9A== X-Gm-Message-State: AHPjjUiF2lqIKF7KTCVLjtjCgyORwXfnLvuO6G1dQyDhbVFvsT7cDpBd TmVDLCWCYYslfvrL X-Google-Smtp-Source: AOwi7QA4fDlVFYnmgUwzeV9bpClDuUL1+wnfPU9MCrurDgRuxFbs6r96o2iGNjR1a6Ybh82Q3a4amg== X-Received: by 10.36.61.149 with SMTP id n143mr89890itn.138.1504805831241; Thu, 07 Sep 2017 10:37:11 -0700 (PDT) From: Tycho Andersen To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, kernel-hardening@lists.openwall.com, Marco Benatto , Juerg Haefliger , linux-arm-kernel@lists.infradead.org, Tycho Andersen Date: Thu, 7 Sep 2017 11:36:05 -0600 Message-Id: <20170907173609.22696-8-tycho@docker.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170907173609.22696-1-tycho@docker.com> References: <20170907173609.22696-1-tycho@docker.com> Subject: [kernel-hardening] [PATCH v6 07/11] arm64/mm, xpfo: temporarily map dcache regions X-Virus-Scanned: ClamAV using ClamSMTP From: Juerg Haefliger If the page is unmapped by XPFO, a data cache flush results in a fatal page fault, so let's temporarily map the region, flush the cache, and then unmap it. v6: actually flush in the face of xpfo, and temporarily map the underlying memory so it can be flushed correctly CC: linux-arm-kernel@lists.infradead.org Signed-off-by: Juerg Haefliger Signed-off-by: Tycho Andersen --- arch/arm64/mm/flush.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/mm/flush.c b/arch/arm64/mm/flush.c index 21a8d828cbf4..e335e3fd4fca 100644 --- a/arch/arm64/mm/flush.c +++ b/arch/arm64/mm/flush.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -28,9 +29,15 @@ void sync_icache_aliases(void *kaddr, unsigned long len) { unsigned long addr = (unsigned long)kaddr; + unsigned long num_pages = XPFO_NUM_PAGES(addr, len); + void *mapping[num_pages]; if (icache_is_aliasing()) { + xpfo_temp_map(kaddr, len, mapping, + sizeof(mapping[0]) * num_pages); __clean_dcache_area_pou(kaddr, len); + xpfo_temp_unmap(kaddr, len, mapping, + sizeof(mapping[0]) * num_pages); __flush_icache_all(); } else { flush_icache_range(addr, addr + len);