linux-stable/arch/s390
Claudio Imbrenda b732815739 KVM: s390: fix race in gmap_make_secure()
[ Upstream commit c148dc8e2f ]

Fix a potential race in gmap_make_secure() and remove the last user of
follow_page() without FOLL_GET.

The old code is locking something it doesn't have a reference to, and
as explained by Jason and David in this discussion:
https://lore.kernel.org/linux-mm/Y9J4P%2FRNvY1Ztn0Q@nvidia.com/
it can lead to all kind of bad things, including the page getting
unmapped (MADV_DONTNEED), freed, reallocated as a larger folio and the
unlock_page() would target the wrong bit.
There is also another race with the FOLL_WRITE, which could race
between the follow_page() and the get_locked_pte().

The main point is to remove the last use of follow_page() without
FOLL_GET or FOLL_PIN, removing the races can be considered a nice
bonus.

Link: https://lore.kernel.org/linux-mm/Y9J4P%2FRNvY1Ztn0Q@nvidia.com/
Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
Fixes: 214d9bbcd3 ("s390/mm: provide memory management functions for protected KVM guests")
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Message-Id: <20230428092753.27913-2-imbrenda@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-05-17 13:58:50 +02:00
..
appldata s390/appldata: remove power management callbacks 2022-12-02 18:25:04 +01:00
boot s390/ipl: add missing intersection check to ipl_report handling 2023-03-22 13:37:59 +01:00
configs s390: update defconfigs 2023-01-11 21:26:40 +01:00
crypto crypto: Kconfig - simplify cipher entries 2022-08-26 18:50:43 +08:00
hypfs s390/hypfs: remove unused info_blk_hdr__pcpus() function 2022-11-23 16:24:07 +01:00
include s390/checksum: always use cksm instruction 2023-05-11 23:11:28 +09:00
kernel KVM: s390: fix race in gmap_make_secure() 2023-05-17 13:58:50 +02:00
kvm KVM: s390: pv: fix asynchronous teardown for small VMs 2023-05-17 13:58:50 +02:00
lib s390/uaccess: add missing earlyclobber annotations to __clear_user() 2023-04-06 12:12:45 +02:00
mm KVM: s390: pv: fix asynchronous teardown for small VMs 2023-05-17 13:58:50 +02:00
net s390/bpf: Add expoline to tail calls 2023-03-10 09:28:11 +01:00
pci PCI: s390: Fix use-after-free of PCI resources with per-function hotplug 2023-03-22 13:37:46 +01:00
purgatory s390/purgatory: remove duplicated build rule of kexec-purgatory.o 2022-06-30 14:18:16 +02:00
tools KVM: s390: Add facility 197 to the allow list 2022-07-13 15:25:25 +02:00
Kbuild kbuild: use more subdir- for visiting subdirectories while cleaning 2021-10-24 13:49:46 +09:00
Kconfig s390/checksum: always use cksm instruction 2023-05-11 23:11:28 +09:00
Kconfig.debug s390/Kconfig.debug: fix indentation 2022-06-01 12:03:15 +02:00
Makefile s390: reintroduce expoline dependence to scripts 2023-04-06 12:12:45 +02:00