diff options
author | KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> | 2006-02-10 04:51:12 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-02-10 11:13:12 -0500 |
commit | 8e36709d8cea48a4d341294ce2b46678a2e77159 (patch) | |
tree | bfb3f096c111e2feaab53e386e199d553df36482 | |
parent | c22db9412736204b25aeba19d18e5ea922f7d632 (diff) |
[PATCH] shmdt cannot detach not-alined shm segment cleanly.
sys_shmdt() can manage shm segments which are covered by multiple vmas. (This
can happen when a user uses mprotect() after shmat().)
This works well if shm is aligned to PAGE_SIZE, but if not, the last
segment cannot be detached. It is because a comparison in sys_shmdt()
(vma->vm_end - addr) < size
addr == return address of shmat()
size == shmsize, argments to shmget()
size should be aligned to PAGE_SIZE before being compared with vma->vm_end,
which is aligned.
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Manfred Spraul <manfred@colorfullife.com>
Acked-by: Hugh Dickins <hugh@veritas.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | ipc/shm.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -870,6 +870,7 @@ asmlinkage long sys_shmdt(char __user *shmaddr) | |||
870 | * could possibly have landed at. Also cast things to loff_t to | 870 | * could possibly have landed at. Also cast things to loff_t to |
871 | * prevent overflows and make comparisions vs. equal-width types. | 871 | * prevent overflows and make comparisions vs. equal-width types. |
872 | */ | 872 | */ |
873 | size = PAGE_ALIGN(size); | ||
873 | while (vma && (loff_t)(vma->vm_end - addr) <= size) { | 874 | while (vma && (loff_t)(vma->vm_end - addr) <= size) { |
874 | next = vma->vm_next; | 875 | next = vma->vm_next; |
875 | 876 | ||