* FAILED: patch "[PATCH] s390/mm: do not trigger write fault when vma does not allow" failed to apply to 4.9-stable tree
@ 2022-08-29 7:37 gregkh
2022-08-29 15:52 ` [PATCH 4.9] s390/mm: do not trigger write fault when vma does not allow VM_WRITE Gerald Schaefer
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2022-08-29 7:37 UTC (permalink / raw)
To: gerald.schaefer, david, gor, hca, stable; +Cc: stable
The patch below does not apply to the 4.9-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 <stable@vger.kernel.org>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 41ac42f137080bc230b5882e3c88c392ab7f2d32 Mon Sep 17 00:00:00 2001
From: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Date: Wed, 17 Aug 2022 15:26:03 +0200
Subject: [PATCH] s390/mm: do not trigger write fault when vma does not allow
VM_WRITE
For non-protection pXd_none() page faults in do_dat_exception(), we
call do_exception() with access == (VM_READ | VM_WRITE | VM_EXEC).
In do_exception(), vma->vm_flags is checked against that before
calling handle_mm_fault().
Since commit 92f842eac7ee3 ("[S390] store indication fault optimization"),
we call handle_mm_fault() with FAULT_FLAG_WRITE, when recognizing that
it was a write access. However, the vma flags check is still only
checking against (VM_READ | VM_WRITE | VM_EXEC), and therefore also
calling handle_mm_fault() with FAULT_FLAG_WRITE in cases where the vma
does not allow VM_WRITE.
Fix this by changing access check in do_exception() to VM_WRITE only,
when recognizing write access.
Link: https://lkml.kernel.org/r/20220811103435.188481-3-david@redhat.com
Fixes: 92f842eac7ee3 ("[S390] store indication fault optimization")
Cc: <stable@vger.kernel.org>
Reported-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
index 13449941516c..09b6e756d521 100644
--- a/arch/s390/mm/fault.c
+++ b/arch/s390/mm/fault.c
@@ -379,7 +379,9 @@ static inline vm_fault_t do_exception(struct pt_regs *regs, int access)
flags = FAULT_FLAG_DEFAULT;
if (user_mode(regs))
flags |= FAULT_FLAG_USER;
- if (access == VM_WRITE || is_write)
+ if (is_write)
+ access = VM_WRITE;
+ if (access == VM_WRITE)
flags |= FAULT_FLAG_WRITE;
mmap_read_lock(mm);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 4.9] s390/mm: do not trigger write fault when vma does not allow VM_WRITE
2022-08-29 7:37 FAILED: patch "[PATCH] s390/mm: do not trigger write fault when vma does not allow" failed to apply to 4.9-stable tree gregkh
@ 2022-08-29 15:52 ` Gerald Schaefer
2022-09-01 10:12 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Gerald Schaefer @ 2022-08-29 15:52 UTC (permalink / raw)
To: gregkh; +Cc: david, gerald.schaefer, gor, hca, stable
commit 41ac42f137080bc230b5882e3c88c392ab7f2d32 upstream.
For non-protection pXd_none() page faults in do_dat_exception(), we
call do_exception() with access == (VM_READ | VM_WRITE | VM_EXEC).
In do_exception(), vma->vm_flags is checked against that before
calling handle_mm_fault().
Since commit 92f842eac7ee3 ("[S390] store indication fault optimization"),
we call handle_mm_fault() with FAULT_FLAG_WRITE, when recognizing that
it was a write access. However, the vma flags check is still only
checking against (VM_READ | VM_WRITE | VM_EXEC), and therefore also
calling handle_mm_fault() with FAULT_FLAG_WRITE in cases where the vma
does not allow VM_WRITE.
Fix this by changing access check in do_exception() to VM_WRITE only,
when recognizing write access.
Link: https://lkml.kernel.org/r/20220811103435.188481-3-david@redhat.com
Fixes: 92f842eac7ee3 ("[S390] store indication fault optimization")
Cc: <stable@vger.kernel.org>
Reported-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
---
arch/s390/mm/fault.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
index ba2f21873cbd..6fa4220e34b5 100644
--- a/arch/s390/mm/fault.c
+++ b/arch/s390/mm/fault.c
@@ -409,7 +409,9 @@ static inline int do_exception(struct pt_regs *regs, int access)
flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
if (user_mode(regs))
flags |= FAULT_FLAG_USER;
- if (access == VM_WRITE || (trans_exc_code & store_indication) == 0x400)
+ if ((trans_exc_code & store_indication) == 0x400)
+ access = VM_WRITE;
+ if (access == VM_WRITE)
flags |= FAULT_FLAG_WRITE;
down_read(&mm->mmap_sem);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 4.9] s390/mm: do not trigger write fault when vma does not allow VM_WRITE
2022-08-29 15:52 ` [PATCH 4.9] s390/mm: do not trigger write fault when vma does not allow VM_WRITE Gerald Schaefer
@ 2022-09-01 10:12 ` Greg KH
0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2022-09-01 10:12 UTC (permalink / raw)
To: Gerald Schaefer; +Cc: david, gor, hca, stable
On Mon, Aug 29, 2022 at 05:52:38PM +0200, Gerald Schaefer wrote:
> commit 41ac42f137080bc230b5882e3c88c392ab7f2d32 upstream.
>
> For non-protection pXd_none() page faults in do_dat_exception(), we
> call do_exception() with access == (VM_READ | VM_WRITE | VM_EXEC).
> In do_exception(), vma->vm_flags is checked against that before
> calling handle_mm_fault().
>
> Since commit 92f842eac7ee3 ("[S390] store indication fault optimization"),
> we call handle_mm_fault() with FAULT_FLAG_WRITE, when recognizing that
> it was a write access. However, the vma flags check is still only
> checking against (VM_READ | VM_WRITE | VM_EXEC), and therefore also
> calling handle_mm_fault() with FAULT_FLAG_WRITE in cases where the vma
> does not allow VM_WRITE.
>
> Fix this by changing access check in do_exception() to VM_WRITE only,
> when recognizing write access.
>
> Link: https://lkml.kernel.org/r/20220811103435.188481-3-david@redhat.com
> Fixes: 92f842eac7ee3 ("[S390] store indication fault optimization")
> Cc: <stable@vger.kernel.org>
> Reported-by: David Hildenbrand <david@redhat.com>
> Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
> Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
> ---
> arch/s390/mm/fault.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
> index ba2f21873cbd..6fa4220e34b5 100644
> --- a/arch/s390/mm/fault.c
> +++ b/arch/s390/mm/fault.c
> @@ -409,7 +409,9 @@ static inline int do_exception(struct pt_regs *regs, int access)
> flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
> if (user_mode(regs))
> flags |= FAULT_FLAG_USER;
> - if (access == VM_WRITE || (trans_exc_code & store_indication) == 0x400)
> + if ((trans_exc_code & store_indication) == 0x400)
> + access = VM_WRITE;
> + if (access == VM_WRITE)
> flags |= FAULT_FLAG_WRITE;
> down_read(&mm->mmap_sem);
>
> --
> 2.34.1
>
all now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-01 10:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-29 7:37 FAILED: patch "[PATCH] s390/mm: do not trigger write fault when vma does not allow" failed to apply to 4.9-stable tree gregkh
2022-08-29 15:52 ` [PATCH 4.9] s390/mm: do not trigger write fault when vma does not allow VM_WRITE Gerald Schaefer
2022-09-01 10:12 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).