Skip to content

Commit efb44ff

Browse files
znleychenhuacai
authored andcommitted
LoongArch: Fix access error when read fault on a write-only VMA
As with most architectures, allow handling of read faults in VMAs that have VM_WRITE but without VM_READ (WRITE implies READ). Otherwise, reading before writing a write-only memory will error while reading after writing everything is fine. BTW, move the VM_EXEC judgement before VM_READ/VM_WRITE to make logic a little clearer. Cc: stable@vger.kernel.org Fixes: 09cfefb ("LoongArch: Add memory management") Signed-off-by: Jiantao Shan <shanjiantao@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent 7ab22b5 commit efb44ff

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

arch/loongarch/mm/fault.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,10 @@ static void __kprobes __do_page_fault(struct pt_regs *regs,
202202
if (!(vma->vm_flags & VM_WRITE))
203203
goto bad_area;
204204
} else {
205-
if (!(vma->vm_flags & VM_READ) && address != exception_era(regs))
206-
goto bad_area;
207205
if (!(vma->vm_flags & VM_EXEC) && address == exception_era(regs))
208206
goto bad_area;
207+
if (!(vma->vm_flags & (VM_READ | VM_WRITE)) && address != exception_era(regs))
208+
goto bad_area;
209209
}
210210

211211
/*

0 commit comments

Comments
 (0)