]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: s390: Fix dat_crste_walk_range() early return
authorClaudio Imbrenda <imbrenda@linux.ibm.com>
Thu, 2 Jul 2026 15:24:05 +0000 (17:24 +0200)
committerChristian Borntraeger <borntraeger@linux.ibm.com>
Thu, 9 Jul 2026 08:26:10 +0000 (10:26 +0200)
If a walk entry handler for a lower level returns a value,
dat_crste_walk_range() will not return immediately, but instead loop
again and move to the next entry.

This means that some entries are potentially skipped, and early return
is ignored. Skipped entries might lead to all kinds of issues, given
that the caller expects them to not be skipped. Early return is often
used to interrupt a walk when a rescheduling is needed; if it is
ignored it can lead to stalls.

Fix by breaking from the loop immediately if the walk to a lower level
returned non-zero.

Fixes: 2db149a0a6c5 ("KVM: s390: KVM page table management functions: walks")
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
arch/s390/kvm/dat.c

index 5f1960ec982d045829a92abcc4a84d921ae3e9c7..ed4259d17629543b95a9691aea62f7075b2fe5aa 100644 (file)
@@ -570,6 +570,8 @@ static long dat_crste_walk_range(gfn_t start, gfn_t end, struct crst_table *tabl
                        else if (walk->ops->pte_entry)
                                rc = dat_pte_walk_range(max(start, cur), min(end, next),
                                                        dereference_pmd(crste.pmd), walk);
+                       if (rc)
+                               break;
                }
        }
        return rc;