stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] s390/mm: fix BUG_ON in crst_table_upgrade" failed to apply to 4.12-stable tree
@ 2017-09-04 10:39 gregkh
  2017-09-05  8:18 ` Martin Schwidefsky
  0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2017-09-04 10:39 UTC (permalink / raw)
  To: schwidefsky, stable; +Cc: stable


The patch below does not apply to the 4.12-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 8ab867cb0806a8e195de161fd8883a0578d1d050 Mon Sep 17 00:00:00 2001
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
Date: Thu, 31 Aug 2017 13:18:22 +0200
Subject: [PATCH] s390/mm: fix BUG_ON in crst_table_upgrade

A 31-bit compat process can force a BUG_ON in crst_table_upgrade
with specific, invalid mmap calls, e.g.

   mmap((void*) 0x7fff8000, 0x10000, 3, 32, -1, 0)

The arch_get_unmapped_area[_topdown] functions miss an if condition
in the decision to do a page table upgrade.

Fixes: 9b11c7912d00 ("s390/mm: simplify arch_get_unmapped_area[_topdown]")
Cc: <stable@vger.kernel.org>  # v4.12+
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
index 2e10d2b8ad35..5bea139517a2 100644
--- a/arch/s390/mm/mmap.c
+++ b/arch/s390/mm/mmap.c
@@ -119,7 +119,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 		return addr;
 
 check_asce_limit:
-	if (addr + len > current->mm->context.asce_limit) {
+	if (addr + len > current->mm->context.asce_limit &&
+	    addr + len <= TASK_SIZE) {
 		rc = crst_table_upgrade(mm, addr + len);
 		if (rc)
 			return (unsigned long) rc;
@@ -183,7 +184,8 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
 	}
 
 check_asce_limit:
-	if (addr + len > current->mm->context.asce_limit) {
+	if (addr + len > current->mm->context.asce_limit &&
+	    addr + len <= TASK_SIZE) {
 		rc = crst_table_upgrade(mm, addr + len);
 		if (rc)
 			return (unsigned long) rc;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: FAILED: patch "[PATCH] s390/mm: fix BUG_ON in crst_table_upgrade" failed to apply to 4.12-stable tree
  2017-09-04 10:39 FAILED: patch "[PATCH] s390/mm: fix BUG_ON in crst_table_upgrade" failed to apply to 4.12-stable tree gregkh
@ 2017-09-05  8:18 ` Martin Schwidefsky
  2017-09-07 14:38   ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Schwidefsky @ 2017-09-05  8:18 UTC (permalink / raw)
  To: gregkh; +Cc: stable

On Mon, 04 Sep 2017 12:39:21 +0200
<gregkh@linuxfoundation.org> wrote:

> The patch below does not apply to the 4.12-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>.

The patch context looks a bit different in 4.12. Fixed with this version
of the patch:
--
>From 66aa7812d5bc7a3488d75969067cfdae288c57fe Mon Sep 17 00:00:00 2001
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
Date: Thu, 31 Aug 2017 13:18:22 +0200
Subject: [PATCH] s390/mm: fix BUG_ON in crst_table_upgrade

commit 8ab867cb0806a8e195de161fd8883a0578d1d050 upstream.

A 31-bit compat process can force a BUG_ON in crst_table_upgrade
with specific, invalid mmap calls, e.g.

   mmap((void*) 0x7fff8000, 0x10000, 3, 32, -1, 0)

The arch_get_unmapped_area[_topdown] functions miss an if condition
in the decision to do a page table upgrade.

[ms: Backport to 4.12, minor context change]

Fixes: 9b11c7912d00 ("s390/mm: simplify arch_get_unmapped_area[_topdown]")
Cc: <stable@vger.kernel.org>  # v4.12+
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---
 arch/s390/mm/mmap.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
index b854b1da281a..888bee99fe64 100644
--- a/arch/s390/mm/mmap.c
+++ b/arch/s390/mm/mmap.c
@@ -119,7 +119,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 		return addr;
 
 check_asce_limit:
-	if (addr + len > current->mm->context.asce_limit) {
+	if (addr + len > current->mm->context.asce_limit &&
+	    addr + len <= TASK_SIZE) {
 		rc = crst_table_upgrade(mm);
 		if (rc)
 			return (unsigned long) rc;
@@ -183,7 +184,8 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
 	}
 
 check_asce_limit:
-	if (addr + len > current->mm->context.asce_limit) {
+	if (addr + len > current->mm->context.asce_limit &&
+	    addr + len <= TASK_SIZE) {
 		rc = crst_table_upgrade(mm);
 		if (rc)
 			return (unsigned long) rc;
-- 
2.13.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: FAILED: patch "[PATCH] s390/mm: fix BUG_ON in crst_table_upgrade" failed to apply to 4.12-stable tree
  2017-09-05  8:18 ` Martin Schwidefsky
@ 2017-09-07 14:38   ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2017-09-07 14:38 UTC (permalink / raw)
  To: Martin Schwidefsky; +Cc: stable

On Tue, Sep 05, 2017 at 10:18:42AM +0200, Martin Schwidefsky wrote:
> On Mon, 04 Sep 2017 12:39:21 +0200
> <gregkh@linuxfoundation.org> wrote:
> 
> > The patch below does not apply to the 4.12-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>.
> 
> The patch context looks a bit different in 4.12. Fixed with this version
> of the patch:

Thanks, that worked.

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-07 14:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-04 10:39 FAILED: patch "[PATCH] s390/mm: fix BUG_ON in crst_table_upgrade" failed to apply to 4.12-stable tree gregkh
2017-09-05  8:18 ` Martin Schwidefsky
2017-09-07 14:38   ` 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).