public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: DervishD <raul@pleyades.net>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Linux-kernel <linux-kernel@vger.kernel.org>, davem@redhat.com
Subject: [PATCH] mmap.c (do_mmap_pgoff) 'repatched'.
Date: Wed, 11 Dec 2002 14:23:38 +0100	[thread overview]
Message-ID: <20021211132338.GD48@DervishD> (raw)

[-- Attachment #1: Type: text/plain, Size: 631 bytes --]

    Hi Alan :))

    The patch I sent you for mmap.c, correcting a corner case,
namely the case where the requested size on a call to 'mmap()' was
greater than SIZE_MAX-PAGE_SIZE, because the size was incorrectly
page-aligned to size '0', does nothing if TASK_SIZE is the full
address space for the task. This happens, for example, under sparc64.

    This new patch covers this case and works even if TASK_SIZE is
very huge. My patch was completed by David S. Miller <davem@redhat.com>
and now should work for all cases.

    The patch is against your 2.4.20-ac1 tree. If you have any doubt,
please tell.

    Thanks ;)

    Raúl

[-- Attachment #2: mmap.c.diff --]
[-- Type: text/plain, Size: 827 bytes --]

--- linux/mm/mmap.c.orig	2002-12-11 14:08:39.000000000 +0100
+++ linux/mm/mmap.c	2002-12-11 14:09:54.000000000 +0100
@@ -473,10 +473,6 @@
 }
 
 
-/*
- *	NOTE: in this function we rely on TASK_SIZE being lower than
- *	SIZE_MAX-PAGE_SIZE at least. I'm pretty sure that it is.
- */
 
 unsigned long do_mmap_pgoff(struct file * file, unsigned long addr, unsigned long len,
 	unsigned long prot, unsigned long flags, unsigned long pgoff)
@@ -493,14 +489,14 @@
 	if (file && (!file->f_op || !file->f_op->mmap))
 		return -ENODEV;
 
-	if (!len)
+	if (len == 0)
 		return addr;
+	
+	len = PAGE_ALIGN(len);
 
-	if (len > TASK_SIZE)
+	if (len > TASK_SIZE || len == 0)
 		return -EINVAL;
 
-	len = PAGE_ALIGN(len);  /* This cannot be zero now */
-
 	/* offset overflow? */
 	if ((pgoff + (len >> PAGE_SHIFT)) < pgoff)
 		return -EINVAL;

                 reply	other threads:[~2002-12-11 13:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20021211132338.GD48@DervishD \
    --to=raul@pleyades.net \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=davem@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /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