Skip to contentSkip to conversation

PATCH: Fix offset of mmap

PATCH H . J . Lu 2 participants 4 messages Sep 14, 2001 MIPS

lore
Share & tools
lore

H . J . Lu

author
#0 lore raw

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

H.J.
---

mips/kernel/syscall.c renamed from tmp/tmp.20947.0 +2 -0
@@ -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);
 }
 
#1 lore raw
Quoted 2 lines

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.

author
#2 lore raw
Quoted 6 lines · James Simmons
Quoted 2 lines

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.

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

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

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

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

H.J.

#3 lore raw
Quoted 5 lines
Quoted 4 lines

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.

Quoted 7 lines

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

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

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

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

Sorry. Mix up in the meaning of offset.