From c7317d4dc74bcb1d0e939c6b06a724fce1510a4e Mon Sep 17 00:00:00 2001 From: kolya Date: Wed, 24 Sep 2008 01:48:31 +0000 Subject: [PATCH] always save and restore %fs, %gs to ensure old segment entries are never accessible to user from the hidden CPU segment registers. --- trapasm.S | 4 ++++ x86.h | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/trapasm.S b/trapasm.S index acdca99..962ba10 100644 --- a/trapasm.S +++ b/trapasm.S @@ -8,6 +8,8 @@ alltraps: # Build trap frame. pushl %ds pushl %es + pushl %fs + pushl %gs pushal # Set up data segments. @@ -24,6 +26,8 @@ alltraps: .globl trapret trapret: popal + popl %gs + popl %fs popl %es popl %ds addl $0x8, %esp # trapno and errcode diff --git a/x86.h b/x86.h index 1f2c881..8db4dc9 100644 --- a/x86.h +++ b/x86.h @@ -135,21 +135,25 @@ struct trapframe { uint eax; // rest of trap frame - ushort es; + ushort gs; ushort padding1; - ushort ds; + ushort fs; ushort padding2; + ushort es; + ushort padding3; + ushort ds; + ushort padding4; uint trapno; // below here defined by x86 hardware uint err; uint eip; ushort cs; - ushort padding3; + ushort padding5; uint eflags; // below here only when crossing rings, such as from user to kernel uint esp; ushort ss; - ushort padding4; + ushort padding6; };