Skip to content

Commit

Permalink
Fix compat_sys_sigpending breakage
Browse files Browse the repository at this point in the history
The latest change of compat_sys_sigpending in commit 8f13621
("sigpending(): move compat to native") has broken it in two ways.

First, it tries to write 4 bytes more than userspace expects:
sizeof(old_sigset_t) == sizeof(long) == 8 instead of
sizeof(compat_old_sigset_t) == sizeof(u32) == 4.

Second, on big endian architectures these bytes are being written in the
wrong order.

This bug was found by strace test suite.

Reported-by: Anatoly Pugachev <[email protected]>
Inspired-by: Eugene Syromyatnikov <[email protected]>
Fixes: 8f13621 ("sigpending(): move compat to native")
Signed-off-by: Dmitry V. Levin <[email protected]>
Acked-by: Al Viro <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
ldv-alt authored and torvalds committed Aug 6, 2017
1 parent 0fdd951 commit fbb7761
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -3303,12 +3303,15 @@ SYSCALL_DEFINE1(sigpending, old_sigset_t __user *, set)
#ifdef CONFIG_COMPAT
COMPAT_SYSCALL_DEFINE1(sigpending, compat_old_sigset_t __user *, set32)
{
#ifdef __BIG_ENDIAN
sigset_t set;
int err = do_sigpending(&set, sizeof(old_sigset_t));
if (err == 0)
if (copy_to_user(set32, &set, sizeof(old_sigset_t)))
err = -EFAULT;
int err = do_sigpending(&set, sizeof(set.sig[0]));
if (!err)
err = put_user(set.sig[0], set32);
return err;
#else
return sys_rt_sigpending((sigset_t __user *)set32, sizeof(*set32));
#endif
}
#endif

Expand Down

0 comments on commit fbb7761

Please sign in to comment.