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
3737 * Lower 12 bits encode the number of additional
3838 * pages to flush (in addition to the 'cur' page).
3939 */
40− if (diff >= HV_TLB_FLUSH_UNIT)
40+ if (diff >= HV_TLB_FLUSH_UNIT) {
4141 gva_list[gva_n] |= ~PAGE_MASK;
42− else if (diff)
42+ cur += HV_TLB_FLUSH_UNIT;
43+ } else if (diff) {
4344 gva_list[gva_n] |= (diff - 1) >> PAGE_SHIFT;
45+ cur = end;
46+ }
4447
45− cur += HV_TLB_FLUSH_UNIT;
4648 gva_n++;
4749
4850 } 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