Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/mm: Prevent unlikely crash in copro_calculate_slb()

If a cxl adapter faults on an invalid address for a kernel context, we
may enter copro_calculate_slb() with a NULL mm pointer (kernel
context) and an effective address which looks like a user
address. Which will cause a crash when dereferencing mm. It is clearly
an AFU bug, but there's no reason to crash either. So return an error,
so that cxl can ack the interrupt with an address error.

Fixes: 73d16a6e0e51 ("powerpc/cell: Move data segment faulting code out of cell platform")
Cc: stable@vger.kernel.org # v3.18+
Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Frederic Barrat and committed by
Michael Ellerman
d2cf909c 1001354c

+2
+2
arch/powerpc/mm/copro_fault.c
··· 106 106 switch (REGION_ID(ea)) { 107 107 case USER_REGION_ID: 108 108 pr_devel("%s: 0x%llx -- USER_REGION_ID\n", __func__, ea); 109 + if (mm == NULL) 110 + return 1; 109 111 psize = get_slice_psize(mm, ea); 110 112 ssize = user_segment_size(ea); 111 113 vsid = get_vsid(mm->context.id, ea, ssize);