Skip to contentSkip to conversation

Drivers: hv: Fix bad pointer dereference in hv_get_partition_id

PATCH Applied Nuno Das Neves 5 participants 7 messages Apr 1, 2025 – Apr 7, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Drivers: hv: Fix bad pointer dereference in hv_get_partition_id

'output' is already a pointer to the output argument, it should be passed directly to hv_do_hypercall() without the '&' operator.

---
This patch is a fixup for:
e96204e5e96e hyperv: Move hv_current_partition_id to arch-generic code

 drivers/hv/hv_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/hv_common.c +1 -1
index b3b11be11650..a7d7494feaca 100644
@@ -307,7 +307,7 @@ void __init hv_get_partition_id(void)
 
 	local_irq_save(flags);
 	output = *this_cpu_ptr(hyperv_pcpu_input_arg);
-	status = hv_do_hypercall(HVCALL_GET_PARTITION_ID, NULL, &output);
+	status = hv_do_hypercall(HVCALL_GET_PARTITION_ID, NULL, output);
 	pt_id = output->partition_id;
 	local_irq_restore(flags);
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw

From: Nuno Das Neves <[email protected]> Sent: Tuesday, April 1, 2025 10:32 AM

Quoted 26 lines

'output' is already a pointer to the output argument, it should be passed directly to hv_do_hypercall() without the '&' operator.

---
This patch is a fixup for:
e96204e5e96e hyperv: Move hv_current_partition_id to arch-generic code

 drivers/hv/hv_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/hv_common.c +1 -2
index b3b11be11650..a7d7494feaca 100644
@@ -307,7 +307,7 @@ void __init hv_get_partition_id(void)
 
 	local_irq_save(flags);
 	output = *this_cpu_ptr(hyperv_pcpu_input_arg);
-	status = hv_do_hypercall(HVCALL_GET_PARTITION_ID, NULL, &output);
+	status = hv_do_hypercall(HVCALL_GET_PARTITION_ID, NULL, output);
 	pt_id = output->partition_id;
 	local_irq_restore(flags);
 
--
Quoted 1 line

2.34.1

I should have caught that when I reviewed the original patch! :-(

Trying again,

#2 lore raw
In reply to Nuno Das Neves
Quoted 7 lines · Nuno Das Neves

'output' is already a pointer to the output argument, it should be passed directly to hv_do_hypercall() without the '&' operator.

---
This patch is a fixup for:
e96204e5e96e hyperv: Move hv_current_partition_id to arch-generic code

You can add Fixes: tag, so that it gets ported to previous kernel, in case, it does not make it to 6.14.

Regards,
Naman

Quoted 17 lines
  drivers/hv/hv_common.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/hv_common.c +1 -1
index b3b11be11650..a7d7494feaca 100644
@@ -307,7 +307,7 @@ void __init hv_get_partition_id(void)
 
  	local_irq_save(flags);
  	output = *this_cpu_ptr(hyperv_pcpu_input_arg);
-	status = hv_do_hypercall(HVCALL_GET_PARTITION_ID, NULL, &output);
+	status = hv_do_hypercall(HVCALL_GET_PARTITION_ID, NULL, output);
  	pt_id = output->partition_id;
  	local_irq_restore(flags);
 
maintainer
#3 lore raw
Quoted 6 lines · Naman Jain
Quoted 3 lines · Nuno Das Neves

'output' is already a pointer to the output argument, it should be passed directly to hv_do_hypercall() without the '&' operator.

Quoted 7 lines
Quoted 4 lines

---
This patch is a fixup for:
e96204e5e96e hyperv: Move hv_current_partition_id to arch-generic code

You can add Fixes: tag, so that it gets ported to previous kernel, in case, it does not make it to 6.14.

This does not need to be ported to older kernels because the bug was never released.

Wei.

Quoted 21 lines

Regards,
Naman

Quoted 15 lines
  drivers/hv/hv_common.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/hv_common.c +1 -1
index b3b11be11650..a7d7494feaca 100644
@@ -307,7 +307,7 @@ void __init hv_get_partition_id(void)
  	local_irq_save(flags);
  	output = *this_cpu_ptr(hyperv_pcpu_input_arg);
-	status = hv_do_hypercall(HVCALL_GET_PARTITION_ID, NULL, &output);
+	status = hv_do_hypercall(HVCALL_GET_PARTITION_ID, NULL, output);
  	pt_id = output->partition_id;
  	local_irq_restore(flags);
maintainer
#4 lore raw
Quoted 12 lines · Wei Liu
Quoted 11 lines · Naman Jain
Quoted 7 lines · Nuno Das Neves

'output' is already a pointer to the output argument, it should be passed directly to hv_do_hypercall() without the '&' operator.

---
This patch is a fixup for:
e96204e5e96e hyperv: Move hv_current_partition_id to arch-generic code

Quoted 5 lines
Quoted 2 lines

You can add Fixes: tag, so that it gets ported to previous kernel, in case, it does not make it to 6.14.

This does not need to be ported to older kernels because the bug was never released.

To be clear that was just a passing comment. I'm not against adding a Fixes tag. I've done that while applying this patch.

Thanks,
Wei.

maintainer Applied
#6 lore raw
In reply to Nuno Das Neves
Quoted 4 lines · Nuno Das Neves

'output' is already a pointer to the output argument, it should be passed directly to hv_do_hypercall() without the '&' operator.

Applied to hyperv-fixes. Thanks.

Quoted 23 lines

---
This patch is a fixup for:
e96204e5e96e hyperv: Move hv_current_partition_id to arch-generic code

 drivers/hv/hv_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/hv_common.c +1 -1
index b3b11be11650..a7d7494feaca 100644
@@ -307,7 +307,7 @@ void __init hv_get_partition_id(void)
 
 	local_irq_save(flags);
 	output = *this_cpu_ptr(hyperv_pcpu_input_arg);
-	status = hv_do_hypercall(HVCALL_GET_PARTITION_ID, NULL, &output);
+	status = hv_do_hypercall(HVCALL_GET_PARTITION_ID, NULL, output);
 	pt_id = output->partition_id;
 	local_irq_restore(flags);
 
Signature · 1 line
2.34.1