[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <56D3E546.5010403@list.ru>
Date: Mon, 29 Feb 2016 09:29:26 +0300
From: Stas Sergeev <stsp@...t.ru>
To: stsp@...t.ru
Cc: Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Richard Weinberger <richard@....at>,
Andrew Morton <akpm@...ux-foundation.org>,
Oleg Nesterov <oleg@...hat.com>, Tejun Heo <tj@...nel.org>,
Heinrich Schuchardt <xypron.glpk@....de>,
Jason Low <jason.low2@...com>,
Andrea Arcangeli <aarcange@...hat.com>,
Frederic Weisbecker <fweisbec@...il.com>,
Konstantin Khlebnikov <khlebnikov@...dex-team.ru>,
Josh Triplett <josh@...htriplett.org>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Aleksa Sarai <cyphar@...har.com>,
Amanieu d'Antras <amanieu@...il.com>,
Paul Moore <pmoore@...hat.com>,
Sasha Levin <sasha.levin@...cle.com>,
Palmer Dabbelt <palmer@...belt.com>,
Vladimir Davydov <vdavydov@...allels.com>,
linux-kernel@...r.kernel.org, linux-api@...r.kernel.org,
Andy Lutomirski <luto@...capital.net>,
Stas Sergeev <stsp@...rs.sourceforge.net>
Subject: Re: [PATCH 1/2] sigaltstack: implement SS_AUTODISARM flag
29.02.2016 00:13, Stas Sergeev пишет:
> This patch implements the SS_AUTODISARM flag that can be ORed with
> SS_ONSTACK when forming ss_flags.
> When this flag is set, sigaltstack will be disabled when entering
> the signal handler; more precisely, after saving sas to uc_stack.
> When leaving the signal handler, the sigaltstack is restored by
> uc_stack.
> When this flag is used, it is safe to switch from sighandler with
> swapcontext(). Without this flag, the subsequent signal will corrupt
> the state of the switched-away sighandler.
>
> CC: Ingo Molnar <mingo@...hat.com>
> CC: Peter Zijlstra <peterz@...radead.org>
> CC: Richard Weinberger <richard@....at>
> CC: Andrew Morton <akpm@...ux-foundation.org>
> CC: Oleg Nesterov <oleg@...hat.com>
> CC: Tejun Heo <tj@...nel.org>
> CC: Heinrich Schuchardt <xypron.glpk@....de>
> CC: Jason Low <jason.low2@...com>
> CC: Andrea Arcangeli <aarcange@...hat.com>
> CC: Frederic Weisbecker <fweisbec@...il.com>
> CC: Konstantin Khlebnikov <khlebnikov@...dex-team.ru>
> CC: Josh Triplett <josh@...htriplett.org>
> CC: "Eric W. Biederman" <ebiederm@...ssion.com>
> CC: Aleksa Sarai <cyphar@...har.com>
> CC: "Amanieu d'Antras" <amanieu@...il.com>
> CC: Paul Moore <pmoore@...hat.com>
> CC: Sasha Levin <sasha.levin@...cle.com>
> CC: Palmer Dabbelt <palmer@...belt.com>
> CC: Vladimir Davydov <vdavydov@...allels.com>
> CC: linux-kernel@...r.kernel.org
> CC: linux-api@...r.kernel.org
> CC: Andy Lutomirski <luto@...capital.net>
>
> Signed-off-by: Stas Sergeev <stsp@...rs.sourceforge.net>
> ---
> include/linux/sched.h | 1 +
> include/linux/signal.h | 4 +++-
> include/uapi/linux/signal.h | 3 +++
> kernel/fork.c | 4 +++-
> kernel/signal.c | 23 ++++++++++++-----------
> 5 files changed, 22 insertions(+), 13 deletions(-)
>
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index a10494a..f561d34 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1587,6 +1587,7 @@ struct task_struct {
>
> unsigned long sas_ss_sp;
> size_t sas_ss_size;
> + unsigned sas_ss_flags;
>
> struct callback_head *task_works;
>
> diff --git a/include/linux/signal.h b/include/linux/signal.h
> index 92557bb..be3ebe0 100644
> --- a/include/linux/signal.h
> +++ b/include/linux/signal.h
> @@ -432,8 +432,10 @@ int __save_altstack(stack_t __user *, unsigned long);
> stack_t __user *__uss = uss; \
> struct task_struct *t = current; \
> put_user_ex((void __user *)t->sas_ss_sp, &__uss->ss_sp); \
> - put_user_ex(sas_ss_flags(sp), &__uss->ss_flags); \
> + put_user_ex(t->sas_ss_flags, &__uss->ss_flags); \
> put_user_ex(t->sas_ss_size, &__uss->ss_size); \
> + if (t->sas_ss_flags & SS_AUTODISARM) \
> + t->sas_ss_size = 0; \
Should also reset flags here...
Will send v4.
Powered by blists - more mailing lists