When the 'start' parameter is >= 0xFF000000 on 32-bit systems, or >= 0xFFFFFFFF'FF000000 on 64-bit systems, fill_gva_list() gets into an infinite loop. With such inputs, 'cur' overflows after adding HV_TLB_FLUSH_UNIT and always compares as less than end. Memory is filled with guest virtual addresses until the system crashes. Fix this by never incrementing 'cur' to be larger than 'end'.
Unified · Split
| @@ -37,12 +37,14 @@ static inline int fill_gva_list(u64 gva_list[], int offset, · 36 unmodified lines | |||
| 37 | * Lower 12 bits encode the number of additional | 37 | * Lower 12 bits encode the number of additional |
| 38 | * pages to flush (in addition to the 'cur' page). | 38 | * pages to flush (in addition to the 'cur' page). |
| 39 | */ | 39 | */ |
| 40 | if (diff >= HV_TLB_FLUSH_UNIT) | 40 | if (diff >= HV_TLB_FLUSH_UNIT) { |
| 41 | gva_list[gva_n] |= ~PAGE_MASK; | 41 | gva_list[gva_n] |= ~PAGE_MASK; |
| 42 | else if (diff) | 42 | cur += HV_TLB_FLUSH_UNIT; |
| 43 | } else if (diff) { | ||
| 43 | gva_list[gva_n] |= (diff - 1) >> PAGE_SHIFT; | 44 | gva_list[gva_n] |= (diff - 1) >> PAGE_SHIFT; |
| 45 | cur = end; | ||
| 46 | } | ||
| 44 | 47 | ||
| 45 | cur += HV_TLB_FLUSH_UNIT; | ||
| 46 | gva_n++; | 48 | gva_n++; |
| 47 | 49 | ||
| 48 | } while (cur < end); | 50 | } while (cur < end); |