mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiaxun Yang <jiaxun.yang@flygoat.com>
To: Tiezhu Yang <yangtiezhu@loongson.cn>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Xuefeng Li <lixuefeng@loongson.cn>,
	linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] MIPS: signal: Return immediately if call fails
Date: Sat, 18 Dec 2021 14:08:10 +0000	[thread overview]
Message-ID: <a04357b6-c762-ebbe-e983-ee2890b97be9@flygoat.com> (raw)
In-Reply-To: <1639797789-3001-3-git-send-email-yangtiezhu@loongson.cn>



在 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 <yangtiezhu@loongson.cn>
> ---
>   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;
>   


  reply	other threads:[~2021-12-18 14:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-18  3:23 [PATCH 0/3] MIPS: signal: Modify some code Tiezhu Yang
2021-12-18  3:23 ` [PATCH 1/3] MIPS: signal: Protect against sigaltstack wraparound Tiezhu Yang
2021-12-18  3:23 ` [PATCH 2/3] MIPS: signal: Return immediately if call fails Tiezhu Yang
2021-12-18 14:08   ` Jiaxun Yang [this message]
2021-12-20  2:25     ` Tiezhu Yang
2021-12-18  3:23 ` [PATCH 3/3] MIPS: signal: Remove unnecessary DEBUG_SIG related code Tiezhu Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a04357b6-c762-ebbe-e983-ee2890b97be9@flygoat.com \
    --to=jiaxun.yang@flygoat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=lixuefeng@loongson.cn \
    --cc=tsbogend@alpha.franken.de \
    --cc=yangtiezhu@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®