mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
LoongArch: Fix access error when read fault on a write-only VMA
commit efb44ff64c95340b06331fc48634b99efc9dd77c upstream.
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: 09cfefb7fa ("LoongArch: Add memory management")
Signed-off-by: Jiantao Shan <shanjiantao@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
94021d1d2b
commit
ba9bcc0e58
@@ -193,10 +193,10 @@ good_area:
|
|||||||
if (!(vma->vm_flags & VM_WRITE))
|
if (!(vma->vm_flags & VM_WRITE))
|
||||||
goto bad_area;
|
goto bad_area;
|
||||||
} else {
|
} else {
|
||||||
if (!(vma->vm_flags & VM_READ) && address != exception_era(regs))
|
|
||||||
goto bad_area;
|
|
||||||
if (!(vma->vm_flags & VM_EXEC) && address == exception_era(regs))
|
if (!(vma->vm_flags & VM_EXEC) && address == exception_era(regs))
|
||||||
goto bad_area;
|
goto bad_area;
|
||||||
|
if (!(vma->vm_flags & (VM_READ | VM_WRITE)) && address != exception_era(regs))
|
||||||
|
goto bad_area;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user