Skip to content

Commit 176826a

Browse files
ldv-altAl Viro
authored and
Al Viro
committed
signal: lift sigset size check out of do_sigpending()
As sigsetsize argument of do_sigpending() is not used anywhere else in that function after the check, remove this argument and move the check out of do_sigpending() into rt_sigpending() and its compat analog. Suggested-by: Al Viro <[email protected]> Signed-off-by: Dmitry V. Levin <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 1681634 commit 176826a

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

kernel/signal.c

+14-7
Original file line numberDiff line numberDiff line change
@@ -2629,11 +2629,8 @@ COMPAT_SYSCALL_DEFINE4(rt_sigprocmask, int, how, compat_sigset_t __user *, nset,
26292629
}
26302630
#endif
26312631

2632-
static int do_sigpending(void *set, unsigned long sigsetsize)
2632+
static int do_sigpending(sigset_t *set)
26332633
{
2634-
if (sigsetsize > sizeof(sigset_t))
2635-
return -EINVAL;
2636-
26372634
spin_lock_irq(&current->sighand->siglock);
26382635
sigorsets(set, &current->pending.signal,
26392636
&current->signal->shared_pending.signal);
@@ -2653,7 +2650,12 @@ static int do_sigpending(void *set, unsigned long sigsetsize)
26532650
SYSCALL_DEFINE2(rt_sigpending, sigset_t __user *, uset, size_t, sigsetsize)
26542651
{
26552652
sigset_t set;
2656-
int err = do_sigpending(&set, sigsetsize);
2653+
int err;
2654+
2655+
if (sigsetsize > sizeof(*uset))
2656+
return -EINVAL;
2657+
2658+
err = do_sigpending(&set);
26572659
if (!err && copy_to_user(uset, &set, sigsetsize))
26582660
err = -EFAULT;
26592661
return err;
@@ -2664,7 +2666,12 @@ COMPAT_SYSCALL_DEFINE2(rt_sigpending, compat_sigset_t __user *, uset,
26642666
compat_size_t, sigsetsize)
26652667
{
26662668
sigset_t set;
2667-
int err = do_sigpending(&set, sigsetsize);
2669+
int err;
2670+
2671+
if (sigsetsize > sizeof(*uset))
2672+
return -EINVAL;
2673+
2674+
err = do_sigpending(&set);
26682675
if (!err)
26692676
err = put_compat_sigset(uset, &set, sigsetsize);
26702677
return err;
@@ -3331,7 +3338,7 @@ SYSCALL_DEFINE1(sigpending, old_sigset_t __user *, set)
33313338
COMPAT_SYSCALL_DEFINE1(sigpending, compat_old_sigset_t __user *, set32)
33323339
{
33333340
sigset_t set;
3334-
int err = do_sigpending(&set, sizeof(set.sig[0]));
3341+
int err = do_sigpending(&set);
33353342
if (!err)
33363343
err = put_user(set.sig[0], set32);
33373344
return err;

0 commit comments

Comments
 (0)