diff mbox series

[SRU,Trusty,v2,1/2] Revert "UBUNTU: SAUCE: x86, extable: fix uaccess fixup detection"

Message ID 20180322133551.17057-2-juergh@canonical.com
State New
Headers show
Series [SRU,Trusty,v2,1/2] Revert "UBUNTU: SAUCE: x86, extable: fix uaccess fixup detection" | expand

Commit Message

Juerg Haefliger March 22, 2018, 1:35 p.m. UTC
BugLink: http://bugs.launchpad.net/bugs/1757193

This reverts commit 56764fdc3a847371531b8044155c70412fc5be76.

juergh: This commit causes the below kernel crash during boot in my local
testing, so revert it and instead pull in the upstream commit 548acf19234d
("x86/mm: Expand the exception table logic to allow new handling options")

[    0.127637] BUG: unable to handle kernel paging request at ffffffff01719db1
[    0.128276] IP: [<ffffffff01719db1>] 0xffffffff01719db1
[    0.128476] PGD 1c0f067 PUD 0
[    0.128476] Oops: 0010 [#1] SMP
[    0.128476] Modules linked in:
[    0.128476] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.13.11-ckt39-trusty+ #3
[    0.128476] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
[    0.128476] task: ffff88003e36c000 ti: ffff88003e36a000 task.ti: ffff88003e36a000
[    0.128476] RIP: 0010:[<ffffffff01719db1>]  [<ffffffff01719db1>] 0xffffffff01719db1
[    0.128476] RSP: 0000:ffff88003e36be98  EFLAGS: 00050246
[    0.128476] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
[    0.128476] RDX: 0000000000000000 RSI: ffff88003d833af4 RDI: ffffffff81cfea36
[    0.128476] RBP: ffff88003e36be98 R08: 0000000000000000 R09: ffff88003fa15180
[    0.128476] R10: ffffffff81339098 R11: ffffea0000f6b400 R12: ffffffff81cfea36
[    0.128476] R13: 0000000000000129 R14: 0000000000000000 R15: 0000000000000000
[    0.128476] FS:  0000000000000000(0000) GS:ffff88003fa00000(0000) knlGS:0000000000000000
[    0.128476] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[    0.128476] CR2: ffffffff01719db1 CR3: 0000000001c0c000 CR4: 0000000000360770
[    0.128476] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[    0.128476] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[    0.128476] Stack:
[    0.128476]  ffff88003e36bf08 ffffffff8100040a ffff88003e36bf00 ffffffff810b2398
[    0.128476]  ffff88003e36bef0 ffff88003fd497a1 ffffffff81afbe48 0000012900060006
[    0.128476]  ffffffff81a78639 ffffffff81e011a8 ffffffff81e012e0 0000000000000006
[    0.128476] Call Trace:
[    0.128476]  [<ffffffff8100040a>] do_one_initcall+0xfa/0x150
[    0.128476]  [<ffffffff810b2398>] ? parse_args+0x1f8/0x330
[    0.128476]  [<ffffffff81ce104c>] kernel_init_freeable+0x15f/0x1e4
[    0.128476]  [<ffffffff81ce08c1>] ? do_early_param+0x88/0x88
[    0.128476]  [<ffffffff816f9ad0>] ? rest_init+0x80/0x80
[    0.128476]  [<ffffffff816f9ade>] kernel_init+0xe/0x130
[    0.128476]  [<ffffffff81713d8e>] ret_from_fork+0x6e/0xa0
[    0.128476]  [<ffffffff816f9ad0>] ? rest_init+0x80/0x80
[    0.128476] Code:  Bad RIP value.
[    0.128476] RIP  [<ffffffff01719db1>] 0xffffffff01719db1
[    0.128476]  RSP <ffff88003e36be98>
[    0.128476] CR2: ffffffff01719db1
[    0.128476] ---[ end trace 6821844fed2f9ed6 ]---
[    0.128476] note: swapper/0[1] exited with preempt_count 1
[    0.152629] swapper/0 (1) used greatest stack depth: 5400 bytes left
[    0.153295] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000009
[    0.153295]
[    0.154271] Kernel Offset: 0x0 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffff9fffffff)

Signed-off-by: Juerg Haefliger <juergh@canonical.com>
---
 arch/x86/mm/extable.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
index a06be2f7f1bb..903ec1e9c326 100644
--- a/arch/x86/mm/extable.c
+++ b/arch/x86/mm/extable.c
@@ -17,7 +17,6 @@  ex_fixup_addr(const struct exception_table_entry *x)
 int fixup_exception(struct pt_regs *regs)
 {
 	const struct exception_table_entry *fixup;
-	unsigned long insn_ip;
 	unsigned long new_ip;
 
 #ifdef CONFIG_PNPBIOS
@@ -36,17 +35,9 @@  int fixup_exception(struct pt_regs *regs)
 
 	fixup = search_exception_tables(regs->ip);
 	if (fixup) {
-		insn_ip = ex_insn_addr(fixup);
 		new_ip = ex_fixup_addr(fixup);
 
-		/*
-		 * If the code and its fixup are "very far apart" then
-		 * they are infact tagged as uaccess'es.  Handle them
-		 * specially and fix the fixup address.  This relies on
-		 * the .fixup section being at higher addresses that the
-		 * original code.
-		 */
-		if (new_ip - insn_ip >= 0x7ffffff0) {
+		if (fixup->fixup - fixup->insn >= 0x7ffffff0 - 4) {
 			/* Special hack for uaccess_err */
 			current_thread_info()->uaccess_err = 1;
 			new_ip -= 0x7ffffff0;
@@ -62,16 +53,13 @@  int fixup_exception(struct pt_regs *regs)
 int __init early_fixup_exception(unsigned long *ip)
 {
 	const struct exception_table_entry *fixup;
-	unsigned long insn_ip;
 	unsigned long new_ip;
 
 	fixup = search_exception_tables(*ip);
 	if (fixup) {
-		insn_ip = ex_insn_addr(fixup);
 		new_ip = ex_fixup_addr(fixup);
 
-		/* See fixup_exception for details ... */
-		if (new_ip - insn_ip >= 0x7ffffff0) {
+		if (fixup->fixup - fixup->insn >= 0x7ffffff0 - 4) {
 			/* uaccess handling not supported during early boot */
 			return 0;
 		}