]> git.baikalelectronics.ru Git - kernel.git/commit
s390/mm: do not trigger write fault when vma does not allow VM_WRITE
authorGerald Schaefer <gerald.schaefer@linux.ibm.com>
Wed, 17 Aug 2022 13:26:03 +0000 (15:26 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 5 Sep 2022 08:27:44 +0000 (10:27 +0200)
commit4d2a1194b36ebfbb35fc7c34c675cde4d022a4be
treeed5b0993ae6d6b65999854e42842413a77d2f16a
parent169c00c374a8e2191287fd6c59b510ef5e1db726
s390/mm: do not trigger write fault when vma does not allow VM_WRITE

commit 2dc2ba451efaab2454ba5f0552c5b43f6b363d98 upstream.

For non-protection pXd_none() page faults in do_dat_exception(), we
call do_exception() with access == (VM_READ | VM_WRITE | VM_EXEC).
In do_exception(), vma->vm_flags is checked against that before
calling handle_mm_fault().

Since commit c1533bde21029 ("[S390] store indication fault optimization"),
we call handle_mm_fault() with FAULT_FLAG_WRITE, when recognizing that
it was a write access. However, the vma flags check is still only
checking against (VM_READ | VM_WRITE | VM_EXEC), and therefore also
calling handle_mm_fault() with FAULT_FLAG_WRITE in cases where the vma
does not allow VM_WRITE.

Fix this by changing access check in do_exception() to VM_WRITE only,
when recognizing write access.

Link: https://lkml.kernel.org/r/20220811103435.188481-3-david@redhat.com
Fixes: c1533bde21029 ("[S390] store indication fault optimization")
Cc: <stable@vger.kernel.org>
Reported-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/s390/mm/fault.c