Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2019-05-17 06:38:43 +0200
committerJiri Slaby <jslaby@suse.cz>2019-05-17 06:38:52 +0200
commitbc073a4a89f27bfdb579740dc88551cbc08ffbd2 (patch)
tree28a7eab53d58b1160e5c1498c262d91384cd5b0a
parentbc4210485122fecae16a56fa2819095df1e5f956 (diff)
powerpc/book3s/64: check for NULL pointer in pgd_alloc()
-rw-r--r--patches.kernel.org/5.1.3-036-powerpc-book3s-64-check-for-NULL-pointer-in-pgd.patch63
-rw-r--r--series.conf1
2 files changed, 64 insertions, 0 deletions
diff --git a/patches.kernel.org/5.1.3-036-powerpc-book3s-64-check-for-NULL-pointer-in-pgd.patch b/patches.kernel.org/5.1.3-036-powerpc-book3s-64-check-for-NULL-pointer-in-pgd.patch
new file mode 100644
index 0000000000..a991270ef5
--- /dev/null
+++ b/patches.kernel.org/5.1.3-036-powerpc-book3s-64-check-for-NULL-pointer-in-pgd.patch
@@ -0,0 +1,63 @@
+From: Rick Lindsley <ricklind@linux.vnet.ibm.com>
+Date: Sun, 5 May 2019 17:20:43 -0700
+Subject: [PATCH] powerpc/book3s/64: check for NULL pointer in pgd_alloc()
+References: bnc#1012628
+Patch-mainline: 5.1.3
+Git-commit: f39356261c265a0689d7ee568132d516e8b6cecc
+
+commit f39356261c265a0689d7ee568132d516e8b6cecc upstream.
+
+When the memset code was added to pgd_alloc(), it failed to consider
+that kmem_cache_alloc() can return NULL. It's uncommon, but not
+impossible under heavy memory contention. Example oops:
+
+ Unable to handle kernel paging request for data at address 0x00000000
+ Faulting instruction address: 0xc0000000000a4000
+ Oops: Kernel access of bad area, sig: 11 [#1]
+ LE SMP NR_CPUS=2048 NUMA pSeries
+ CPU: 70 PID: 48471 Comm: entrypoint.sh Kdump: loaded Not tainted 4.14.0-115.6.1.el7a.ppc64le #1
+ task: c000000334a00000 task.stack: c000000331c00000
+ NIP: c0000000000a4000 LR: c00000000012f43c CTR: 0000000000000020
+ REGS: c000000331c039c0 TRAP: 0300 Not tainted (4.14.0-115.6.1.el7a.ppc64le)
+ MSR: 800000010280b033 <SF,VEC,VSX,EE,FP,ME,IR,DR,RI,LE,TM[E]> CR: 44022840 XER: 20040000
+ CFAR: c000000000008874 DAR: 0000000000000000 DSISR: 42000000 SOFTE: 1
+ ...
+ NIP [c0000000000a4000] memset+0x68/0x104
+ LR [c00000000012f43c] mm_init+0x27c/0x2f0
+ Call Trace:
+ mm_init+0x260/0x2f0 (unreliable)
+ copy_mm+0x11c/0x638
+ copy_process.isra.28.part.29+0x6fc/0x1080
+ _do_fork+0xdc/0x4c0
+ ppc_clone+0x8/0xc
+ Instruction dump:
+ 409e000c b0860000 38c60002 409d000c 90860000 38c60004 78a0d183 78a506a0
+ 7c0903a6 41820034 60000000 60420000 <f8860000> f8860008 f8860010 f8860018
+
+Fixes: fc5c2f4a55a2 ("powerpc/mm/hash64: Zero PGD pages on allocation")
+Cc: stable@vger.kernel.org # v4.16+
+Signed-off-by: Rick Lindsley <ricklind@vnet.linux.ibm.com>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Jiri Slaby <jslaby@suse.cz>
+---
+ arch/powerpc/include/asm/book3s/64/pgalloc.h | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/arch/powerpc/include/asm/book3s/64/pgalloc.h b/arch/powerpc/include/asm/book3s/64/pgalloc.h
+index 138bc2ecc0c4..ba188797d940 100644
+--- a/arch/powerpc/include/asm/book3s/64/pgalloc.h
++++ b/arch/powerpc/include/asm/book3s/64/pgalloc.h
+@@ -81,6 +81,9 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
+
+ pgd = kmem_cache_alloc(PGT_CACHE(PGD_INDEX_SIZE),
+ pgtable_gfp_flags(mm, GFP_KERNEL));
++ if (unlikely(!pgd))
++ return pgd;
++
+ /*
+ * Don't scan the PGD for pointers, it contains references to PUDs but
+ * those references are not full pointers and so can't be recognised by
+--
+2.21.0
+
diff --git a/series.conf b/series.conf
index 54a51031a1..a03564e358 100644
--- a/series.conf
+++ b/series.conf
@@ -121,6 +121,7 @@
patches.kernel.org/5.1.3-033-isdn-bas_gigaset-use-usb_fill_int_urb-properly.patch
patches.kernel.org/5.1.3-034-drivers-virt-fsl_hypervisor.c-dereferencing-err.patch
patches.kernel.org/5.1.3-035-drivers-virt-fsl_hypervisor.c-prevent-integer-o.patch
+ patches.kernel.org/5.1.3-036-powerpc-book3s-64-check-for-NULL-pointer-in-pgd.patch
########################################################
# Build fixes that apply to the vanilla kernel too.