Skip to content

Commit 41ac42f

Browse files
gerald-schaeferVasily Gorbik
authored andcommitted
s390/mm: do not trigger write fault when vma does not allow VM_WRITE
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 92f842e ("[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/[email protected] Fixes: 92f842e ("[S390] store indication fault optimization") Cc: <[email protected]> Reported-by: David Hildenbrand <[email protected]> Reviewed-by: Heiko Carstens <[email protected]> Signed-off-by: Gerald Schaefer <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent 13cccaf commit 41ac42f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arch/s390/mm/fault.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,9 @@ static inline vm_fault_t do_exception(struct pt_regs *regs, int access)
379379
flags = FAULT_FLAG_DEFAULT;
380380
if (user_mode(regs))
381381
flags |= FAULT_FLAG_USER;
382-
if (access == VM_WRITE || is_write)
382+
if (is_write)
383+
access = VM_WRITE;
384+
if (access == VM_WRITE)
383385
flags |= FAULT_FLAG_WRITE;
384386
mmap_read_lock(mm);
385387

0 commit comments

Comments
 (0)