android_kernel_xiaomi_sm8450/arch/s390/mm
Gerald Schaefer 6cf48403c4 s390/extmem: return correct segment type in __segment_load()
commit 8c42dd78df148c90e48efff204cce38743906a79 upstream.

Commit f05f62d042 ("s390/vmem: get rid of memory segment list")
reshuffled the call to vmem_add_mapping() in __segment_load(), which now
overwrites rc after it was set to contain the segment type code.

As result, __segment_load() will now always return 0 on success, which
corresponds to the segment type code SEG_TYPE_SW, i.e. a writeable
segment. This results in a kernel crash when loading a read-only segment
as dcssblk block device, and trying to write to it.

Instead of reshuffling code again, make sure to return the segment type
on success, and also describe this rather delicate and unexpected logic
in the function comment. Also initialize new segtype variable with
invalid value, to prevent possible future confusion.

Fixes: f05f62d042 ("s390/vmem: get rid of memory segment list")
Cc: <stable@vger.kernel.org> # 5.9+
Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-03-11 16:39:55 +01:00
..
cmm.c mm: remove unneeded includes of <asm/pgalloc.h> 2020-08-07 11:33:26 -07:00
dump_pagetables.c s390/mm,ptdump: sort markers 2020-09-16 14:08:47 +02:00
extmem.c s390/extmem: return correct segment type in __segment_load() 2023-03-11 16:39:55 +01:00
fault.c s390/mm: do not trigger write fault when vma does not allow VM_WRITE 2022-09-05 10:28:55 +02:00
gmap.c KVM: s390: pv: leak the topmost page table when destroy fails 2022-08-21 15:15:58 +02:00
hugetlbpage.c s390/mm: fix huge pte soft dirty copying 2020-07-09 15:18:23 +02:00
init.c s390/pv: fix the forcing of the swiotlb 2021-09-18 13:40:36 +02:00
kasan_init.c s390/kasan: fix large PMD pages address alignment check 2021-09-15 09:50:27 +02:00
maccess.c s390/maccess: add no DAT mode to kernel_write 2020-06-29 16:26:36 +02:00
Makefile s390: add ARCH_HAS_DEBUG_WX support 2020-09-14 11:38:35 +02:00
mmap.c mm: remove unneeded includes of <asm/pgalloc.h> 2020-08-07 11:33:26 -07:00
page-states.c arch, mm: replace for_each_memblock() with for_each_mem_pfn_range() 2020-10-13 18:38:35 -07:00
pageattr.c s390/mm,ptdump: hold cpa mutex while walking for kernel page table dump 2020-09-14 11:38:34 +02:00
pgalloc.c s390/mm: fix 2KB pgtable release race 2022-01-27 10:54:25 +01:00
pgtable.c s390/mm: use non-quiescing sske for KVM switch to keyed guest 2022-06-25 15:16:08 +02:00
vmem.c s390/vmem: fix empty page tables cleanup under KASAN 2023-03-11 16:39:25 +01:00