linux/arch/s390/mm
Heiko Carstens d9c2cf67b9 s390/kfence: fix page fault reporting
Baoquan He reported lots of KFENCE reports when /proc/kcore is read,
e.g. with crash or even simpler with dd:

 BUG: KFENCE: invalid read in copy_from_kernel_nofault+0x5e/0x120
 Invalid read at 0x00000000f4f5149f:
  copy_from_kernel_nofault+0x5e/0x120
  read_kcore+0x6b2/0x870
  proc_reg_read+0x9a/0xf0
  vfs_read+0x94/0x270
  ksys_read+0x70/0x100
  __do_syscall+0x1d0/0x200
  system_call+0x82/0xb0

The reason for this is that read_kcore() simply reads memory that might
have been unmapped by KFENCE with copy_from_kernel_nofault(). Any fault due
to pages being unmapped by KFENCE would be handled gracefully by the fault
handler (exception table fixup).

However the s390 fault handler first reports the fault, and only afterwards
would perform the exception table fixup. Most architectures have this in
reversed order, which also avoids the false positive KFENCE reports when an
unmapped page is accessed.

Therefore change the s390 fault handler so it handles exception table
fixups before KFENCE page faults are reported.

Reported-by: Baoquan He <bhe@redhat.com>
Tested-by: Baoquan He <bhe@redhat.com>
Acked-by: Alexander Potapenko <glider@google.com>
Link: https://lore.kernel.org/r/20230213183858.1473681-1-hca@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2023-02-15 11:07:01 +01:00
..
cmm.c s390/cmm: add missing virt_to_phys() conversion 2021-12-10 16:14:25 +01:00
dump_pagetables.c s390/mm,ptdump: avoid Kasan vs Memcpy Real markers swapping 2023-01-31 18:56:36 +01:00
extable.c s390/extable: add EX_TABLE_UA_LOAD_REGPAIR() macro 2022-11-21 13:36:15 +01:00
extmem.c s390/extmem: remove stale -ENOSPC comment and handling 2020-07-03 10:49:16 +02:00
fault.c s390/kfence: fix page fault reporting 2023-02-15 11:07:01 +01:00
gmap.c ARM64: 2022-12-15 11:12:21 -08:00
hugetlbpage.c s390/hugetlb: switch to generic version of follow_huge_pud() 2022-09-11 20:26:01 -07:00
init.c s390/mm: start kernel with DAT enabled 2023-01-13 14:15:05 +01:00
kasan_init.c s390/mem_detect: do not truncate online memory ranges info 2023-02-14 11:45:40 +01:00
maccess.c s390/mm: allocate Absolute Lowcore Area in decompressor 2023-01-13 14:15:06 +01:00
Makefile s390/extable: move extable related functions to mm/extable.c 2022-03-08 00:33:00 +01:00
mmap.c treewide: use get_random_u32() when possible 2022-10-11 17:42:58 -06:00
page-states.c s390/mm: remove unused get_page_state() function 2022-11-23 16:24:07 +01:00
pageattr.c s390/mm,pageattr: don't use pte_val()/pXd_val() as lvalue 2022-03-01 21:05:10 +01:00
pgalloc.c s390/mm: use CRST_ALLOC_ORDER instead of number 2022-02-09 22:56:04 +01:00
pgtable.c s390/mm: add support for RDP (Reset DAT-Protection) 2023-02-14 11:45:39 +01:00
vmem.c s390/vmem: remove unnecessary KASAN checks 2023-02-06 11:13:53 +01:00