Merge branch 'core-signals-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull core signal updates from Ingo Molnar: "These updates from Stas Sergeev and Andy Lutomirski, improve the sigaltstack interface by extending its ABI with the SS_AUTODISARM feature, which makes it possible to use swapcontext() in a sighandler that works on sigaltstack. Without this flag, the subsequent signal will corrupt the state of the switched-away sighandler. The inspiration is more robust dosemu signal handling" * 'core-signals-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: signals/sigaltstack: Change SS_AUTODISARM to (1U << 31) signals/sigaltstack: Report current flag bits in sigaltstack() selftests/sigaltstack: Fix the sigaltstack test on old kernels signals/sigaltstack: If SS_AUTODISARM, bypass on_sig_stack() selftests/sigaltstack: Add new testcase for sigaltstack(SS_ONSTACK|SS_AUTODISARM) signals/sigaltstack: Implement SS_AUTODISARM flag signals/sigaltstack: Prepare to add new SS_xxx flags signals/sigaltstack, x86/signals: Unify the x86 sigaltstack check with other architectures
This commit is contained in:
@@ -1595,6 +1595,7 @@ struct task_struct {
|
||||
|
||||
unsigned long sas_ss_sp;
|
||||
size_t sas_ss_size;
|
||||
unsigned sas_ss_flags;
|
||||
|
||||
struct callback_head *task_works;
|
||||
|
||||
@@ -2574,6 +2575,18 @@ static inline int kill_cad_pid(int sig, int priv)
|
||||
*/
|
||||
static inline int on_sig_stack(unsigned long sp)
|
||||
{
|
||||
/*
|
||||
* If the signal stack is SS_AUTODISARM then, by construction, we
|
||||
* can't be on the signal stack unless user code deliberately set
|
||||
* SS_AUTODISARM when we were already on it.
|
||||
*
|
||||
* This improves reliability: if user state gets corrupted such that
|
||||
* the stack pointer points very close to the end of the signal stack,
|
||||
* then this check will enable the signal to be handled anyway.
|
||||
*/
|
||||
if (current->sas_ss_flags & SS_AUTODISARM)
|
||||
return 0;
|
||||
|
||||
#ifdef CONFIG_STACK_GROWSUP
|
||||
return sp >= current->sas_ss_sp &&
|
||||
sp - current->sas_ss_sp < current->sas_ss_size;
|
||||
@@ -2591,6 +2604,13 @@ static inline int sas_ss_flags(unsigned long sp)
|
||||
return on_sig_stack(sp) ? SS_ONSTACK : 0;
|
||||
}
|
||||
|
||||
static inline void sas_ss_reset(struct task_struct *p)
|
||||
{
|
||||
p->sas_ss_sp = 0;
|
||||
p->sas_ss_size = 0;
|
||||
p->sas_ss_flags = SS_DISABLE;
|
||||
}
|
||||
|
||||
static inline unsigned long sigsp(unsigned long sp, struct ksignal *ksig)
|
||||
{
|
||||
if (unlikely((ksig->ka.sa.sa_flags & SA_ONSTACK)) && ! sas_ss_flags(sp))
|
||||
|
Reference in New Issue
Block a user