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


Groups > linux.kernel > #1350646 > unrolled thread

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

Started byAndy Lutomirski <luto@amacapital.net>
First post2016-03-04 23:30 +0100
Last post2016-03-05 08:50 +0100
Articles 3 — 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-04 23:30 +0100
    Re: [PATCH 1/2] sigaltstack: implement SS_AUTODISARM flag Stas Sergeev <stsp@list.ru> - 2016-03-05 08:40 +0100
      Re: [PATCH 1/2] sigaltstack: implement SS_AUTODISARM flag Stas Sergeev <stsp@list.ru> - 2016-03-05 08:50 +0100

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

FromAndy Lutomirski <luto@amacapital.net>
Date2016-03-04 23:30 +0100
SubjectRe: [PATCH 1/2] sigaltstack: implement SS_AUTODISARM flag
Message-ID<r96op-5cc-11@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.
>

This looks reasonable to me with one exception: how does a user
program detect the presence of this feature?  Anyone else have any
thoughts?

[toc] | [next] | [standalone]


#1350816

FromStas Sergeev <stsp@list.ru>
Date2016-03-05 08:40 +0100
Message-ID<r9eYF-2Pv-1@gated-at.bofh.it>
In reply to#1350646
05.03.2016 01:22, Andy Lutomirski пишет:
> 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.
>>
> This looks reasonable to me with one exception: how does a user
> program detect the presence of this feature?
Compile-time detection:
#ifdef SS_AUTODISARM
   # I have this feature
   ...
#endif

Run-time detection:
int err = sigaltstack(SS_ONSTACK | SS_AUTODISARM);
if (err == EINVAL) {
   i_dont_have_this_feature = 1;
   err = sigaltstack(SS_ONSTACK);
}

Note: if you want to keep such detection for the future
additions, the mask can be enlarged to, say, ((1 << 24) - 1),
and whenever someone adds a new flag, he can lower the
mask by one bit.
But I think this would be an overkill in that particular case.

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


#1350819

FromStas Sergeev <stsp@list.ru>
Date2016-03-05 08:50 +0100
Message-ID<r9f8m-2Tl-1@gated-at.bofh.it>
In reply to#1350816
05.03.2016 10:39, Stas Sergeev пишет:
> 05.03.2016 01:22, Andy Lutomirski пишет:
>> 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.
>>>
>> This looks reasonable to me with one exception: how does a user
>> program detect the presence of this feature?
> Compile-time detection:
> #ifdef SS_AUTODISARM
>   # I have this feature
>   ...
> #endif
>
> Run-time detection:
> int err = sigaltstack(SS_ONSTACK | SS_AUTODISARM);
> if (err == EINVAL) {
I guess I mean here
if (err && errno == EINVAL)

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web