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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0366C74A4B for ; Tue, 14 Mar 2023 16:31:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230394AbjCNQbz (ORCPT ); Tue, 14 Mar 2023 12:31:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229988AbjCNQbr (ORCPT ); Tue, 14 Mar 2023 12:31:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13A455653F; Tue, 14 Mar 2023 09:31:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7A78361847; Tue, 14 Mar 2023 16:31:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D989CC433EF; Tue, 14 Mar 2023 16:31:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678811500; bh=ARC9WBAhBVNF4Tztw+npvVi7tSsxTYJsQSXYXedfHHg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qj2EMqg+tWF6I0RiRIFJxaGmxwCo4aQ9Pwt/roF+/gI36ZhlwL2tqAM1P+PmBCf5Z c2FXor5ppSLyGiHzoTNmItOaOC/NGcfdw+uVUHuZxlHyudsqjWT5y/0kUYxlms86PX yqOj1HvKbbWmEofHGXiGeU75lV7OEtZkVum4Fe+LiYBzShRoVvnEn2CwmLuN5F3BSQ szjnOa1MG9n4VrEAljHEYnqeIF3erX2GMQAPCNYsZyQk7G688+wm4qomx9milYSwxE 1jW6l8zvArDZRUt/5CU/DcbXAE2+/tXW1/sKrwHoYggaKzVS0YE7AuVZTOYfAi4+r3 0XeVxW+WjIHOA== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pc7Yo-0001sY-Fs; Tue, 14 Mar 2023 16:31:38 +0000 Date: Tue, 14 Mar 2023 16:31:38 +0000 Message-ID: <86fsa7xpjp.wl-maz@kernel.org> From: Marc Zyngier To: David Matlack Cc: Oliver Upton , kvm@vger.kernel.org, James Morse , Suzuki K Poulose , Zenghui Yu , Will Deacon , Marcelo Tosatti , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, stable@vger.kernel.org, Sean Christopherson Subject: Re: [PATCH] KVM: arm64: Retry fault if vma_lookup() results become invalid In-Reply-To: <20230313235454.2964067-1-dmatlack@google.com> References: <20230313235454.2964067-1-dmatlack@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: dmatlack@google.com, oliver.upton@linux.dev, kvm@vger.kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, will@kernel.org, mtosatti@redhat.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, stable@vger.kernel.org, seanjc@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org [Dropping Christoffer's 11 year obsolete address...] On Mon, 13 Mar 2023 23:54:54 +0000, David Matlack wrote: > > Read mmu_invalidate_seq before dropping the mmap_lock so that KVM can > detect if the results of vma_lookup() (e.g. vma_shift) become stale > before it acquires kvm->mmu_lock. This fixes a theoretical bug where a > VMA could be changed by userspace after vma_lookup() and before KVM > reads the mmu_invalidate_seq, causing KVM to install page table entries > based on a (possibly) no-longer-valid vma_shift. > > Re-order the MMU cache top-up to earlier in user_mem_abort() so that it > is not done after KVM has read mmu_invalidate_seq (i.e. so as to avoid > inducing spurious fault retries). > > This bug has existed since KVM/ARM's inception. It's unlikely that any > sane userspace currently modifies VMAs in such a way as to trigger this > race. And even with directed testing I was unable to reproduce it. But a > sufficiently motivated host userspace might be able to exploit this > race. > > Fixes: 94f8e6418d39 ("KVM: ARM: Handle guest faults in KVM") Ah, good luck with that one! :D user_mem_abort() used to be so nice and simple at the time! And yet... > Cc: stable@vger.kernel.org > Reported-by: Sean Christopherson > Signed-off-by: David Matlack Reviewed-by: Marc Zyngier Oliver, how do you want to deal with this one? queue it right now? Or wait until the dust settles on my two other patches? I don't mind either way, I can either take it as part of the same series, or rebase my stuff on it. Thanks, M. -- Without deviation from the norm, progress is not possible.