linux-user: Restrict usage of sa_restorer

Reading and writing to an sa_restorer member that isn't supposed to
exist corrupts user memory.  Introduce TARGET_ARCH_HAS_SA_RESTORER,
similar to the kernel's __ARCH_HAS_SA_RESTORER.

Reported-by: Helge Deller <deller@gmx.de>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
This commit is contained in:
Richard Henderson 2017-10-31 13:53:52 +01:00 committed by Riku Voipio
parent b0fbe46ad8
commit 7f047de18c
2 changed files with 15 additions and 2 deletions

View file

@ -777,7 +777,7 @@ int do_sigaction(int sig, const struct target_sigaction *act,
if (oact) {
__put_user(k->_sa_handler, &oact->_sa_handler);
__put_user(k->sa_flags, &oact->sa_flags);
#if !defined(TARGET_MIPS)
#ifdef TARGET_ARCH_HAS_SA_RESTORER
__put_user(k->sa_restorer, &oact->sa_restorer);
#endif
/* Not swapped. */
@ -787,7 +787,7 @@ int do_sigaction(int sig, const struct target_sigaction *act,
/* FIXME: This is not threadsafe. */
__get_user(k->_sa_handler, &act->_sa_handler);
__get_user(k->sa_flags, &act->sa_flags);
#if !defined(TARGET_MIPS)
#ifdef TARGET_ARCH_HAS_SA_RESTORER
__get_user(k->sa_restorer, &act->sa_restorer);
#endif
/* To be swapped in target_to_host_sigset. */