Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit afe05d41 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull ARC fix from Vineet Gupta:
 "Chrisitian found/fixed issue with SA_SIGINFO based signal handler
  corrupting the user space registers post after signal handling"

* 'for-curr' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc:
  ARC: Fix signal frame management for SA_SIGINFO
parents c15f5bbc 10469350
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -101,7 +101,6 @@ SYSCALL_DEFINE0(rt_sigreturn)
{
	struct rt_sigframe __user *sf;
	unsigned int magic;
	int err;
	struct pt_regs *regs = current_pt_regs();

	/* Always make any pending restarted system calls return -EINTR */
@@ -119,15 +118,16 @@ SYSCALL_DEFINE0(rt_sigreturn)
	if (!access_ok(VERIFY_READ, sf, sizeof(*sf)))
		goto badframe;

	err = restore_usr_regs(regs, sf);
	err |= __get_user(magic, &sf->sigret_magic);
	if (err)
	if (__get_user(magic, &sf->sigret_magic))
		goto badframe;

	if (unlikely(is_do_ss_needed(magic)))
		if (restore_altstack(&sf->uc.uc_stack))
			goto badframe;

	if (restore_usr_regs(regs, sf))
		goto badframe;

	/* Don't restart from sigreturn */
	syscall_wont_restart(regs);

@@ -190,6 +190,15 @@ setup_rt_frame(int signo, struct k_sigaction *ka, siginfo_t *info,
	if (!sf)
		return 1;

	/*
	 * w/o SA_SIGINFO, struct ucontext is partially populated (only
	 * uc_mcontext/uc_sigmask) for kernel's normal user state preservation
	 * during signal handler execution. This works for SA_SIGINFO as well
	 * although the semantics are now overloaded (the same reg state can be
	 * inspected by userland: but are they allowed to fiddle with it ?
	 */
	err |= stash_usr_regs(sf, regs, set);

	/*
	 * SA_SIGINFO requires 3 args to signal handler:
	 *  #1: sig-no (common to any handler)
@@ -213,14 +222,6 @@ setup_rt_frame(int signo, struct k_sigaction *ka, siginfo_t *info,
		magic = MAGIC_SIGALTSTK;
	}

	/*
	 * w/o SA_SIGINFO, struct ucontext is partially populated (only
	 * uc_mcontext/uc_sigmask) for kernel's normal user state preservation
	 * during signal handler execution. This works for SA_SIGINFO as well
	 * although the semantics are now overloaded (the same reg state can be
	 * inspected by userland: but are they allowed to fiddle with it ?
	 */
	err |= stash_usr_regs(sf, regs, set);
	err |= __put_user(magic, &sf->sigret_magic);
	if (err)
		return err;