From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796381122; b=Tgwss5Crqu4eTDuUtHFV2Jr11ZGs/StcizFmv9P0PVaGj/f7e8J0Sar4pTPnb1i7BtEf z/oI7gzMrd1qaS9/rWZSAmlhJ6A4nRsxSxPOEHMCVoyXJnn8p+BijTUCMSnmUFkTjqyg5 tXpwfwHKjg7OkFFQj8RB00F2hVBo54utPxPfvmdxM0uE/R2d0M8eEx27j67z8cwJfTmsR TA4vnvhSpvalpdvd+sSIAKY8qtZdjUrW81OgcEQUwcIgIb3MblQYA8NYx4AsJ0r3LQyp/ odWSIljqY14QnhrP92PPqHYv2OEn9hqg6Jn6EhPUyQ0T+snU1kgir2nrJiD3wxgd1Rw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381122; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=ae/KfnQerJvXQzIc3X8XfjXulmjEU/gDsItgsdAz9mM=; b=bWqIdCbKiPUc2F1m9djD4ZELXav+HCR4ABcHLaXlhRdhqrulGR12HfAJpOkgoYD4Hojp AKGiXCkY4cbBXHgggCbz9Zoqz/1G/WUC15zpeQTvEFt0ICOPHaVZd8oEjmuKrNrGIa1Oj PCNSP6GSWbyDkk8oOn2tRPwrcmi8sBVBaHznZobuIy7FAv6gsslyR7mlEfPj86eypWB3c 7wNwhjbpyS1c9RhqyKyKGyFMAHyXQCRnnwQa0xjkZb03jyODzb3jEXe/0tOC/LwgSGye1 6EdYOTQL8uMeYevTPXxV7zwWSx7Wdlc3cxyNoTmyN8TxoUxHi3yONze8JOHvAXcsrhw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=1SVYtURR; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4E78606A330; Fri, 4 Dec 2026 10:45:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=1SVYtURR Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B6611F00934; Fri, 4 Dec 2026 10:45:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381122; bh=ae/KfnQerJvXQzIc3X8XfjXulmjEU/gDsItgsdAz9mM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1SVYtURRY6ILzjP44HbWdo5eYkpJtCGaSEXvqIjjyKO9LO6Be9NhsjDEIbiTPsWVv cl4rz5F8f2KKn0hsqBI0SoUHq+Tj4Qz1UvWRNp1VI7moVh33E8z7lSYw0npRyzZp8F WaqwvLl+QKGPOGTfwlA5QmHePyp99OTP264NI7aM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Gautam Menghani , "Ritesh Harjani (IBM)" , Madhavan Srinivasan Subject: [PATCH 7.3 531/742] KVM: PPC: Book3S HV: Take SRCU read lock around kvmppc_h_page_init() call Date: Fri, 4 Dec 2026 19:06:35 +0900 Message-ID: <20261204100649.279846381@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gautam Menghani commit b04be22bf6ea06b92bff7850328a8057b8d964ae upstream. Since there is no srcu read lock around kvmppc_h_page_init(), a "suspicious rcu_dereference_check() usage" can be triggered by running host linux with CONFIG_PROVE_RCU=y and the following code in the guest: plpar_hcall_norets(H_PAGE_INIT, H_ZERO_PAGE, phys_addr, 0); ============================= WARNING: suspicious RCU usage 7.0.0-dirty #227 Not tainted ----------------------------- ./include/linux/kvm_host.h:1074 suspicious rcu_dereference_check() usage! other info that might help us debug this: rcu_scheduler_active = 2, debug_locks = 1 1 lock held by qemu-system-ppc/2093: #0: c000000354197ab0 (&vcpu->mutex){+.+.}-{3:3}, at: kvm_vcpu_ioctl+0x10c/0xaf0 stack backtrace: CPU: 30 UID: 0 PID: 2093 Comm: qemu-system-ppc Not tainted 7.0.0-dirty #227 PREEMPT(full) Hardware name: IBM,9080-HEX POWER10 (architected) 0x800200 0xf000006 of:IBM,FW1060.60 (NH1060_158) hv:phyp pSeries Call Trace: [c00000033e1bf430] [c000000001b3dbd4] dump_stack_lvl+0xc8/0x130 (unreliable) [c00000033e1bf470] [c0000000003da964] lockdep_rcu_suspicious+0x1f4/0x290 [c00000033e1bf520] [c000000000231424] gfn_to_memslot+0x1b4/0x1c0 [c00000033e1bf560] [c00000000023637c] kvm_clear_guest+0x9c/0x110 [c00000033e1bf5c0] [c0000000002714a4] kvmppc_h_page_init+0x160/0x1a0 [c00000033e1bf610] [c00000000026c040] kvmppc_pseries_do_hcall+0x1930/0x1940 [c00000033e1bf6d0] [c00000000026fb18] kvmppc_vcpu_run_hv+0x268/0x800 [c00000033e1bf7a0] [c000000000246b30] kvmppc_vcpu_run+0x30/0x50 [c00000033e1bf7c0] [c000000000241ed4] kvm_arch_vcpu_ioctl_run+0x364/0x530 [c00000033e1bf860] [c00000000022b870] kvm_vcpu_ioctl+0x1b0/0xaf0 [c00000033e1bfa50] [c0000000009b4514] sys_ioctl+0x144/0x190 [c00000033e1bfab0] [c000000000034330] system_call_exception+0x170/0x370 [c00000033e1bfe50] [c00000000000d05c] system_call_vectored_common+0x15c/0x2ec Fix this by taking a srcu read lock around kvmppc_h_page_init(). Fixes: 2d34d1c3bbfd ("KVM: PPC: Book3S HV: Implement virtual mode H_PAGE_INIT handler") Cc: stable@vger.kernel.org # 5.2+ Signed-off-by: Gautam Menghani Reviewed-by: Ritesh Harjani (IBM) Signed-off-by: Madhavan Srinivasan Link: https://patch.msgid.link/20261012082922.218799-5-gautam@linux.ibm.com Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kvm/book3s_hv.c | 2 ++ 1 file changed, 2 insertions(+) --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -1388,9 +1388,11 @@ int kvmppc_pseries_do_hcall(struct kvm_v ret = kvmhv_copy_tofrom_guest_nested(vcpu); break; case H_PAGE_INIT: + idx = srcu_read_lock(&kvm->srcu); ret = kvmppc_h_page_init(vcpu, kvmppc_get_gpr(vcpu, 4), kvmppc_get_gpr(vcpu, 5), kvmppc_get_gpr(vcpu, 6)); + srcu_read_unlock(&kvm->srcu, idx); break; case H_SVM_PAGE_IN: ret = H_UNSUPPORTED;