public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Li Wang <liwang@redhat.com>
To: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Cc: schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com,
	mingo@kernel.org, hughd@google.com, paul.gortmaker@windriver.com,
	mhocko@suse.com, shuwang@redhat.com, liwang@redhat.com
Subject: [PATCH] s390/mm: return -ENOMEM in arch_get_unmapped_area[_topdown]
Date: Thu, 26 Oct 2017 15:36:10 +0800	[thread overview]
Message-ID: <20171026073610.9139-1-liwang@redhat.com> (raw)

That would be very hard to get -ENOMEM returned in crst_table_upgrade()
because the condition(addr + len <= TASK_SIZE) makes all 'end' value
is smaller/equal than 'TASK_SIZE_TASK'. So let's move it to the upper
layer.

Fixes: 8ab867cb0806 (s390/mm: fix BUG_ON in crst_table_upgrade)
Signed-off-by: Li Wang <liwang@redhat.com>
---
 arch/s390/mm/mmap.c    | 6 ++++++
 arch/s390/mm/pgalloc.c | 3 +--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
index 5bea139..8ddb13a 100644
--- a/arch/s390/mm/mmap.c
+++ b/arch/s390/mm/mmap.c
@@ -119,6 +119,9 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 		return addr;
 
 check_asce_limit:
+	if (addr + len >= TASK_SIZE_MAX)
+		return -ENOMEM;
+
 	if (addr + len > current->mm->context.asce_limit &&
 	    addr + len <= TASK_SIZE) {
 		rc = crst_table_upgrade(mm, addr + len);
@@ -184,6 +187,9 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
 	}
 
 check_asce_limit:
+	if (addr + len >= TASK_SIZE_MAX)
+		return -ENOMEM;
+
 	if (addr + len > current->mm->context.asce_limit &&
 	    addr + len <= TASK_SIZE) {
 		rc = crst_table_upgrade(mm, addr + len);
diff --git a/arch/s390/mm/pgalloc.c b/arch/s390/mm/pgalloc.c
index 05f1f27..5e4b887 100644
--- a/arch/s390/mm/pgalloc.c
+++ b/arch/s390/mm/pgalloc.c
@@ -84,8 +84,7 @@ int crst_table_upgrade(struct mm_struct *mm, unsigned long end)
 
 	/* upgrade should only happen from 3 to 4, 3 to 5, or 4 to 5 levels */
 	VM_BUG_ON(mm->context.asce_limit < _REGION2_SIZE);
-	if (end >= TASK_SIZE_MAX)
-		return -ENOMEM;
+
 	rc = 0;
 	notify = 0;
 	while (mm->context.asce_limit < end) {
-- 
2.9.3

             reply	other threads:[~2017-10-26  7:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-26  7:36 Li Wang [this message]
2017-10-26  9:26 ` [PATCH] s390/mm: return -ENOMEM in arch_get_unmapped_area[_topdown] Martin Schwidefsky
2017-10-26  9:47   ` Li Wang
2017-10-26 10:16     ` Martin Schwidefsky
2017-11-09  4:36       ` Li Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171026073610.9139-1-liwang@redhat.com \
    --to=liwang@redhat.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mhocko@suse.com \
    --cc=mingo@kernel.org \
    --cc=paul.gortmaker@windriver.com \
    --cc=schwidefsky@de.ibm.com \
    --cc=shuwang@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox