History

x86/hyper-v: Fix overflow bug in fill_gva_list()

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'.

Tianyu Lan committed 7 years ago

Commit 4030b4c1 parent 9b8bd471 file · +5 −3Browse files

Unified · Split

arch/x86/hyperv/mmu.c+5−3
@@ -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 additional37 * 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);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t