mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gordon Jin <gordon.jin@intel.com>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, michael.fu@intel.com
Subject: [PATCH 2.6] fix mmap() return value to conform POSIX
Date: Tue, 15 Mar 2005 11:04:12 +0800	[thread overview]
Message-ID: <1110855852.26254.59.camel@yjin3-dev.sh.intel.com> (raw)
In-Reply-To: <1110794148.26254.45.camel@yjin3-dev.sh.intel.com>

This patch fixes 2 return values in mmap() to conform POSIX spec:

[EINVAL]
        The value of len is zero.
        
[ENOMEM]
        MAP_FIXED was specified, and the range [addr,addr+len) exceeds
        that allowed for the address space of a process; or, if
        MAP_FIXED was not specified and there is insufficient room in
        the address space to effect the mapping.

--- linux-2.6.11.3/mm/mmap.c.orig	2005-03-14 13:20:11.000000000 -0800
+++ linux-2.6.11.3/mm/mmap.c	2005-03-14 17:24:37.000000000 -0800
@@ -897,12 +897,12 @@ unsigned long do_mmap_pgoff(struct file 
 			prot |= PROT_EXEC;
 
 	if (!len)
-		return addr;
+		return -EINVAL;
 
 	/* Careful about overflows.. */
 	len = PAGE_ALIGN(len);
 	if (!len || len > TASK_SIZE)
-		return -EINVAL;
+		return -ENOMEM;
 
 	/* offset overflow? */
 	if ((pgoff + (len >> PAGE_SHIFT)) < pgoff)



      parent reply	other threads:[~2005-03-15  3:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-14  9:55 [PATCH 2.6] fix mprotect() with len=(size_t)(-1) to return -ENOMEM Gordon Jin
2005-03-14 10:08 ` Arjan van de Ven
2005-03-14 21:58   ` Ingo Oeser
2005-03-15  3:04 ` Gordon Jin [this message]

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=1110855852.26254.59.camel@yjin3-dev.sh.intel.com \
    --to=gordon.jin@intel.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.fu@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®