All of lore.kernel.org
 help / color / mirror / Atom feed
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
To: vagabon.xyz@gmail.com
Cc: ralf@linux-mips.org, linux-mips@linux-mips.org
Subject: Re: [PATCH 9/10] signal: do not use save_static_function() anymore
Date: Thu, 08 Feb 2007 22:36:37 +0900 (JST)	[thread overview]
Message-ID: <20070208.223637.108120499.anemo@mba.ocn.ne.jp> (raw)
In-Reply-To: <cda58cb80702080053m6f22dc15td3b8c447e2abbda1@mail.gmail.com>

On Thu, 8 Feb 2007 09:53:18 +0100, "Franck Bui-Huu" <vagabon.xyz@gmail.com> wrote:
> I tried the following patch:
> 
> diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
> index 229276a..046fb1b 100644
> --- a/arch/mips/kernel/signal.c
> +++ b/arch/mips/kernel/signal.c
> @@ -68,7 +68,9 @@ int setup_sigcontext(struct pt_regs *regs, struct
> sigcontext __user *sc)
>  	err |= __put_user(regs->cp0_epc, &sc->sc_pc);
> 
>  	err |= __put_user(0, &sc->sc_regs[0]);
> -	for (i = 1; i < 32; i++)
> +	for (i = 1; i < 16; i++)
> +		err |= __put_user(regs->regs[i], &sc->sc_regs[i]);
> +	for (i = 24; i < 32; i++)
>  		err |= __put_user(regs->regs[i], &sc->sc_regs[i]);
> 
>  	err |= __put_user(regs->hi, &sc->sc_mdhi);
> @@ -126,7 +128,9 @@ int restore_sigcontext(struct pt_regs *regs,
> struct sigcontext __user *sc)
>  		err |= __get_user(treg, &sc->sc_dsp); wrdsp(treg, DSP_MASK);
>  	}
> 
> -	for (i = 1; i < 32; i++)
> +	for (i = 1; i < 16; i++)
> +		err |= __get_user(regs->regs[i], &sc->sc_regs[i]);
> +	for (i = 24; i < 32; i++)
>  		err |= __get_user(regs->regs[i], &sc->sc_regs[i]);
> 
>  	err |= __get_user(used_math, &sc->sc_used_math);
> 
> ...and it still passes LTP tests.
> 
> Someone reported that not saving/restoring static registers may break
> user tools but the gain is important I think.

NO!  This change might silently corrupt static registers!

If you did not restore static registers in kernel stack on
restore_sigcontext(), succeeding RESTORE_STATIC in restore_all will
load garbages to static registers.

Note that any hardware interrupts in middle of signal handler
overwrite pt_regs area in kernel stack.

I can still remember random static register corruption bug and how
hard to debug ...

---
Atsushi Nemoto

  reply	other threads:[~2007-02-08 13:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-05 14:24 [PATCH 0/10] Clean up signal code [take #3] Franck Bui-Huu
2007-02-05 14:24 ` [PATCH 1/10] signals: reduce {setup,restore}_sigcontext sizes Franck Bui-Huu
2007-02-05 14:24 ` [PATCH 2/10] signal: do not inline functions in signal-common.h Franck Bui-Huu
2007-02-05 14:24 ` [PATCH 3/10] signal: clean up sigframe structure Franck Bui-Huu
2007-02-05 14:24 ` [PATCH 4/10] signal32: remove code duplication Franck Bui-Huu
2007-02-05 14:24 ` [PATCH 5/10] signal: test return value of install_sigtramp() Franck Bui-Huu
2007-02-05 14:24 ` [PATCH 6/10] signal: factorize debug code Franck Bui-Huu
2007-02-05 14:24 ` [PATCH 7/10] signal32: reduce {setup,restore}_sigcontext32 sizes Franck Bui-Huu
2007-02-05 14:24 ` [PATCH 8/10] signal32: no need to save c0_status register in setup_sigcontext32() Franck Bui-Huu
2007-02-05 14:24 ` [PATCH 9/10] signal: do not use save_static_function() anymore Franck Bui-Huu
2007-02-07 15:40   ` Atsushi Nemoto
2007-02-08  8:53     ` Franck Bui-Huu
2007-02-08 13:36       ` Atsushi Nemoto [this message]
2007-02-08 15:39         ` Franck Bui-Huu
2007-02-08 16:35           ` Atsushi Nemoto
2007-02-08 20:05             ` Franck Bui-Huu
2007-02-05 14:24 ` [PATCH 10/10] signal: do not inline handle_signal() Franck Bui-Huu
2007-02-07 16:04 ` [PATCH 0/10] Clean up signal code [take #3] Atsushi Nemoto
2007-02-08  8:55   ` Franck Bui-Huu
2007-02-08  9:16     ` Franck Bui-Huu
2007-02-08 13:15       ` Atsushi Nemoto

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=20070208.223637.108120499.anemo@mba.ocn.ne.jp \
    --to=anemo@mba.ocn.ne.jp \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    --cc=vagabon.xyz@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.