Skip to content

Commit fe75233

Browse files
committed
KVM: s390: vsie: fix race during shadow creation
Right now it is possible to see gmap->private being zero in kvm_s390_vsie_gmap_notifier resulting in a crash. This is due to the fact that we add gmap->private == kvm after creation: static int acquire_gmap_shadow(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) { [...] gmap = gmap_shadow(vcpu->arch.gmap, asce, edat); if (IS_ERR(gmap)) return PTR_ERR(gmap); gmap->private = vcpu->kvm; Let children inherit the private field of the parent. Reported-by: Marc Hartmayer <[email protected]> Fixes: a3508fb ("KVM: s390: vsie: initial support for nested virtualization") Cc: <[email protected]> Cc: David Hildenbrand <[email protected]> Reviewed-by: Janosch Frank <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Reviewed-by: Claudio Imbrenda <[email protected]> Signed-off-by: Christian Borntraeger <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 4cdf351 commit fe75233

File tree

2 files changed

+1
-1
lines changed

2 files changed

+1
-1
lines changed

arch/s390/kvm/vsie.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,6 @@ static int acquire_gmap_shadow(struct kvm_vcpu *vcpu,
12201220
gmap = gmap_shadow(vcpu->arch.gmap, asce, edat);
12211221
if (IS_ERR(gmap))
12221222
return PTR_ERR(gmap);
1223-
gmap->private = vcpu->kvm;
12241223
vcpu->kvm->stat.gmap_shadow_create++;
12251224
WRITE_ONCE(vsie_page->gmap, gmap);
12261225
return 0;

arch/s390/mm/gmap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,7 @@ struct gmap *gmap_shadow(struct gmap *parent, unsigned long asce,
16911691
return ERR_PTR(-ENOMEM);
16921692
new->mm = parent->mm;
16931693
new->parent = gmap_get(parent);
1694+
new->private = parent->private;
16941695
new->orig_asce = asce;
16951696
new->edat_level = edat_level;
16961697
new->initialized = false;

0 commit comments

Comments
 (0)