All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
To: Souptick Joarder <jrdr.linux@gmail.com>
Cc: "Matthew Wilcox" <willy@infradead.org>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Jérôme Glisse" <jglisse@redhat.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
	"Huang Ying" <ying.huang@intel.com>,
	"open list" <linux-kernel@vger.kernel.org>
Subject: [PATCH] mm: Fail when offset == num in first check of vm_map_pages_zero()
Date: Tue, 28 May 2019 22:05:40 +0200	[thread overview]
Message-ID: <20190528193004.GA7744@gmail.com> (raw)

If the user asks us for offset == num, we should already fail in the
first check, i.e. the one testing for offsets beyond the object.

At the moment, we are failing on the second test anyway,
since count cannot be 0. Still, to agree with the comment of the first
test, we should first there.

Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
---
 mm/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memory.c b/mm/memory.c
index ddf20bd0c317..74cf8b0ce353 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1547,7 +1547,7 @@ static int __vm_map_pages(struct vm_area_struct *vma, struct page **pages,
 	int ret, i;
 
 	/* Fail if the user requested offset is beyond the end of the object */
-	if (offset > num)
+	if (offset >= num)
 		return -ENXIO;
 
 	/* Fail if the user requested size exceeds available object size */
-- 
2.17.1


             reply	other threads:[~2019-05-28 20:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-28 20:05 Miguel Ojeda [this message]
2019-05-29  7:09 ` [PATCH] mm: Fail when offset == num in first check of vm_map_pages_zero() Souptick Joarder
2019-06-01 10:41   ` Miguel Ojeda

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=20190528193004.GA7744@gmail.com \
    --to=miguel.ojeda.sandonis@gmail.com \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=jglisse@redhat.com \
    --cc=jrdr.linux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=willy@infradead.org \
    --cc=ying.huang@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.