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=1796383973; b=vshxlzebQM8HevqMmxwoGs2Sn/2wmaPTfO6qcFt05DyAmJmcy4eOfjTcjRJ3lLqFa8u2 ZRdeNjJh15ea53QqIvSmIG85oPUHAB5bq00WUazY+hP22FA5JjCdY/GFYKdTdnMIkmnSP 5bDRWvfL6cR+GY8c4Fhfxd2cSiRqG7eKQnmgNwINvYg16xs3BhNxdau/PE++vM0xWzCO6 IUo8CaS+M1eW4C9cCUJFuLSO6fX2IcUWZX/hiwBeC2/Uns5DeYFIFPrGdkj4bOrby+cnz mfvU4sHJjvytHRrZ3iE7m9hKrhX93QnnOXrUUpIQYaU5/VMeXzAlKxT6qknaPpZxEbQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383973; 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=7H7fV1G39xFKZ6IYXV47fPR89q+iTCbtImF2ZcBFPvg=; b=hCQVJFxKchd+GRnu8ywxYHNZeksCCZvtGP4qac5UA6PXY0MpE/JJnP5cH3C83RbPr2J3 er4dKPz3IDaUQHub3nHdlUDz0BLf7c8lYgGCkT9E/r0iyPs9Xe+FsZKNCpF1jBfsjbLS8 1CGFtOAYZX2fLzLTZ5ts5RuiastAAxYsaRcYpoUdqpUf2+zimhhupG3+H4NWNw3hURN5e +bMo/8P78GDPz8pFBaGXqDfTy9OwcqIG2TbJLEpfnRZoVgrh6ctmOaVlaajFU6fR/RgK/ YPkRe4MRcjfDoFcW0xRK2MYITOL37miEwdGdCFRHjztq6twGgN2A1wx4ib28kiVvoaA== 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=fvs13hNB; 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 B610E606A68E; Fri, 4 Dec 2026 11:32:53 +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=fvs13hNB Received: by smtp.kernel.org (Postfix) with ESMTPSA id 217491F000C2; Fri, 4 Dec 2026 11:32:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383973; bh=7H7fV1G39xFKZ6IYXV47fPR89q+iTCbtImF2ZcBFPvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fvs13hNB+N5OTI3lqcRKXwof12RBgKoRyo3xa3/JeQ/oF9rsbzildssqsVT4mvsZ+ 6qPgnBQwjL1/2OxzmqYTqIi60bodcoD20BzCnjGoVgfvGKCvUsJ/4rCbTQXjtETFGR k8WSeClrqdX1Z/6pEzeJAk3w6L2CihWDLp7avudQ= 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.12 416/555] KVM: PPC: Book3S HV: Take SRCU read lock around kvmppc_h_page_init() call Date: Fri, 4 Dec 2026 19:07:39 +0900 Message-ID: <20261204100625.561964725@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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.12-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 @@ -1368,9 +1368,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;