Skip to content

Commit 98fb4e5

Browse files
committed
lguest: fix guest kernel stack overflow when TF bit set.
The symptoms are that running gdb on a binary causes the guest to overflow the kernels stack (after some period of time), resulting in it finally being killed with a "Bad address" message. Reported-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 4623c28 commit 98fb4e5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/lguest/interrupts_and_traps.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,16 @@ static void set_guest_interrupt(struct lg_cpu *cpu, u32 lo, u32 hi,
139139
cpu->regs->cs = (__KERNEL_CS|GUEST_PL);
140140
cpu->regs->eip = idt_address(lo, hi);
141141

142+
/*
143+
* Trapping always clears these flags:
144+
* TF: Trap flag
145+
* VM: Virtual 8086 mode
146+
* RF: Resume
147+
* NT: Nested task.
148+
*/
149+
cpu->regs->eflags &=
150+
~(X86_EFLAGS_TF|X86_EFLAGS_VM|X86_EFLAGS_RF|X86_EFLAGS_NT);
151+
142152
/*
143153
* There are two kinds of interrupt handlers: 0xE is an "interrupt
144154
* gate" which expects interrupts to be disabled on entry.

0 commit comments

Comments
 (0)