[PATCH v2 15/20] KVM: s390: vsie: Guard against invalid CPU address
Christoph Schlameuss <[email protected]>
| Newsgroups | org.kernel.vger.linux-s390,org.kernel.vger.kvm |
|---|---|
| Message-ID | <[email protected]> |
Inject a specification interrupt if the CPU address is above 255. It would be possible to implement a finer check here to guard against CPU addresses over 63 when a BSCA is used. But this minimal check is sufficient to guard against out-of-bounds accesses. The architecture allows CPU addresses up to 255 for ESCA configurations, so this check ensures compliance with architectural limits. Signed-off-by: Christoph Schlameuss <[email protected]> --- arch/s390/kvm/vsie.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c index 6cd8eee9a503..844ffd3244fe 100644 --- a/arch/s390/kvm/vsie.c +++ b/arch/s390/kvm/vsie.c @@ -2167,6 +2167,11 @@ int kvm_s390_handle_vsie(struct kvm_vcpu *vcpu) return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); scb_o = (struct kvm_s390_sie_block *)phys_to_virt(scb_hpa); + if (scb_o->icpua >= KVM_S390_MAX_VSIE_VCPUS) { + rc = kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); + goto out_unpin; + } + if (!use_ssca(vcpu->kvm, scb_o)) { /* get the vsie_page with pinned scb_o */ vsie_page = get_vsie_page(vcpu, scb_addr); -- 2.55.0