* [PATCH] LoongArch: Fix access error when read fault on a write-only VMA
@ 2024-04-23 7:42 Huacai Chen
2024-04-23 9:44 ` Markus Elfring
0 siblings, 1 reply; 3+ messages in thread
From: Huacai Chen @ 2024-04-23 7:42 UTC (permalink / raw)
To: Arnd Bergmann, Huacai Chen
Cc: loongarch, linux-arch, Xuefeng Li, Guo Ren, Xuerui Wang,
Jiaxun Yang, linux-kernel, loongson-kernel, Jiantao Shan,
Huacai Chen
From: Jiantao Shan <shanjiantao@loongson.cn>
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.
Signed-off-by: Jiantao Shan <shanjiantao@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
arch/loongarch/mm/fault.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/loongarch/mm/fault.c b/arch/loongarch/mm/fault.c
index 1fc2f6813ea0..97b40defde06 100644
--- a/arch/loongarch/mm/fault.c
+++ b/arch/loongarch/mm/fault.c
@@ -202,10 +202,10 @@ static void __kprobes __do_page_fault(struct pt_regs *regs,
if (!(vma->vm_flags & VM_WRITE))
goto bad_area;
} else {
- if (!(vma->vm_flags & VM_READ) && address != exception_era(regs))
- goto bad_area;
if (!(vma->vm_flags & VM_EXEC) && address == exception_era(regs))
goto bad_area;
+ if (!(vma->vm_flags & (VM_READ | VM_WRITE)) && address != exception_era(regs))
+ goto bad_area;
}
/*
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] LoongArch: Fix access error when read fault on a write-only VMA
2024-04-23 7:42 [PATCH] LoongArch: Fix access error when read fault on a write-only VMA Huacai Chen
@ 2024-04-23 9:44 ` Markus Elfring
2024-04-24 3:11 ` Huacai Chen
0 siblings, 1 reply; 3+ messages in thread
From: Markus Elfring @ 2024-04-23 9:44 UTC (permalink / raw)
To: Huacai Chen, Jiantao Shan, loongarch, loongson-kernel, linux-arch,
kernel-janitors, Arnd Bergmann
Cc: LKML, Guo Ren, Huacai Chen, Jiaxun Yang, Xuefeng Li, Xuerui Wang
> As with most architectures, allow handling of read faults in VMAs that
> have VM_WRITE but without VM_READ (WRITE implies READ).
…
Will the tag “Fixes” become relevant here?
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] LoongArch: Fix access error when read fault on a write-only VMA
2024-04-23 9:44 ` Markus Elfring
@ 2024-04-24 3:11 ` Huacai Chen
0 siblings, 0 replies; 3+ messages in thread
From: Huacai Chen @ 2024-04-24 3:11 UTC (permalink / raw)
To: Markus Elfring
Cc: Huacai Chen, Jiantao Shan, loongarch, loongson-kernel, linux-arch,
kernel-janitors, Arnd Bergmann, LKML, Guo Ren, Jiaxun Yang,
Xuefeng Li, Xuerui Wang
Hi, Markus,
On Tue, Apr 23, 2024 at 5:45 PM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> > As with most architectures, allow handling of read faults in VMAs that
> > have VM_WRITE but without VM_READ (WRITE implies READ).
> …
>
> Will the tag “Fixes” become relevant here?
Yes, you are right, thank you.
Huacai
>
> Regards,
> Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-24 3:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-23 7:42 [PATCH] LoongArch: Fix access error when read fault on a write-only VMA Huacai Chen
2024-04-23 9:44 ` Markus Elfring
2024-04-24 3:11 ` Huacai Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox