When debug sigaltstack(), copy_siginfo_to_user() fails first in
setup_rt_frame() if the alternate signal stack is too small, so
it should return immediately if call fails, no need to call the
following functions.
Signed-off-by: Tiezhu Yang <[email protected]>
---
arch/mips/kernel/signal.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
index c1632e8..4cd3969 100644
--- a/arch/mips/kernel/signal.c
+++ b/arch/mips/kernel/signal.c
@@ -761,15 +761,28 @@ static int setup_rt_frame(void *sig_return, struct ksignal *ksig,
return -EFAULT;
/* Create siginfo. */
- err |= copy_siginfo_to_user(&frame->rs_info, &ksig->info);
+ err = copy_siginfo_to_user(&frame->rs_info, &ksig->info);
+ if (err)
+ return -EFAULT;
/* Create the ucontext. */
- err |= __put_user(0, &frame->rs_uc.uc_flags);
- err |= __put_user(NULL, &frame->rs_uc.uc_link);
- err |= __save_altstack(&frame->rs_uc.uc_stack, regs->regs[29]);
- err |= setup_sigcontext(regs, &frame->rs_uc.uc_mcontext);
- err |= __copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set));
+ err = __put_user(0, &frame->rs_uc.uc_flags);
+ if (err)
+ return -EFAULT;
+
+ err = __put_user(NULL, &frame->rs_uc.uc_link);
+ if (err)
+ return -EFAULT;
+
+ err = __save_altstack(&frame->rs_uc.uc_stack, regs->regs[29]);
+ if (err)
+ return -EFAULT;
+
+ err = setup_sigcontext(regs, &frame->rs_uc.uc_mcontext);
+ if (err)
+ return -EFAULT;
+ err = __copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set));
if (err)
return -EFAULT;
--
2.1.0
在 2021/12/18 3:23, Tiezhu Yang 写道:
> When debug sigaltstack(), copy_siginfo_to_user() fails first in
> setup_rt_frame() if the alternate signal stack is too small, so
> it should return immediately if call fails, no need to call the
> following functions.
Hi Tiezhu,
Thanks for your patch.
If we are doing so I see no reason for keeping the err variable.
Just
if (copy_siginfo_to_user(&frame->rs_info, &ksig->info))
return -EFAULT;
seems much more clear.
Thanks.
- Jiaxun
>
> Signed-off-by: Tiezhu Yang <[email protected]>
> ---
> arch/mips/kernel/signal.c | 25 +++++++++++++++++++------
> 1 file changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
> index c1632e8..4cd3969 100644
> --- a/arch/mips/kernel/signal.c
> +++ b/arch/mips/kernel/signal.c
> @@ -761,15 +761,28 @@ static int setup_rt_frame(void *sig_return, struct ksignal *ksig,
> return -EFAULT;
>
> /* Create siginfo. */
> - err |= copy_siginfo_to_user(&frame->rs_info, &ksig->info);
> + err = copy_siginfo_to_user(&frame->rs_info, &ksig->info);
> + if (err)
> + return -EFAULT;
>
> /* Create the ucontext. */
> - err |= __put_user(0, &frame->rs_uc.uc_flags);
> - err |= __put_user(NULL, &frame->rs_uc.uc_link);
> - err |= __save_altstack(&frame->rs_uc.uc_stack, regs->regs[29]);
> - err |= setup_sigcontext(regs, &frame->rs_uc.uc_mcontext);
> - err |= __copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set));
> + err = __put_user(0, &frame->rs_uc.uc_flags);
> + if (err)
> + return -EFAULT;
> +
> + err = __put_user(NULL, &frame->rs_uc.uc_link);
> + if (err)
> + return -EFAULT;
> +
> + err = __save_altstack(&frame->rs_uc.uc_stack, regs->regs[29]);
> + if (err)
> + return -EFAULT;
> +
> + err = setup_sigcontext(regs, &frame->rs_uc.uc_mcontext);
> + if (err)
> + return -EFAULT;
>
> + err = __copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set));
> if (err)
> return -EFAULT;
>
On 12/18/2021 10:08 PM, Jiaxun Yang wrote:
>
>
> 在 2021/12/18 3:23, Tiezhu Yang 写道:
>> When debug sigaltstack(), copy_siginfo_to_user() fails first in
>> setup_rt_frame() if the alternate signal stack is too small, so
>> it should return immediately if call fails, no need to call the
>> following functions.
>
> Hi Tiezhu,
>
> Thanks for your patch.
> If we are doing so I see no reason for keeping the err variable.
> Just
>
> if (copy_siginfo_to_user(&frame->rs_info, &ksig->info))
> return -EFAULT;
>
> seems much more clear.
OK, thank you, I will send v2 later.
Thanks,
Tiezhu
>
> Thanks.
>
> - Jiaxun
>