WSL2-Linux-Kernel/arch/s390/mm
Gerald Schaefer 61e64c3227 s390/extmem: return correct segment type in __segment_load()
commit 8c42dd78df 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-10 09:39:56 +01:00
..
Makefile s390: add ARCH_HAS_DEBUG_WX support 2020-09-14 11:38:35 +02:00
cmm.c mm: remove unneeded includes of <asm/pgalloc.h> 2020-08-07 11:33:26 -07:00
dump_pagetables.c s390: add kfence region to pagetable dumper 2021-07-30 17:09:02 +02:00
extmem.c s390/extmem: return correct segment type in __segment_load() 2023-03-10 09:39:56 +01:00
fault.c s390/mm: do not trigger write fault when vma does not allow VM_WRITE 2022-08-31 17:16:48 +02:00
gmap.c KVM: s390: pv: leak the topmost page table when destroy fails 2022-08-17 14:23:51 +02:00
hugetlbpage.c hugetlb: pass vma into huge_pte_alloc() and huge_pmd_share() 2021-05-05 11:27:20 -07:00
init.c Merge branch 'akpm' (patches from Andrew) 2021-09-08 12:55:35 -07:00
kasan_init.c s390/kasan: fix large PMD pages address alignment check 2021-08-25 11:03:33 +02:00
maccess.c s390/maccess: fix semantics of memcpy_real() and its callers 2022-08-17 14:24:09 +02:00
mmap.c mm: remove unneeded includes of <asm/pgalloc.h> 2020-08-07 11:33:26 -07:00
page-states.c s390/mm: remove unused cmma functions 2021-08-18 10:01:28 +02:00
pageattr.c s390/mm,pageattr: fix walk_pte_level() early exit 2021-08-25 11:03:34 +02:00
pgalloc.c s390/mm: fix 2KB pgtable release race 2022-01-27 11:05:10 +01:00
pgtable.c s390/mm: use non-quiescing sske for KVM switch to keyed guest 2022-06-25 15:18:40 +02:00
vmem.c s390/vmem: fix empty page tables cleanup under KASAN 2023-03-10 09:39:15 +01:00