Skip to contentSkip to conversation

FAILED: patch "[PATCH] riscv: Make VM_WRITE imply VM_READ" failed to apply to 5.4-stable tree

PATCH [email protected] 1 participant 1 message Oct 16, 2022

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

Possible dependencies:

7ab72c597356 ("riscv: Make VM_WRITE imply VM_READ")
afb8c6fee8ce ("riscv/mm/fault: Move access error check to function")
6747430197ed ("riscv/mm/fault: Move FAULT_FLAG_WRITE handling in do_page_fault()") ac416a724f11 ("riscv/mm/fault: Move vmalloc fault handling to vmalloc_fault()") a51271d99cdd ("riscv/mm/fault: Move bad area handling to bad_area()")
cac4d1dc85be ("riscv/mm/fault: Move no context handling to no_context()")
d8ed45c5dcd4 ("mmap locking API: use coccinelle to convert mmap_sem rwsem call sites") 7ae77150d94d ("Merge tag 'powerpc-5.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux")

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 7ab72c597356be1e7f0f3d856e54ce78527f43c8 Mon Sep 17 00:00:00 2001
From: Andrew Bresticker <[email protected]>
Date: Thu, 15 Sep 2022 15:37:01 -0400
Subject: [PATCH] riscv: Make VM_WRITE imply VM_READ

RISC-V does not presently have write-only mappings as that PTE bit pattern is considered reserved in the privileged spec, so allow handling of read faults in VMAs that have VM_WRITE without VM_READ in order to be consistent with other architectures that have similar limitations.

Fixes 2139619bcad7 ("riscv: mmap with PROT_WRITE but no PROT_READ is invalid")
arch/riscv/mm/fault.c +2 -1
index f2fbd1400b7c..d86f7cebd4a7 100644
@@ -184,7 +184,8 @@ static inline bool access_error(unsigned long cause, struct vm_area_struct *vma)
 		}
 		break;
 	case EXC_LOAD_PAGE_FAULT:
-		if (!(vma->vm_flags & VM_READ)) {
+		/* Write implies read */
+		if (!(vma->vm_flags & (VM_READ | VM_WRITE))) {
 			return true;
 		}
 		break;