Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1351190 > unrolled thread

Re: [PATCH 1/2] sigaltstack: implement SS_AUTODISARM flag

Started byAndy Lutomirski <luto@amacapital.net>
First post2016-03-06 21:10 +0100
Last post2016-03-06 21:20 +0100
Articles 4 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 1/2] sigaltstack: implement SS_AUTODISARM flag Andy Lutomirski <luto@amacapital.net> - 2016-03-06 21:10 +0100
    Re: [PATCH 1/2] sigaltstack: implement SS_AUTODISARM flag Stas Sergeev <stsp@list.ru> - 2016-03-06 21:20 +0100
      Re: [PATCH 1/2] sigaltstack: implement SS_AUTODISARM flag Andy Lutomirski <luto@amacapital.net> - 2016-03-06 22:00 +0100
    Re: [PATCH 1/2] sigaltstack: implement SS_AUTODISARM flag Andy Lutomirski <luto@amacapital.net> - 2016-03-06 21:20 +0100

#1351190 — Re: [PATCH 1/2] sigaltstack: implement SS_AUTODISARM flag

FromAndy Lutomirski <luto@amacapital.net>
Date2016-03-06 21:10 +0100
SubjectRe: [PATCH 1/2] sigaltstack: implement SS_AUTODISARM flag
Message-ID<r9Na3-1n4-35@gated-at.bofh.it>
On Mon, Feb 29, 2016 at 1:29 PM, Stas Sergeev <stsp@list.ru> wrote:
> 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@redhat.com>
> CC: Peter Zijlstra <peterz@infradead.org>
> CC: Richard Weinberger <richard@nod.at>
> CC: Andrew Morton <akpm@linux-foundation.org>
> CC: Oleg Nesterov <oleg@redhat.com>
> CC: Tejun Heo <tj@kernel.org>
> CC: Heinrich Schuchardt <xypron.glpk@gmx.de>
> CC: Jason Low <jason.low2@hp.com>
> CC: Andrea Arcangeli <aarcange@redhat.com>
> CC: Frederic Weisbecker <fweisbec@gmail.com>
> CC: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> CC: Josh Triplett <josh@joshtriplett.org>
> CC: "Eric W. Biederman" <ebiederm@xmission.com>
> CC: Aleksa Sarai <cyphar@cyphar.com>
> CC: "Amanieu d'Antras" <amanieu@gmail.com>
> CC: Paul Moore <pmoore@redhat.com>
> CC: Sasha Levin <sasha.levin@oracle.com>
> CC: Palmer Dabbelt <palmer@dabbelt.com>
> CC: Vladimir Davydov <vdavydov@parallels.com>
> CC: linux-kernel@vger.kernel.org
> CC: linux-api@vger.kernel.org
> CC: Andy Lutomirski <luto@amacapital.net>
>
> Signed-off-by: Stas Sergeev <stsp@users.sourceforge.net>
> ---
>  include/linux/sched.h       |  8 ++++++++
>  include/linux/signal.h      |  4 +++-
>  include/uapi/linux/signal.h |  3 +++
>  kernel/fork.c               |  2 +-
>  kernel/signal.c             | 23 ++++++++++++-----------
>  5 files changed, 27 insertions(+), 13 deletions(-)
>
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index a10494a..26201cd 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;
>
> @@ -2573,6 +2574,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))
> diff --git a/include/linux/signal.h b/include/linux/signal.h
> index 92557bb..3fbe814 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) \
> +               sas_ss_reset(t); \
>  } while (0);
>
>  #ifdef CONFIG_PROC_FS
> diff --git a/include/uapi/linux/signal.h b/include/uapi/linux/signal.h
> index e1bd50c2..4691bc5 100644
> --- a/include/uapi/linux/signal.h
> +++ b/include/uapi/linux/signal.h
> @@ -6,5 +6,8 @@
>
>  #define SS_ONSTACK     1
>  #define SS_DISABLE     2
> +#define SS_VALMASK     0xf

SS_MODE_MASK, perhaps?

> diff --git a/kernel/signal.c b/kernel/signal.c
> index 0508544..fab6bea 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -3100,13 +3100,14 @@ do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long s
>         if (uss) {
>                 void __user *ss_sp;
>                 size_t ss_size;
> -               int ss_flags;
> +               unsigned ss_flags;
> +               unsigned ss_xflags;
>
>                 error = -EFAULT;
>                 if (!access_ok(VERIFY_READ, uss, sizeof(*uss)))
>                         goto out;
>                 error = __get_user(ss_sp, &uss->ss_sp) |
> -                       __get_user(ss_flags, &uss->ss_flags) |
> +                       __get_user(ss_xflags, &uss->ss_flags) |
>                         __get_user(ss_size, &uss->ss_size);
>                 if (error)
>                         goto out;
> @@ -3115,14 +3116,8 @@ do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long s
>                 if (on_sig_stack(sp))
>                         goto out;
>
> +               ss_flags = ss_xflags & SS_VALMASK;

This is poorly named.  How about "ss_mode = ss_flags & SS_MODE_MASK";

--Andy

[toc] | [next] | [standalone]


#1351191

FromStas Sergeev <stsp@list.ru>
Date2016-03-06 21:20 +0100
Message-ID<r9NjH-1qo-1@gated-at.bofh.it>
In reply to#1351190
06.03.2016 23:10, Andy Lutomirski пишет:
> On Sun, Mar 6, 2016 at 12:07 PM, Andy Lutomirski <luto@amacapital.net> wrote:
>> On Mon, Feb 29, 2016 at 1:29 PM, Stas Sergeev <stsp@list.ru> wrote:
>>> 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@redhat.com>
>>> CC: Peter Zijlstra <peterz@infradead.org>
>>> CC: Richard Weinberger <richard@nod.at>
>>> CC: Andrew Morton <akpm@linux-foundation.org>
>>> CC: Oleg Nesterov <oleg@redhat.com>
>>> CC: Tejun Heo <tj@kernel.org>
>>> CC: Heinrich Schuchardt <xypron.glpk@gmx.de>
>>> CC: Jason Low <jason.low2@hp.com>
>>> CC: Andrea Arcangeli <aarcange@redhat.com>
>>> CC: Frederic Weisbecker <fweisbec@gmail.com>
>>> CC: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
>>> CC: Josh Triplett <josh@joshtriplett.org>
>>> CC: "Eric W. Biederman" <ebiederm@xmission.com>
>>> CC: Aleksa Sarai <cyphar@cyphar.com>
>>> CC: "Amanieu d'Antras" <amanieu@gmail.com>
>>> CC: Paul Moore <pmoore@redhat.com>
>>> CC: Sasha Levin <sasha.levin@oracle.com>
>>> CC: Palmer Dabbelt <palmer@dabbelt.com>
>>> CC: Vladimir Davydov <vdavydov@parallels.com>
>>> CC: linux-kernel@vger.kernel.org
>>> CC: linux-api@vger.kernel.org
>>> CC: Andy Lutomirski <luto@amacapital.net>
>>>
>>> Signed-off-by: Stas Sergeev <stsp@users.sourceforge.net>
>>> ---
>>>   include/linux/sched.h       |  8 ++++++++
>>>   include/linux/signal.h      |  4 +++-
>>>   include/uapi/linux/signal.h |  3 +++
>>>   kernel/fork.c               |  2 +-
>>>   kernel/signal.c             | 23 ++++++++++++-----------
>>>   5 files changed, 27 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/include/linux/sched.h b/include/linux/sched.h
>>> index a10494a..26201cd 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;
>>>
>>> @@ -2573,6 +2574,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))
>>> diff --git a/include/linux/signal.h b/include/linux/signal.h
>>> index 92557bb..3fbe814 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) \
>>> +               sas_ss_reset(t); \
>>>   } while (0);
>>>
>>>   #ifdef CONFIG_PROC_FS
>>> diff --git a/include/uapi/linux/signal.h b/include/uapi/linux/signal.h
>>> index e1bd50c2..4691bc5 100644
>>> --- a/include/uapi/linux/signal.h
>>> +++ b/include/uapi/linux/signal.h
>>> @@ -6,5 +6,8 @@
>>>
>>>   #define SS_ONSTACK     1
>>>   #define SS_DISABLE     2
>>> +#define SS_VALMASK     0xf
>> SS_MODE_MASK, perhaps?
> Actually, let's invert that.
>
> #define SS_AUTODISARM (1U << 31)
> #define SS_FLAG_BITS SS_AUTODISARM
>
> ss_mode = ss_flags & ~SS_FLAG_BITS;
>
> this way flag bits that are currently undefined will continue to trigger EINVAL.
OK, will do.
Though I am still going to keep SS_AUTODISARM =(1 << 4) -
it doesn't matter from what side we add new flags, does it?

[toc] | [prev] | [next] | [standalone]


#1351199

FromAndy Lutomirski <luto@amacapital.net>
Date2016-03-06 22:00 +0100
Message-ID<r9NWp-1Fj-1@gated-at.bofh.it>
In reply to#1351191
On Sun, Mar 6, 2016 at 12:17 PM, Stas Sergeev <stsp@list.ru> wrote:
> 06.03.2016 23:10, Andy Lutomirski пишет:
>
>> On Sun, Mar 6, 2016 at 12:07 PM, Andy Lutomirski <luto@amacapital.net>
>> wrote:
>>>
>>> On Mon, Feb 29, 2016 at 1:29 PM, Stas Sergeev <stsp@list.ru> wrote:
>>>>
>>>> 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@redhat.com>
>>>> CC: Peter Zijlstra <peterz@infradead.org>
>>>> CC: Richard Weinberger <richard@nod.at>
>>>> CC: Andrew Morton <akpm@linux-foundation.org>
>>>> CC: Oleg Nesterov <oleg@redhat.com>
>>>> CC: Tejun Heo <tj@kernel.org>
>>>> CC: Heinrich Schuchardt <xypron.glpk@gmx.de>
>>>> CC: Jason Low <jason.low2@hp.com>
>>>> CC: Andrea Arcangeli <aarcange@redhat.com>
>>>> CC: Frederic Weisbecker <fweisbec@gmail.com>
>>>> CC: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
>>>> CC: Josh Triplett <josh@joshtriplett.org>
>>>> CC: "Eric W. Biederman" <ebiederm@xmission.com>
>>>> CC: Aleksa Sarai <cyphar@cyphar.com>
>>>> CC: "Amanieu d'Antras" <amanieu@gmail.com>
>>>> CC: Paul Moore <pmoore@redhat.com>
>>>> CC: Sasha Levin <sasha.levin@oracle.com>
>>>> CC: Palmer Dabbelt <palmer@dabbelt.com>
>>>> CC: Vladimir Davydov <vdavydov@parallels.com>
>>>> CC: linux-kernel@vger.kernel.org
>>>> CC: linux-api@vger.kernel.org
>>>> CC: Andy Lutomirski <luto@amacapital.net>
>>>>
>>>> Signed-off-by: Stas Sergeev <stsp@users.sourceforge.net>
>>>> ---
>>>>   include/linux/sched.h       |  8 ++++++++
>>>>   include/linux/signal.h      |  4 +++-
>>>>   include/uapi/linux/signal.h |  3 +++
>>>>   kernel/fork.c               |  2 +-
>>>>   kernel/signal.c             | 23 ++++++++++++-----------
>>>>   5 files changed, 27 insertions(+), 13 deletions(-)
>>>>
>>>> diff --git a/include/linux/sched.h b/include/linux/sched.h
>>>> index a10494a..26201cd 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;
>>>>
>>>> @@ -2573,6 +2574,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))
>>>> diff --git a/include/linux/signal.h b/include/linux/signal.h
>>>> index 92557bb..3fbe814 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) \
>>>> +               sas_ss_reset(t); \
>>>>   } while (0);
>>>>
>>>>   #ifdef CONFIG_PROC_FS
>>>> diff --git a/include/uapi/linux/signal.h b/include/uapi/linux/signal.h
>>>> index e1bd50c2..4691bc5 100644
>>>> --- a/include/uapi/linux/signal.h
>>>> +++ b/include/uapi/linux/signal.h
>>>> @@ -6,5 +6,8 @@
>>>>
>>>>   #define SS_ONSTACK     1
>>>>   #define SS_DISABLE     2
>>>> +#define SS_VALMASK     0xf
>>>
>>> SS_MODE_MASK, perhaps?
>>
>> Actually, let's invert that.
>>
>> #define SS_AUTODISARM (1U << 31)
>> #define SS_FLAG_BITS SS_AUTODISARM
>>
>> ss_mode = ss_flags & ~SS_FLAG_BITS;
>>
>> this way flag bits that are currently undefined will continue to trigger
>> EINVAL.
>
> OK, will do.
> Though I am still going to keep SS_AUTODISARM =(1 << 4) -
> it doesn't matter from what side we add new flags, does it?

Adding them starting with a high bit means that more low bits are
available for use as mode numbers.  Admittedly, this barely matters.

--Andy

-- 
Andy Lutomirski
AMA Capital Management, LLC

[toc] | [prev] | [next] | [standalone]


#1351192

FromAndy Lutomirski <luto@amacapital.net>
Date2016-03-06 21:20 +0100
Message-ID<r9NjH-1qo-3@gated-at.bofh.it>
In reply to#1351190
On Sun, Mar 6, 2016 at 12:07 PM, Andy Lutomirski <luto@amacapital.net> wrote:
> On Mon, Feb 29, 2016 at 1:29 PM, Stas Sergeev <stsp@list.ru> wrote:
>> 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@redhat.com>
>> CC: Peter Zijlstra <peterz@infradead.org>
>> CC: Richard Weinberger <richard@nod.at>
>> CC: Andrew Morton <akpm@linux-foundation.org>
>> CC: Oleg Nesterov <oleg@redhat.com>
>> CC: Tejun Heo <tj@kernel.org>
>> CC: Heinrich Schuchardt <xypron.glpk@gmx.de>
>> CC: Jason Low <jason.low2@hp.com>
>> CC: Andrea Arcangeli <aarcange@redhat.com>
>> CC: Frederic Weisbecker <fweisbec@gmail.com>
>> CC: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
>> CC: Josh Triplett <josh@joshtriplett.org>
>> CC: "Eric W. Biederman" <ebiederm@xmission.com>
>> CC: Aleksa Sarai <cyphar@cyphar.com>
>> CC: "Amanieu d'Antras" <amanieu@gmail.com>
>> CC: Paul Moore <pmoore@redhat.com>
>> CC: Sasha Levin <sasha.levin@oracle.com>
>> CC: Palmer Dabbelt <palmer@dabbelt.com>
>> CC: Vladimir Davydov <vdavydov@parallels.com>
>> CC: linux-kernel@vger.kernel.org
>> CC: linux-api@vger.kernel.org
>> CC: Andy Lutomirski <luto@amacapital.net>
>>
>> Signed-off-by: Stas Sergeev <stsp@users.sourceforge.net>
>> ---
>>  include/linux/sched.h       |  8 ++++++++
>>  include/linux/signal.h      |  4 +++-
>>  include/uapi/linux/signal.h |  3 +++
>>  kernel/fork.c               |  2 +-
>>  kernel/signal.c             | 23 ++++++++++++-----------
>>  5 files changed, 27 insertions(+), 13 deletions(-)
>>
>> diff --git a/include/linux/sched.h b/include/linux/sched.h
>> index a10494a..26201cd 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;
>>
>> @@ -2573,6 +2574,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))
>> diff --git a/include/linux/signal.h b/include/linux/signal.h
>> index 92557bb..3fbe814 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) \
>> +               sas_ss_reset(t); \
>>  } while (0);
>>
>>  #ifdef CONFIG_PROC_FS
>> diff --git a/include/uapi/linux/signal.h b/include/uapi/linux/signal.h
>> index e1bd50c2..4691bc5 100644
>> --- a/include/uapi/linux/signal.h
>> +++ b/include/uapi/linux/signal.h
>> @@ -6,5 +6,8 @@
>>
>>  #define SS_ONSTACK     1
>>  #define SS_DISABLE     2
>> +#define SS_VALMASK     0xf
>
> SS_MODE_MASK, perhaps?

Actually, let's invert that.

#define SS_AUTODISARM (1U << 31)
#define SS_FLAG_BITS SS_AUTODISARM

ss_mode = ss_flags & ~SS_FLAG_BITS;

this way flag bits that are currently undefined will continue to trigger EINVAL.

--Andy

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web