From b38758d4d47a769268da791ec6a1ab8b138e203e Mon Sep 17 00:00:00 2001 From: Evgeniy Didin Date: Tue, 30 Jan 2018 15:36:51 +0300 Subject: [PATCH] kernel: backport fix undefined abort While building mpi.ko module with stable Linux v4.14.14 an error occured: >ERROR: "abort" [lib/mpi/mpi.ko] undefined! In upstream Linux 4.15 this issue is fixed: Commit 7c2c11b208be ("arch: define weak abort()") https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7c2c11b208be09c156573fc0076b7b3646e05219 Commit dc8635b78cd8 ("kernel/exit.c: export abort() to modules") https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=dc8635b78cd8669c37e230058d18c33af7451ab1 So lets add backport patches until these fixes are not applied in stable version. Signed-off-by: Evgeniy Didin Cc: Alexey Brodkin CC: John Crispin CC: Hauke Mehrtens --- ...80-v4.15-0001-arch-define-weak-abort.patch | 51 +++++++++++++ ...ernel-exit.c-export-abort-to-modules.patch | 74 +++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 target/linux/generic/backport-4.14/080-v4.15-0001-arch-define-weak-abort.patch create mode 100644 target/linux/generic/backport-4.14/081-v4.15-0002-kernel-exit.c-export-abort-to-modules.patch diff --git a/target/linux/generic/backport-4.14/080-v4.15-0001-arch-define-weak-abort.patch b/target/linux/generic/backport-4.14/080-v4.15-0001-arch-define-weak-abort.patch new file mode 100644 index 000000000000..2d247a39e41f --- /dev/null +++ b/target/linux/generic/backport-4.14/080-v4.15-0001-arch-define-weak-abort.patch @@ -0,0 +1,51 @@ +From 7c2c11b208be09c156573fc0076b7b3646e05219 Mon Sep 17 00:00:00 2001 +From: Sudip Mukherjee +Date: Thu, 14 Dec 2017 15:33:19 -0800 +Subject: [PATCH] arch: define weak abort() + +gcc toggle -fisolate-erroneous-paths-dereference (default at -O2 +onwards) isolates faulty code paths such as null pointer access, divide +by zero etc. If gcc port doesnt implement __builtin_trap, an abort() is +generated which causes kernel link error. + +In this case, gcc is generating abort due to 'divide by zero' in +lib/mpi/mpih-div.c. + +Currently 'frv' and 'arc' are failing. Previously other arch was also +broken like m32r was fixed by commit d22e3d69ee1a ("m32r: fix build +failure"). + +Let's define this weak function which is common for all arch and fix the +problem permanently. We can even remove the arch specific 'abort' after +this is done. + +Link: http://lkml.kernel.org/r/1513118956-8718-1-git-send-email-sudipm.mukherjee@gmail.com +Signed-off-by: Sudip Mukherjee +Cc: Alexey Brodkin +Cc: Vineet Gupta +Cc: Sudip Mukherjee +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +--- + kernel/exit.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/kernel/exit.c b/kernel/exit.c +index 6b4298a41167..df0c91d5606c 100644 +--- a/kernel/exit.c ++++ b/kernel/exit.c +@@ -1755,3 +1755,11 @@ COMPAT_SYSCALL_DEFINE5(waitid, + return -EFAULT; + } + #endif ++ ++__weak void abort(void) ++{ ++ BUG(); ++ ++ /* if that doesn't kill us, halt */ ++ panic("Oops failed to kill thread"); ++} +-- +2.11.0 + diff --git a/target/linux/generic/backport-4.14/081-v4.15-0002-kernel-exit.c-export-abort-to-modules.patch b/target/linux/generic/backport-4.14/081-v4.15-0002-kernel-exit.c-export-abort-to-modules.patch new file mode 100644 index 000000000000..5b95b6798da9 --- /dev/null +++ b/target/linux/generic/backport-4.14/081-v4.15-0002-kernel-exit.c-export-abort-to-modules.patch @@ -0,0 +1,74 @@ +From dc8635b78cd8669c37e230058d18c33af7451ab1 Mon Sep 17 00:00:00 2001 +From: Andrew Morton +Date: Thu, 4 Jan 2018 16:17:56 -0800 +Subject: [PATCH] kernel/exit.c: export abort() to modules + +gcc -fisolate-erroneous-paths-dereference can generate calls to abort() +from modular code too. + +[arnd@arndb.de: drop duplicate exports of abort()] + Link: http://lkml.kernel.org/r/20180102103311.706364-1-arnd@arndb.de +Reported-by: Vineet Gupta +Cc: Sudip Mukherjee +Cc: Arnd Bergmann +Cc: Alexey Brodkin +Cc: Russell King +Cc: Jose Abreu +Signed-off-by: Andrew Morton +Signed-off-by: Arnd Bergmann +Signed-off-by: Linus Torvalds +--- + arch/arm/kernel/traps.c | 1 - + arch/m32r/kernel/traps.c | 1 - + arch/unicore32/kernel/traps.c | 1 - + kernel/exit.c | 1 + + 4 files changed, 1 insertion(+), 3 deletions(-) + +diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c +index 5cf04888c581..3e26c6f7a191 100644 +--- a/arch/arm/kernel/traps.c ++++ b/arch/arm/kernel/traps.c +@@ -793,7 +793,6 @@ void abort(void) + /* if that doesn't kill us, halt */ + panic("Oops failed to kill thread"); + } +-EXPORT_SYMBOL(abort); + + void __init trap_init(void) + { +diff --git a/arch/m32r/kernel/traps.c b/arch/m32r/kernel/traps.c +index cb79fba79d43..b88a8dd14933 100644 +--- a/arch/m32r/kernel/traps.c ++++ b/arch/m32r/kernel/traps.c +@@ -122,7 +122,6 @@ void abort(void) + /* if that doesn't kill us, halt */ + panic("Oops failed to kill thread"); + } +-EXPORT_SYMBOL(abort); + + void __init trap_init(void) + { +diff --git a/arch/unicore32/kernel/traps.c b/arch/unicore32/kernel/traps.c +index 5f25b39f04d4..c4ac6043ebb0 100644 +--- a/arch/unicore32/kernel/traps.c ++++ b/arch/unicore32/kernel/traps.c +@@ -298,7 +298,6 @@ void abort(void) + /* if that doesn't kill us, halt */ + panic("Oops failed to kill thread"); + } +-EXPORT_SYMBOL(abort); + + void __init trap_init(void) + { +diff --git a/kernel/exit.c b/kernel/exit.c +index df0c91d5606c..995453d9fb55 100644 +--- a/kernel/exit.c ++++ b/kernel/exit.c +@@ -1763,3 +1763,4 @@ __weak void abort(void) + /* if that doesn't kill us, halt */ + panic("Oops failed to kill thread"); + } ++EXPORT_SYMBOL(abort); +-- +2.11.0 + -- 2.30.2