Subject: PATCH: Fix offset of mmap

From: "H . J . Lu" <[email-masked]>
Date: Fri, 14 Sep 2001 10:07:00 -0700

We should check if offset of mmap is on the page boundary.

H.J.
---
--- /tmp/tmp.20947.0	Fri Sep 14 10:05:33 2001
+++ arch/mips/kernel/syscall.c	Fri Sep 14 10:05:08 2001
@@ -82,6 +82,8 @@ out:
 asmlinkage unsigned long old_mmap(unsigned long addr, size_t len, int prot,
                                   int flags, int fd, off_t offset)
 {
+	if (offset & ~PAGE_MASK)
+		return -EINVAL;
 	return do_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
 }

---

From: James Simmons <[email-masked]>
Date: Fri, 14 Sep 2001 10:10:58 -0700 (PDT)

> We should check if offset of mmap is on the page boundary.

I believe this would break certain pieces of hardware. For example the
mq200 framebuffer in the sigmarion is not paged aligned. You have to
supply a offset to make it work.

---

From: "H . J . Lu" <[email-masked]>
Date: Fri, 14 Sep 2001 10:15:49 -0700

> supply a offset to make it work.

How do you mmap a memory whose offset is not page aligned? The code
here is

					    ^^^^^^^^^^^^^^^^^^^^

It is up to the user code to make sure everything is ok.

H.J.

---

From: James Simmons <[email-masked]>
Date: Fri, 14 Sep 2001 10:27:20 -0700 (PDT)

> return do_mmap2(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);

Sorry. Mix up in the meaning of offset.