mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
To: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Xuefeng Li <lixuefeng@loongson.cn>,
	linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] MIPS: signal: Return immediately if call fails
Date: Sun, 2 Jan 2022 14:31:22 +0100	[thread overview]
Message-ID: <20220102133122.GG3468@alpha.franken.de> (raw)
In-Reply-To: <1639974460-3278-3-git-send-email-yangtiezhu@loongson.cn>

On Mon, Dec 20, 2021 at 12:27:39PM +0800, Tiezhu Yang wrote:
> 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 <yangtiezhu@loongson.cn>
> ---
>  arch/mips/kernel/signal.c | 20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
> index c1632e8..5bce782 100644
> --- a/arch/mips/kernel/signal.c
> +++ b/arch/mips/kernel/signal.c
> @@ -754,23 +754,25 @@ static int setup_rt_frame(void *sig_return, struct ksignal *ksig,
>  			  struct pt_regs *regs, sigset_t *set)
>  {
>  	struct rt_sigframe __user *frame;
> -	int err = 0;
>  
>  	frame = get_sigframe(ksig, regs, sizeof(*frame));
>  	if (!access_ok(frame, sizeof (*frame)))
>  		return -EFAULT;
>  
>  	/* Create siginfo.  */
> -	err |= copy_siginfo_to_user(&frame->rs_info, &ksig->info);
> +	if (copy_siginfo_to_user(&frame->rs_info, &ksig->info))
> +		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));
> -
> -	if (err)
> +	if (__put_user(0, &frame->rs_uc.uc_flags))
> +		return -EFAULT;
> +	if (__put_user(NULL, &frame->rs_uc.uc_link))
> +		return -EFAULT;
> +	if (__save_altstack(&frame->rs_uc.uc_stack, regs->regs[29]))
> +		return -EFAULT;
> +	if (setup_sigcontext(regs, &frame->rs_uc.uc_mcontext))
> +		return -EFAULT;
> +	if (__copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set)))
>  		return -EFAULT;
>  
>  	/*
> -- 
> 2.1.0

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

  reply	other threads:[~2022-01-02 13:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-20  4:27 [PATCH v2 0/3] MIPS: signal: Modify some code Tiezhu Yang
2021-12-20  4:27 ` [PATCH v2 1/3] MIPS: signal: Protect against sigaltstack wraparound Tiezhu Yang
2022-01-02 13:31   ` Thomas Bogendoerfer
2021-12-20  4:27 ` [PATCH v2 2/3] MIPS: signal: Return immediately if call fails Tiezhu Yang
2022-01-02 13:31   ` Thomas Bogendoerfer [this message]
2021-12-20  4:27 ` [PATCH v2 3/3] MIPS: signal: Remove unnecessary DEBUG_SIG related code Tiezhu Yang
2022-01-02 13:32   ` Thomas Bogendoerfer
2022-01-18 16:01     ` Maciej W. Rozycki

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=20220102133122.GG3468@alpha.franken.de \
    --to=tsbogend@alpha.franken.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=lixuefeng@loongson.cn \
    --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

Powered by JetHome