From 5c49574ffd7ac07eae8c3b065d19e6ebc7e4760f Mon Sep 17 00:00:00 2001
From: Al Viro <viro@zeniv.linux.org.uk>
Date: Sun, 18 Nov 2012 15:29:16 -0500
Subject: [PATCH] new helper: restore_altstack()

to be used by rt_sigreturn instances

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 include/linux/signal.h | 2 ++
 kernel/signal.c        | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/include/linux/signal.h b/include/linux/signal.h
index e19a011b43b76..5969522136fee 100644
--- a/include/linux/signal.h
+++ b/include/linux/signal.h
@@ -385,4 +385,6 @@ int unhandled_signal(struct task_struct *tsk, int sig);
 
 void signals_init(void);
 
+int restore_altstack(const stack_t __user *);
+
 #endif /* _LINUX_SIGNAL_H */
diff --git a/kernel/signal.c b/kernel/signal.c
index e75e4bd2839bb..887f2fefe207e 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -3103,6 +3103,13 @@ do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long s
 	return error;
 }
 
+int restore_altstack(const stack_t __user *uss)
+{
+	int err = do_sigaltstack(uss, NULL, current_user_stack_pointer());
+	/* squash all but EFAULT for now */
+	return err == -EFAULT ? err : 0;
+}
+
 #ifdef __ARCH_WANT_SYS_SIGPENDING
 
 /**
-- 
GitLab