public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/hyperv: Fix error pointer dereference
@ 2026-02-18 19:09 Ethan Tidmore
  2026-02-18 19:11 ` Ethan Tidmore
  0 siblings, 1 reply; 3+ messages in thread
From: Ethan Tidmore @ 2026-02-18 19:09 UTC (permalink / raw)
  To: K . Y . Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li,
	Saurabh Sengar
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Michael Kelley, x86, linux-hyperv, linux-kernel,
	Ethan Tidmore

The function idle_thread_get() can return an error pointer and is not
checked for it. Add check for error pointer.

Detected by Smatch:
arch/x86/hyperv/hv_vtl.c:126 hv_vtl_bringup_vcpu() error:
'idle' dereferencing possible ERR_PTR()

Fixes: 2b4b90e053a29 ("x86/hyperv: Use per cpu initial stack for vtl context")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
v2:
- Fixed typo.

 arch/x86/hyperv/hv_vtl.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/x86/hyperv/hv_vtl.c b/arch/x86/hyperv/hv_vtl.c
index c0edaed0efb3..9b6a9bc4ab76 100644
--- a/arch/x86/hyperv/hv_vtl.c
+++ b/arch/x86/hyperv/hv_vtl.c
@@ -110,7 +110,7 @@ static void hv_vtl_ap_entry(void)
 
 static int hv_vtl_bringup_vcpu(u32 target_vp_index, int cpu, u64 eip_ignored)
 {
-	u64 status;
+	u64 status, rsp, rip;
 	int ret = 0;
 	struct hv_enable_vp_vtl *input;
 	unsigned long irq_flags;
@@ -123,9 +123,11 @@ static int hv_vtl_bringup_vcpu(u32 target_vp_index, int cpu, u64 eip_ignored)
 	struct desc_struct *gdt;
 
 	struct task_struct *idle = idle_thread_get(cpu);
-	u64 rsp = (unsigned long)idle->thread.sp;
+	if (IS_ERR(idle))
+		return PTR_ERR(idle);
 
-	u64 rip = (u64)&hv_vtl_ap_entry;
+	rsp = (unsigned long)idle->thread.sp;
+	rip = (u64)&hv_vtl_ap_entry;
 
 	native_store_gdt(&gdt_ptr);
 	store_idt(&idt_ptr);
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/hyperv: Fix error pointer dereference
  2026-02-18 19:09 [PATCH] x86/hyperv: Fix error pointer dereference Ethan Tidmore
@ 2026-02-18 19:11 ` Ethan Tidmore
  2026-02-18 23:22   ` Wei Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Ethan Tidmore @ 2026-02-18 19:11 UTC (permalink / raw)
  To: Ethan Tidmore, K . Y . Srinivasan, Haiyang Zhang, Wei Liu,
	Dexuan Cui, Long Li, Saurabh Sengar
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H . Peter Anvin, Michael Kelley, x86, linux-hyperv, linux-kernel

On Wed Feb 18, 2026 at 1:09 PM CST, Ethan Tidmore wrote:
> The function idle_thread_get() can return an error pointer and is not
> checked for it. Add check for error pointer.
>
> Detected by Smatch:
> arch/x86/hyperv/hv_vtl.c:126 hv_vtl_bringup_vcpu() error:
> 'idle' dereferencing possible ERR_PTR()
>
> Fixes: 2b4b90e053a29 ("x86/hyperv: Use per cpu initial stack for vtl context")
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
> ---

Oops, forgot v2 header this is the v2.

Thanks,

ET

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/hyperv: Fix error pointer dereference
  2026-02-18 19:11 ` Ethan Tidmore
@ 2026-02-18 23:22   ` Wei Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Wei Liu @ 2026-02-18 23:22 UTC (permalink / raw)
  To: Ethan Tidmore
  Cc: K . Y . Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li,
	Saurabh Sengar, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, H . Peter Anvin, Michael Kelley, x86, linux-hyperv,
	linux-kernel

On Wed, Feb 18, 2026 at 01:11:18PM -0600, Ethan Tidmore wrote:
> On Wed Feb 18, 2026 at 1:09 PM CST, Ethan Tidmore wrote:
> > The function idle_thread_get() can return an error pointer and is not
> > checked for it. Add check for error pointer.
> >
> > Detected by Smatch:
> > arch/x86/hyperv/hv_vtl.c:126 hv_vtl_bringup_vcpu() error:
> > 'idle' dereferencing possible ERR_PTR()
> >
> > Fixes: 2b4b90e053a29 ("x86/hyperv: Use per cpu initial stack for vtl context")
> > Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
> > ---
> 
> Oops, forgot v2 header this is the v2.

Applied. Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-02-18 23:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-18 19:09 [PATCH] x86/hyperv: Fix error pointer dereference Ethan Tidmore
2026-02-18 19:11 ` Ethan Tidmore
2026-02-18 23:22   ` Wei Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox