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 D3FADC7618E for ; Thu, 16 Mar 2023 17:47:02 +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:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=3sySQ6nqZ/xtLmpbg4LG/AvlmhHkBE/BVIp2gYMx6gI=; b=pl8bM99weAfTfv CQ/R7tMe+8qQxDgGvrPMhhzFvE+6rOUqsY649PIiwpQpFfAsHWzs4nmIfOFVJX3fEct7fTzwsCyAW JfYgRLygDtKyuPN3BfGG7gkql9Y901f6+jRlXaaRchKWgSBdVIC4k9h1jOGvBY7mCDRzI7tf805DN rto9VJR+MZyAwM8xNwYFd2s6K2Z6k00t9OgHRgwIsg+5ulcPfIQREDFXx1R15v0ZWiHba0gnyMy3F gW47JTSathhAK/Fd6QjBkMTo9oWhG0/HTWpNpZteOi3wyhFMh7fTpkkllg0MB1cZoC7yweO/3EsLr CwexjocLe3q1CisX70+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pcrfs-00HAIz-1U; Thu, 16 Mar 2023 17:46:00 +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 1pcrfl-00HAHW-31 for linux-arm-kernel@lists.infradead.org; Thu, 16 Mar 2023 17:45:58 +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 4DB83620D4; Thu, 16 Mar 2023 17:45:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A556BC433EF; Thu, 16 Mar 2023 17:45:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678988752; bh=N1P01DTJd4uVjYfwCW0Upba7xUoZtVgRhAG/ukULUy4=; h=From:To:Cc:Subject:Date:From; b=dL9Fb4tR+LyaksLVWeq3nNK5szOJaEghNyl5aontm0qutNQk3UavbeNDCgco3tih2 nqCmWVjP1lyWFHsZsCnq4CsuiqQGqnGL2v17HFiQuosE827tjH/Dh+BNrI0nIrlDUM b7Rd5Aquz23nUpC6Wv8GAZZqTNP+cWMAcOukIuDuj/wrTBzUL+6PgD5EJFyS/nimZF qgvULMGVIM/jj2Ah7pbKZiP51RFFRkpIHnSM3ua2SP8e9rJCNXPsSkgPI20k6wSsG6 iE0XAWVJf8yjxEdxFFEp7GWNY28Mk+CgKiRIsgQvAMdh0xFvZEIN74m4378GEeTqKP t08LcnqGoMNdA== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pcrfi-000eUs-DM; Thu, 16 Mar 2023 17:45:50 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Cc: James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Ard Biesheuvel , Will Deacon , Quentin Perret , Sean Christopherson , David Matlack Subject: [PATCH v2 0/2] KVM: arm64: Plug a couple of MM races Date: Thu, 16 Mar 2023 17:45:44 +0000 Message-Id: <20230316174546.3777507-1-maz@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, ardb@kernel.org, will@kernel.org, qperret@google.com, seanjc@google.com, dmatlack@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-20230316_104554_049956_869926F5 X-CRM114-Status: GOOD ( 16.91 ) 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 Ard recently reported a really odd warning generated with KASAN, where the page table walker we use to inspect the userspace page tables was going into the weeds and accessing something that was looking totally unrelated (and previously freed). Will and I spent quite some time looking into it, and while we were not able to reproduce the issue, we were able to spot at least a couple of issues that could partially explain the issue. The first course of action is to disable interrupts while walking the userspace PTs. This prevents exit_mmap() from tearing down these PTs by blocking the IPI. We also fail gracefully if the IPI won the race and killed the page tables before we started the walk. The second issue is to not use a VMA pointer that was obtained with the mmap_read_lock held after that lock has been released. There is no guarantee that it is still valid. I've earmarked both for stable, though I expect backporting this to older revisions of the kernel could be... interesting. * From v1[1]: - Return -EAGAIN from get_user_mapping_size() when the mapping is gone instead of -EFAULT which would be fatal (which is still returned in cases that are not expected to be seen). Other error codes can also be returned from kvm_pgtable_get_leaf(), but always in conditions that are rather bad. - Rebased on top of kvmarm/fixes which already contains David's own MMU fix. [1] https://lore.kernel.org/r/20230313091425.1962708-1-maz@kernel.org Marc Zyngier (2): KVM: arm64: Disable interrupts while walking userspace PTs KVM: arm64: Check for kvm_vma_mte_allowed in the critical section arch/arm64/kvm/mmu.c | 53 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 9 deletions(-) -- 2.34.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel