Commit 1e8a9345 authored by Andi Kleen's avatar Andi Kleen Committed by Linus Torvalds

[PATCH] Fix compat shmget overflow

This fixes an incorrect sign extension in the compat layer that breaks
32bit shmget that are >2GB.  sys_shmget has a signed size_t size argument,
and the int size argument coming from 32bit user space would get sign
extended to 64bit, which is wrong.

I fixed it on all compat architectures, except PPC64 which was already ok. 

It was originally debugged and fixed by Karl Rister @ IBM for SLES9 on x86-64.
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 46f4fe4b
......@@ -1415,7 +1415,7 @@ sys32_ipc(u32 call, int first, int second, int third, u32 ptr, u32 fifth)
case SHMDT:
return sys_shmdt(compat_ptr(ptr));
case SHMGET:
return sys_shmget(first, second, third);
return sys_shmget(first, (unsigned)second, third);
case SHMCTL:
return compat_sys_shmctl(first, second, compat_ptr(ptr));
......
......@@ -1115,7 +1115,7 @@ sys32_ipc (u32 call, int first, int second, int third, u32 ptr, u32 fifth)
err = sys_shmdt ((char *)A(ptr));
break;
case SHMGET:
err = sys_shmget (first, second, third);
err = sys_shmget (first, (unsigned)second, third);
break;
case SHMCTL:
err = do_sys32_shmctl (first, second, (void *)AA(ptr));
......
......@@ -331,7 +331,7 @@ asmlinkage long sys32_ipc(u32 call, int first, int second, int third, u32 ptr)
case SHMDT:
return sys_shmdt(compat_ptr(ptr));
case SHMGET:
return sys_shmget(first, second, third);
return sys_shmget(first, (unsigned)second, third);
case SHMCTL:
return compat_sys_shmctl(first, second, compat_ptr(ptr));
}
......
......@@ -835,7 +835,7 @@ asmlinkage long compat_sys_ipc(u32 call, int first, int second, int third, compa
err = sys_shmdt(ptr);
goto out;
case SHMGET:
err = sys_shmget(first, second, third);
err = sys_shmget(first, (unsigned)second, third);
goto out;
case SHMCTL:
err = do_sys32_shmctl(first, second, ptr);
......
......@@ -49,7 +49,7 @@ sys32_ipc(u32 call, int first, int second, int third,
case SHMDT:
return sys_shmdt(compat_ptr(ptr));
case SHMGET:
return sys_shmget(first, second, third);
return sys_shmget(first, (unsigned)second, third);
case SHMCTL:
return compat_sys_shmctl(first, second, compat_ptr(ptr));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment