aboutsummaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2017-02-15 12:33:03 +0100
committerFelix Fietkau <nbd@nbd.name>2017-02-15 13:23:58 +0100
commit853bad5af293c6291894892237ddecbd24e370c8 (patch)
tree1dca663b5aa412991b9e5d10f4f6f13b655a7e09 /target
parentdf49e49bc7834ad3257d1b10972854a14605a67c (diff)
downloadupstream-853bad5af293c6291894892237ddecbd24e370c8.tar.gz
upstream-853bad5af293c6291894892237ddecbd24e370c8.tar.bz2
upstream-853bad5af293c6291894892237ddecbd24e370c8.zip
kernel: fix crashes on MIPS when loading kernel modules under memory pressure
When memory is tight, modules may need to be loaded into vmalloc() space. The code then has to generate jump trampolines which enable relocations between vmalloc space and physical address space. The code had a bug that was freeing these trampolines even when the module was successfully loaded. Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'target')
-rw-r--r--target/linux/generic/patches-3.18/305-mips_module_reloc.patch5
-rw-r--r--target/linux/generic/patches-4.4/305-mips_module_reloc.patch5
2 files changed, 8 insertions, 2 deletions
diff --git a/target/linux/generic/patches-3.18/305-mips_module_reloc.patch b/target/linux/generic/patches-3.18/305-mips_module_reloc.patch
index f8ca91401a..fae7e70f0e 100644
--- a/target/linux/generic/patches-3.18/305-mips_module_reloc.patch
+++ b/target/linux/generic/patches-3.18/305-mips_module_reloc.patch
@@ -317,7 +317,7 @@
return 0;
}
-@@ -287,9 +529,33 @@ int module_finalize(const Elf_Ehdr *hdr,
+@@ -287,9 +529,36 @@ int module_finalize(const Elf_Ehdr *hdr,
list_add(&me->arch.dbe_list, &dbe_list);
spin_unlock_irq(&dbe_lock);
}
@@ -338,6 +338,9 @@
+void module_arch_freeing_init(struct module *mod)
+{
++ if (mod->state == MODULE_STATE_LIVE)
++ return;
++
+ if (mod->arch.phys_plt_tbl) {
+ __module_free(mod->arch.phys_plt_tbl);
+ mod->arch.phys_plt_tbl = NULL;
diff --git a/target/linux/generic/patches-4.4/305-mips_module_reloc.patch b/target/linux/generic/patches-4.4/305-mips_module_reloc.patch
index 8b3975fe09..944921fff7 100644
--- a/target/linux/generic/patches-4.4/305-mips_module_reloc.patch
+++ b/target/linux/generic/patches-4.4/305-mips_module_reloc.patch
@@ -316,7 +316,7 @@
return 0;
}
-@@ -287,9 +528,33 @@ int module_finalize(const Elf_Ehdr *hdr,
+@@ -287,9 +528,36 @@ int module_finalize(const Elf_Ehdr *hdr,
list_add(&me->arch.dbe_list, &dbe_list);
spin_unlock_irq(&dbe_lock);
}
@@ -337,6 +337,9 @@
+void module_arch_freeing_init(struct module *mod)
+{
++ if (mod->state == MODULE_STATE_LIVE)
++ return;
++
+ if (mod->arch.phys_plt_tbl) {
+ __module_free(mod->arch.phys_plt_tbl);
+ mod->arch.phys_plt_tbl = NULL;