From mboxrd@z Thu Jan 1 00:00:00 1970 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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 89E4BC55179 for ; Fri, 30 Oct 2020 16:00:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EFA0420A8B for ; Fri, 30 Oct 2020 16:00:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EFA0420A8B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3AC6A6B0073; Fri, 30 Oct 2020 12:00:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3846E6B0075; Fri, 30 Oct 2020 12:00:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 272716B007B; Fri, 30 Oct 2020 12:00:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id EFB7E6B0073 for ; Fri, 30 Oct 2020 12:00:15 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 902C6181AEF15 for ; Fri, 30 Oct 2020 16:00:15 +0000 (UTC) X-FDA: 77429053590.17.story67_1e1483a27297 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 6C3A2180D0180 for ; Fri, 30 Oct 2020 16:00:15 +0000 (UTC) X-HE-Tag: story67_1e1483a27297 X-Filterd-Recvd-Size: 3650 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Fri, 30 Oct 2020 16:00:14 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C38911435; Fri, 30 Oct 2020 09:00:13 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.53.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E2B453F719; Fri, 30 Oct 2020 09:00:06 -0700 (PDT) Date: Fri, 30 Oct 2020 16:00:04 +0000 From: Mark Rutland To: Jann Horn Cc: Marco Elver , Andrew Morton , Alexander Potapenko , "H . Peter Anvin" , "Paul E . McKenney" , Andrey Konovalov , Andrey Ryabinin , Andy Lutomirski , Borislav Petkov , Catalin Marinas , Christoph Lameter , Dave Hansen , David Rientjes , Dmitry Vyukov , Eric Dumazet , Greg Kroah-Hartman , Hillf Danton , Ingo Molnar , Jonathan Cameron , Jonathan Corbet , Joonsoo Kim , joern@purestorage.com, Kees Cook , Pekka Enberg , Peter Zijlstra , SeongJae Park , Thomas Gleixner , Vlastimil Babka , Will Deacon , the arch/x86 maintainers , "open list:DOCUMENTATION" , kernel list , kasan-dev , Linux ARM , Linux-MM Subject: Re: [PATCH v6 3/9] arm64, kfence: enable KFENCE for ARM64 Message-ID: <20201030160004.GE50718@C02TD0UTHF1T.local> References: <20201029131649.182037-1-elver@google.com> <20201029131649.182037-4-elver@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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: On Fri, Oct 30, 2020 at 03:49:26AM +0100, Jann Horn wrote: > On Thu, Oct 29, 2020 at 2:17 PM Marco Elver wrote: > > @@ -312,6 +313,9 @@ static void __do_kernel_fault(unsigned long addr, unsigned int esr, > > "Ignoring spurious kernel translation fault at virtual address %016lx\n", addr)) > > return; > > > > + if (kfence_handle_page_fault(addr)) > > + return; > > As in the X86 case, we may want to ensure that this doesn't run for > permission faults, only for non-present pages. Maybe move this down > into the third branch of the "if" block below (neither permission > fault nor NULL deref)? I think that'd make sense. Those cases *should* be mutually exclusive, but it'd be more robust to do the KFENCE checks in that last block so that if something goes wrong wrong within KFENCE we can't get stuck in a loop failing to service an instruction abort or similar. Either that, or factor out an is_el1_translation_fault() and only do the KFENCE check and is_spurious_el1_translation_fault() check under that. Thanks, Mark.