Skip to content

Commit

Permalink
[SPARC64]: Fix bugs in SYSV IPC handling in 64-bit processes.
Browse files Browse the repository at this point in the history
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: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Oct 14, 2007
1 parent fa7744d commit 7379b42
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions arch/sparc64/kernel/sys_sparc.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ asmlinkage long sparc_pipe(struct pt_regs *regs)
asmlinkage long sys_ipc(unsigned int call, int first, unsigned long second,
unsigned long third, void __user *ptr, long fifth)
{
int err;
long err;

/* No need for backward compatibility. We can start fresh... */
if (call <= SEMCTL) {
Expand All @@ -453,16 +453,9 @@ asmlinkage long sys_ipc(unsigned int call, int first, unsigned long second,
err = sys_semget(first, (int)second, (int)third);
goto out;
case SEMCTL: {
union semun fourth;
err = -EINVAL;
if (!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);
err = sys_semctl(first, third,
(int)second | IPC_64,
(union semun) ptr);
goto out;
}
default:
Expand Down

0 comments on commit 7379b42

Please sign in to comment.