From: Hugh Dickins SUSv3 says the shmdt() function shall fail with EINVAL if the value of shmaddr is not the data segment start address of a shared memory segment: our sys_shmdt needs to reject a shmaddr which is not page-aligned. Does it have the potential to break existing apps? Hugh says "sys_shmdt() just does the wrong (unexpected) thing with a misaligned address: it'll fail on what you might expect it to succeed on, and only succeed on what it should definitely fail on. "That is, I think it behaves as if shmaddr gets rounded up, when the only understandable behaviour would be if it rounded it down. "Which does mean you'd have to be devious to see anything but EINVAL from a misaligned shmaddr there, so it's not terribly important." Signed-off-by: Hugh Dickins Signed-off-by: Andrew Morton --- ipc/shm.c | 3 +++ 1 files changed, 3 insertions(+) diff -puN ipc/shm.c~shmdt-check-address-aligment ipc/shm.c --- devel/ipc/shm.c~shmdt-check-address-aligment 2006-02-27 20:58:18.000000000 -0800 +++ devel-akpm/ipc/shm.c 2006-02-27 20:58:18.000000000 -0800 @@ -816,6 +816,9 @@ asmlinkage long sys_shmdt(char __user *s loff_t size = 0; int retval = -EINVAL; + if (addr & ~PAGE_MASK) + return retval; + down_write(&mm->mmap_sem); /* _