kernel: backport fix undefined abort
[openwrt/openwrt.git] / target / linux / generic / backport-4.14 / 080-v4.15-0001-arch-define-weak-abort.patch
1 From 7c2c11b208be09c156573fc0076b7b3646e05219 Mon Sep 17 00:00:00 2001
2 From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
3 Date: Thu, 14 Dec 2017 15:33:19 -0800
4 Subject: [PATCH] arch: define weak abort()
5
6 gcc toggle -fisolate-erroneous-paths-dereference (default at -O2
7 onwards) isolates faulty code paths such as null pointer access, divide
8 by zero etc. If gcc port doesnt implement __builtin_trap, an abort() is
9 generated which causes kernel link error.
10
11 In this case, gcc is generating abort due to 'divide by zero' in
12 lib/mpi/mpih-div.c.
13
14 Currently 'frv' and 'arc' are failing. Previously other arch was also
15 broken like m32r was fixed by commit d22e3d69ee1a ("m32r: fix build
16 failure").
17
18 Let's define this weak function which is common for all arch and fix the
19 problem permanently. We can even remove the arch specific 'abort' after
20 this is done.
21
22 Link: http://lkml.kernel.org/r/1513118956-8718-1-git-send-email-sudipm.mukherjee@gmail.com
23 Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
24 Cc: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
25 Cc: Vineet Gupta <Vineet.Gupta1@synopsys.com>
26 Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
27 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
28 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
29 ---
30 kernel/exit.c | 8 ++++++++
31 1 file changed, 8 insertions(+)
32
33 diff --git a/kernel/exit.c b/kernel/exit.c
34 index 6b4298a41167..df0c91d5606c 100644
35 --- a/kernel/exit.c
36 +++ b/kernel/exit.c
37 @@ -1755,3 +1755,11 @@ COMPAT_SYSCALL_DEFINE5(waitid,
38 return -EFAULT;
39 }
40 #endif
41 +
42 +__weak void abort(void)
43 +{
44 + BUG();
45 +
46 + /* if that doesn't kill us, halt */
47 + panic("Oops failed to kill thread");
48 +}
49 --
50 2.11.0
51