Commit 7379b42b authored by David S. Miller's avatar David S. Miller

[SPARC64]: Fix bugs in SYSV IPC handling in 64-bit processes.

Thanks to Tom Callaway for the excellent bug report and
test case.

sys_ipc() has several problems, most to due with semaphore
call handling:

1) 'err' return should be a 'long'
2) "union semun" is passed in a register on 64-bit compared
   to 32-bit which provides it on the stack and therefore
   by reference
3) Second and third arguments to SEMCTL are swapped compared
   to 32-bit.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fa7744db
...@@ -436,7 +436,7 @@ asmlinkage long sparc_pipe(struct pt_regs *regs) ...@@ -436,7 +436,7 @@ asmlinkage long sparc_pipe(struct pt_regs *regs)
asmlinkage long sys_ipc(unsigned int call, int first, unsigned long second, asmlinkage long sys_ipc(unsigned int call, int first, unsigned long second,
unsigned long third, void __user *ptr, long fifth) unsigned long third, void __user *ptr, long fifth)
{ {
int err; long err;
/* No need for backward compatibility. We can start fresh... */ /* No need for backward compatibility. We can start fresh... */
if (call <= SEMCTL) { if (call <= SEMCTL) {
...@@ -453,16 +453,9 @@ asmlinkage long sys_ipc(unsigned int call, int first, unsigned long second, ...@@ -453,16 +453,9 @@ asmlinkage long sys_ipc(unsigned int call, int first, unsigned long second,
err = sys_semget(first, (int)second, (int)third); err = sys_semget(first, (int)second, (int)third);
goto out; goto out;
case SEMCTL: { case SEMCTL: {
union semun fourth; err = sys_semctl(first, third,
err = -EINVAL; (int)second | IPC_64,
if (!ptr) (union semun) ptr);
goto out;
err = -EFAULT;
if (get_user(fourth.__pad,
(void __user * __user *) ptr))
goto out;
err = sys_semctl(first, (int)second | IPC_64,
(int)third, fourth);
goto out; goto out;
} }
default: default:
......
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