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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DA787C6FD1F for ; Tue, 14 Mar 2023 17:46:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1D4ViK5FJDHGq5tFC2jnSU8rgwB1TiPd1MSW3zI7rfs=; b=NUGvlFngELIBt4 suGJXTbdSse7kU1dUfhwGS9SVbO49EAkn8xJjVdNk7aT9u6+wQzzo2L08ct72gsTs36fwM+t2CMkE tn8+4gcrFWaPIoa8wItzUm3PJiK+7NldqlcUqzS5kB2Tzb++cNlm8qHAXxEJLfSSbz9zSfHE7PQNl 9KeHghIeNfCaQiKdn7p8YnhgB/w6kU0uciIbJBKOUhywtqlzBK1KGtYjMOPgvHF5hccUxHnNKpfQQ daOxfd/02n29qwUBBHssX/e/Mi8akdeyBWJLUcDjukh7zzsbF8YAw/w3vDB935rSdDGyDmIQfoSYv qs0yFo4NjgYXKXIRckwg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pc8ia-00B3QE-2o; Tue, 14 Mar 2023 17:45:48 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pc7Yr-00AqPL-2r for linux-arm-kernel@lists.infradead.org; Tue, 14 Mar 2023 16:31:43 +0000 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 7BB3D6184D; 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") 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230314_093141_999211_A4B15D16 X-CRM114-Status: GOOD ( 19.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel