Skip to content

Commit d38bc89

Browse files
amlutoIngo Molnar
authored andcommitted
x86/oops: Show the correct CS value in show_regs()
show_regs() shows the CS in the CPU register instead of the value in regs. This means that we'll probably print "CS: 0010" almost all the time regardless of what was actually in CS when the kernel malfunctioned. This gives a particularly confusing result if we OOPSed due to an implicit supervisor access from user mode. Signed-off-by: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Yu-cheng Yu <[email protected]> Link: http://lkml.kernel.org/r/4e36812b6e1e95236a812021d35cbf22746b5af6.1542841400.git.luto@kernel.org Signed-off-by: Ingo Molnar <[email protected]>
1 parent ebb53e2 commit d38bc89

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

arch/x86/kernel/process_64.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode)
6666
unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L, fs, gs, shadowgs;
6767
unsigned long d0, d1, d2, d3, d6, d7;
6868
unsigned int fsindex, gsindex;
69-
unsigned int ds, cs, es;
69+
unsigned int ds, es;
7070

7171
show_iret_regs(regs);
7272

@@ -98,7 +98,6 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode)
9898
}
9999

100100
asm("movl %%ds,%0" : "=r" (ds));
101-
asm("movl %%cs,%0" : "=r" (cs));
102101
asm("movl %%es,%0" : "=r" (es));
103102
asm("movl %%fs,%0" : "=r" (fsindex));
104103
asm("movl %%gs,%0" : "=r" (gsindex));
@@ -114,7 +113,7 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode)
114113

115114
printk(KERN_DEFAULT "FS: %016lx(%04x) GS:%016lx(%04x) knlGS:%016lx\n",
116115
fs, fsindex, gs, gsindex, shadowgs);
117-
printk(KERN_DEFAULT "CS: %04x DS: %04x ES: %04x CR0: %016lx\n", cs, ds,
116+
printk(KERN_DEFAULT "CS: %04lx DS: %04x ES: %04x CR0: %016lx\n", regs->cs, ds,
118117
es, cr0);
119118
printk(KERN_DEFAULT "CR2: %016lx CR3: %016lx CR4: %016lx\n", cr2, cr3,
120119
cr4);

0 commit comments

Comments
 (0)