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=1796382493; b=3AngdvLzzim/jOkgl6Cu2CpcGKF6XqMZsQ/bQXcX6RLjbfB6h6DyntT5tVWtig4SnxrY /87RzzlPRGvqd9dE7jzHDCnI/6eKYm/dQFxkGGRnMGgnyyf8FQ82gjmqKEQnWDrD3EqhI SbMiO5FvuEPDzhSmYJLWs8Xiy2sxoa0aL04LVK9+8dDGg7KRDoHAq8emw06DISINkeFuq PpGvp8GlBr77XDH0qgSUTyg0sicu9ajwoT3rpc0kdL7Q5ZHV+cJPmvtByVdcYijYgW50C cgxClS5g4nZD0Zgd1St1+12X151NhST3IKM9Tf1xW8/+4p5qUEiq/b+oGcOwMQh33UA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382493; 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=9mb84SpAqZDRRSapqUGgkamrCndzzmkrvQyvWRTpvu4=; b=la2rGh/y0dcGgtRj+yupNLeSjWE4b1N1Q1XMuZoXukClO1RrH0rx0jPpMAt9/Gx2VOzc +aRgwCeWtKvw8aFgs5XNAzPYAap6ddPTgMxhutSTylgLPHutIfvNHSrPWfjNtcbq+/R/I 5lZJZYafk8KQ3D2quRZa7ZvdZyMEd1FLqB3Sw+Oz/fn4HzveSv6pd0aN0X3y4Ddg1W+Aa gr9zxwaDigzXji0vXRB2kGizvZpoY4U4u7KsjdHBkZMhRZ1kolmqBvDBtJB6NhKe/lLm7 2r/6BpgBpbs2cO7eM5WwqzO3MAwz2sSC+1Jh/ngbBjVfzZCtLTNepLBYU3ZTXypM5sw== 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=IyMPjUWo; 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 F38E5606A322; Fri, 4 Dec 2026 11:08:12 +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=IyMPjUWo Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6ED2F1F000C2; Fri, 4 Dec 2026 11:08:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382492; bh=9mb84SpAqZDRRSapqUGgkamrCndzzmkrvQyvWRTpvu4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IyMPjUWosXeigakvMQSXTSiNHtLY2QGIDTK6f7nYSWHt39llAdzl2kxbkwvpmDx+6 Hst5BVDn7k+bIsjgRWwYg82X5pb3vFk53ktEDcB21PTjk34Y1hu2nVL3GhyZdld04u pGbMXklusLR68yNs0vld0cARnGT9GgLQHFlqxnaQ= 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 6.18 478/703] KVM: PPC: Book3S HV: Take SRCU read lock around kvmppc_h_page_init() call Date: Fri, 4 Dec 2026 19:06:17 +0900 Message-ID: <20261204100640.517293672@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-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 @@ -1384,9 +1384,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;