Skip to content

Commit

Permalink
select: shift restore_saved_sigmask_unless() into poll_select_copy_re…
Browse files Browse the repository at this point in the history
…maining()

Now that restore_saved_sigmask_unless() is always called with the same
argument right before poll_select_copy_remaining() we can move it into
poll_select_copy_remaining() and make it the only caller of restore() in
fs/select.c.

The patch also renames poll_select_copy_remaining(),
poll_select_finish() looks better after this change.

kern_select() doesn't use set_user_sigmask(), so in this case
poll_select_finish() does restore_saved_sigmask_unless() "for no
reason".  But this won't hurt, and WARN_ON(!TIF_SIGPENDING) is still
valid.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Oleg Nesterov <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: David Laight <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Cc: Deepa Dinamani <[email protected]>
Cc: Eric W. Biederman <[email protected]>
Cc: Eric Wong <[email protected]>
Cc: Jason Baron <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
oleg-nesterov authored and torvalds committed Jul 17, 2019
1 parent 8cf8b55 commit ac30102
Showing 1 changed file with 13 additions and 33 deletions.
46 changes: 13 additions & 33 deletions fs/select.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,14 @@ enum poll_time_type {
PT_OLD_TIMESPEC = 3,
};

static int poll_select_copy_remaining(struct timespec64 *end_time,
void __user *p,
enum poll_time_type pt_type, int ret)
static int poll_select_finish(struct timespec64 *end_time,
void __user *p,
enum poll_time_type pt_type, int ret)
{
struct timespec64 rts;

restore_saved_sigmask_unless(ret == -ERESTARTNOHAND);

if (!p)
return ret;

Expand Down Expand Up @@ -714,9 +716,7 @@ static int kern_select(int n, fd_set __user *inp, fd_set __user *outp,
}

ret = core_sys_select(n, inp, outp, exp, to);
ret = poll_select_copy_remaining(&end_time, tvp, PT_TIMEVAL, ret);

return ret;
return poll_select_finish(&end_time, tvp, PT_TIMEVAL, ret);
}

SYSCALL_DEFINE5(select, int, n, fd_set __user *, inp, fd_set __user *, outp,
Expand Down Expand Up @@ -757,10 +757,7 @@ static long do_pselect(int n, fd_set __user *inp, fd_set __user *outp,
return ret;

ret = core_sys_select(n, inp, outp, exp, to);
restore_saved_sigmask_unless(ret == -ERESTARTNOHAND);
ret = poll_select_copy_remaining(&end_time, tsp, type, ret);

return ret;
return poll_select_finish(&end_time, tsp, type, ret);
}

/*
Expand Down Expand Up @@ -1102,10 +1099,7 @@ SYSCALL_DEFINE5(ppoll, struct pollfd __user *, ufds, unsigned int, nfds,
return ret;

ret = do_sys_poll(ufds, nfds, to);
restore_saved_sigmask_unless(ret == -ERESTARTNOHAND);
ret = poll_select_copy_remaining(&end_time, tsp, PT_TIMESPEC, ret);

return ret;
return poll_select_finish(&end_time, tsp, PT_TIMESPEC, ret);
}

#if defined(CONFIG_COMPAT_32BIT_TIME) && !defined(CONFIG_64BIT)
Expand All @@ -1131,10 +1125,7 @@ SYSCALL_DEFINE5(ppoll_time32, struct pollfd __user *, ufds, unsigned int, nfds,
return ret;

ret = do_sys_poll(ufds, nfds, to);
restore_saved_sigmask_unless(ret == -ERESTARTNOHAND);
ret = poll_select_copy_remaining(&end_time, tsp, PT_OLD_TIMESPEC, ret);

return ret;
return poll_select_finish(&end_time, tsp, PT_OLD_TIMESPEC, ret);
}
#endif

Expand Down Expand Up @@ -1271,9 +1262,7 @@ static int do_compat_select(int n, compat_ulong_t __user *inp,
}

ret = compat_core_sys_select(n, inp, outp, exp, to);
ret = poll_select_copy_remaining(&end_time, tvp, PT_OLD_TIMEVAL, ret);

return ret;
return poll_select_finish(&end_time, tvp, PT_OLD_TIMEVAL, ret);
}

COMPAT_SYSCALL_DEFINE5(select, int, n, compat_ulong_t __user *, inp,
Expand Down Expand Up @@ -1333,10 +1322,7 @@ static long do_compat_pselect(int n, compat_ulong_t __user *inp,
return ret;

ret = compat_core_sys_select(n, inp, outp, exp, to);
restore_saved_sigmask_unless(ret == -ERESTARTNOHAND);
ret = poll_select_copy_remaining(&end_time, tsp, type, ret);

return ret;
return poll_select_finish(&end_time, tsp, type, ret);
}

COMPAT_SYSCALL_DEFINE6(pselect6_time64, int, n, compat_ulong_t __user *, inp,
Expand Down Expand Up @@ -1405,10 +1391,7 @@ COMPAT_SYSCALL_DEFINE5(ppoll_time32, struct pollfd __user *, ufds,
return ret;

ret = do_sys_poll(ufds, nfds, to);
restore_saved_sigmask_unless(ret == -ERESTARTNOHAND);
ret = poll_select_copy_remaining(&end_time, tsp, PT_OLD_TIMESPEC, ret);

return ret;
return poll_select_finish(&end_time, tsp, PT_OLD_TIMESPEC, ret);
}
#endif

Expand All @@ -1434,10 +1417,7 @@ COMPAT_SYSCALL_DEFINE5(ppoll_time64, struct pollfd __user *, ufds,
return ret;

ret = do_sys_poll(ufds, nfds, to);
restore_saved_sigmask_unless(ret == -ERESTARTNOHAND);
ret = poll_select_copy_remaining(&end_time, tsp, PT_TIMESPEC, ret);

return ret;
return poll_select_finish(&end_time, tsp, PT_TIMESPEC, ret);
}

#endif

0 comments on commit ac30102

Please sign in to comment.