Skip to content

Commit

Permalink
powerpc/signal64: Use __get_user() to copy sigset_t
Browse files Browse the repository at this point in the history
Usually sigset_t is exactly 8B which is a "trivial" size and does not
warrant using __copy_from_user(). Use __get_user() directly in
anticipation of future work to remove the trivial size optimizations
from __copy_from_user(). Calling __get_user() also results in a small
boost to signal handling throughput here.

Signed-off-by: Christopher M. Riedl <cmr@codefail.de>
  • Loading branch information
cmriedl authored and intel-lab-lkp committed Feb 3, 2021
1 parent cf2cc6f commit c6e40a9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions arch/powerpc/kernel/signal_64.c
Expand Up @@ -97,6 +97,14 @@ static void prepare_setup_sigcontext(struct task_struct *tsk, int ctx_has_vsx_re
#endif /* CONFIG_VSX */
}

static inline int get_user_sigset(sigset_t *dst, const sigset_t *src)
{
if (sizeof(sigset_t) <= 8)
return __get_user(dst->sig[0], &src->sig[0]);
else
return __copy_from_user(dst, src, sizeof(sigset_t));
}

/*
* Set up the sigcontext for the signal frame.
*/
Expand Down Expand Up @@ -701,8 +709,9 @@ SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx,
* We kill the task with a SIGSEGV in this situation.
*/

if (__copy_from_user(&set, &new_ctx->uc_sigmask, sizeof(set)))
if (get_user_sigset(&set, &new_ctx->uc_sigmask))
do_exit(SIGSEGV);

set_current_blocked(&set);

if (!user_read_access_begin(new_ctx, ctx_size))
Expand Down Expand Up @@ -740,8 +749,9 @@ SYSCALL_DEFINE0(rt_sigreturn)
if (!access_ok(uc, sizeof(*uc)))
goto badframe;

if (__copy_from_user(&set, &uc->uc_sigmask, sizeof(set)))
if (get_user_sigset(&set, &uc->uc_sigmask))
goto badframe;

set_current_blocked(&set);

#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
Expand Down

0 comments on commit c6e40a9

Please sign in to comment.