Skip to content

Commit 0c7fbae

Browse files
t-8chfrankjaa
authored andcommitted
KVM: s390: Don't use %pK through debug printing
Restricted pointers ("%pK") are only meant to be used when directly printing to a file from task context. Otherwise it can unintentionally expose security sensitive, raw pointer values. Use regular pointer formatting instead. Link: https://lore.kernel.org/lkml/20250113171731-dc10e3c1-da64-4af0-b767-7c7070468023@linutronix.de/ Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de> Reviewed-by: Michael Mueller <mimu@linux.ibm.com> Tested-by: Michael Mueller <mimu@linux.ibm.com> Link: https://lore.kernel.org/r/20250217-restricted-pointers-s390-v1-2-0e4ace75d8aa@linutronix.de Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Message-ID: <20250217-restricted-pointers-s390-v1-2-0e4ace75d8aa@linutronix.de>
1 parent 6c9567e commit 0c7fbae

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

arch/s390/kvm/intercept.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static int handle_validity(struct kvm_vcpu *vcpu)
9595

9696
vcpu->stat.exit_validity++;
9797
trace_kvm_s390_intercept_validity(vcpu, viwhy);
98-
KVM_EVENT(3, "validity intercept 0x%x for pid %u (kvm 0x%pK)", viwhy,
98+
KVM_EVENT(3, "validity intercept 0x%x for pid %u (kvm 0x%p)", viwhy,
9999
current->pid, vcpu->kvm);
100100

101101
/* do not warn on invalid runtime instrumentation mode */

arch/s390/kvm/interrupt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3161,7 +3161,7 @@ void kvm_s390_gisa_clear(struct kvm *kvm)
31613161
if (!gi->origin)
31623162
return;
31633163
gisa_clear_ipm(gi->origin);
3164-
VM_EVENT(kvm, 3, "gisa 0x%pK cleared", gi->origin);
3164+
VM_EVENT(kvm, 3, "gisa 0x%p cleared", gi->origin);
31653165
}
31663166

31673167
void kvm_s390_gisa_init(struct kvm *kvm)
@@ -3178,7 +3178,7 @@ void kvm_s390_gisa_init(struct kvm *kvm)
31783178
gi->timer.function = gisa_vcpu_kicker;
31793179
memset(gi->origin, 0, sizeof(struct kvm_s390_gisa));
31803180
gi->origin->next_alert = (u32)virt_to_phys(gi->origin);
3181-
VM_EVENT(kvm, 3, "gisa 0x%pK initialized", gi->origin);
3181+
VM_EVENT(kvm, 3, "gisa 0x%p initialized", gi->origin);
31823182
}
31833183

31843184
void kvm_s390_gisa_enable(struct kvm *kvm)
@@ -3219,7 +3219,7 @@ void kvm_s390_gisa_destroy(struct kvm *kvm)
32193219
process_gib_alert_list();
32203220
hrtimer_cancel(&gi->timer);
32213221
gi->origin = NULL;
3222-
VM_EVENT(kvm, 3, "gisa 0x%pK destroyed", gisa);
3222+
VM_EVENT(kvm, 3, "gisa 0x%p destroyed", gisa);
32233223
}
32243224

32253225
void kvm_s390_gisa_disable(struct kvm *kvm)
@@ -3468,7 +3468,7 @@ int __init kvm_s390_gib_init(u8 nisc)
34683468
}
34693469
}
34703470

3471-
KVM_EVENT(3, "gib 0x%pK (nisc=%d) initialized", gib, gib->nisc);
3471+
KVM_EVENT(3, "gib 0x%p (nisc=%d) initialized", gib, gib->nisc);
34723472
goto out;
34733473

34743474
out_unreg_gal:

arch/s390/kvm/kvm-s390.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ static int kvm_s390_set_mem_control(struct kvm *kvm, struct kvm_device_attr *att
10201020
}
10211021
mutex_unlock(&kvm->lock);
10221022
VM_EVENT(kvm, 3, "SET: max guest address: %lu", new_limit);
1023-
VM_EVENT(kvm, 3, "New guest asce: 0x%pK",
1023+
VM_EVENT(kvm, 3, "New guest asce: 0x%p",
10241024
(void *) kvm->arch.gmap->asce);
10251025
break;
10261026
}
@@ -3464,7 +3464,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
34643464
kvm_s390_gisa_init(kvm);
34653465
INIT_LIST_HEAD(&kvm->arch.pv.need_cleanup);
34663466
kvm->arch.pv.set_aside = NULL;
3467-
KVM_EVENT(3, "vm 0x%pK created by pid %u", kvm, current->pid);
3467+
KVM_EVENT(3, "vm 0x%p created by pid %u", kvm, current->pid);
34683468

34693469
return 0;
34703470
out_err:
@@ -3527,7 +3527,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
35273527
kvm_s390_destroy_adapters(kvm);
35283528
kvm_s390_clear_float_irqs(kvm);
35293529
kvm_s390_vsie_destroy(kvm);
3530-
KVM_EVENT(3, "vm 0x%pK destroyed", kvm);
3530+
KVM_EVENT(3, "vm 0x%p destroyed", kvm);
35313531
}
35323532

35333533
/* Section: vcpu related */
@@ -3648,7 +3648,7 @@ static int sca_switch_to_extended(struct kvm *kvm)
36483648

36493649
free_page((unsigned long)old_sca);
36503650

3651-
VM_EVENT(kvm, 2, "Switched to ESCA (0x%pK -> 0x%pK)",
3651+
VM_EVENT(kvm, 2, "Switched to ESCA (0x%p -> 0x%p)",
36523652
old_sca, kvm->arch.sca);
36533653
return 0;
36543654
}
@@ -4025,7 +4025,7 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
40254025
goto out_free_sie_block;
40264026
}
40274027

4028-
VM_EVENT(vcpu->kvm, 3, "create cpu %d at 0x%pK, sie block at 0x%pK",
4028+
VM_EVENT(vcpu->kvm, 3, "create cpu %d at 0x%p, sie block at 0x%p",
40294029
vcpu->vcpu_id, vcpu, vcpu->arch.sie_block);
40304030
trace_kvm_s390_create_vcpu(vcpu->vcpu_id, vcpu, vcpu->arch.sie_block);
40314031

0 commit comments

Comments
 (0)