]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
LoongArch: Fix access error when read fault on a write-only VMA
authorJiantao Shan <shanjiantao@loongson.cn>
Wed, 24 Apr 2024 04:36:07 +0000 (12:36 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 May 2024 14:32:45 +0000 (16:32 +0200)
commitc15b5c6fabcbfcde904c157fd34043d055617996
tree31268bd2023a40a2a09bfb668c3bececcd313f65
parent2c733bb795dded51e09b397a4afcddd08eb8bb27
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: 09cfefb7fa70c3af01 ("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>
arch/loongarch/mm/fault.c