linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stas Sergeev <stsp@list.ru>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Richard Weinberger <richard@nod.at>,
	Andrew Morton <akpm@linux-foundation.org>,
	Oleg Nesterov <oleg@redhat.com>, Tejun Heo <tj@kernel.org>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Jason Low <jason.low2@hp.com>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Konstantin Khlebnikov <khlebnikov@yandex-team.ru>,
	Josh Triplett <josh@joshtriplett.org>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Aleksa Sarai <cyphar@cyphar.com>,
	"Amanieu d'Antras" <amanieu@gmail.com>,
	Paul Moore <pmoore@redhat.com>,
	Sasha Levin <sasha.levin@oracle.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Vladimir Davydov <vdavydov@parallels.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linux API <linux-api@vger.kernel.org>,
	Stas Sergeev <stsp@users.sourceforge.net>
Subject: Re: [PATCH 1/2] sigaltstack: implement SS_AUTODISARM flag
Date: Sat, 5 Mar 2016 10:39:17 +0300	[thread overview]
Message-ID: <56DA8D25.20600@list.ru> (raw)
In-Reply-To: <CALCETrWMJ-2xovNnPgsKZtmBWZpqBERCTzne2L81x0tcm0BhbQ@mail.gmail.com>

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.

  reply	other threads:[~2016-03-05  7:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-29 21:29 [PATCH v4 0/2] make sigaltstack() compatible with swapcontext() Stas Sergeev
2016-02-29 21:29 ` [PATCH 1/2] sigaltstack: implement SS_AUTODISARM flag Stas Sergeev
2016-03-04 22:22   ` Andy Lutomirski
2016-03-05  7:39     ` Stas Sergeev [this message]
2016-03-05  7:40       ` Stas Sergeev
2016-03-06 20:07   ` Andy Lutomirski
2016-03-06 20:10     ` Andy Lutomirski
2016-03-06 20:17       ` Stas Sergeev
2016-03-06 20:55         ` Andy Lutomirski
2016-02-29 21:29 ` [PATCH 2/2] selftests: Add test for sigaltstack(SS_AUTODISARM) Stas Sergeev
2016-03-06 20:02 ` [PATCH v4 0/2] make sigaltstack() compatible with swapcontext() Szabolcs Nagy
2016-03-06 20:27   ` Stas Sergeev
2016-03-06 20:27   ` Szabolcs Nagy
  -- strict thread matches above, loose matches on Subject: below --
2016-02-28 21:13 [PATCH v3 " Stas Sergeev
2016-02-28 21:13 ` [PATCH 1/2] sigaltstack: implement SS_AUTODISARM flag Stas Sergeev
2016-02-29  6:29   ` Stas Sergeev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56DA8D25.20600@list.ru \
    --to=stsp@list.ru \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=amanieu@gmail.com \
    --cc=cyphar@cyphar.com \
    --cc=ebiederm@xmission.com \
    --cc=fweisbec@gmail.com \
    --cc=jason.low2@hp.com \
    --cc=josh@joshtriplett.org \
    --cc=khlebnikov@yandex-team.ru \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@redhat.com \
    --cc=oleg@redhat.com \
    --cc=palmer@dabbelt.com \
    --cc=peterz@infradead.org \
    --cc=pmoore@redhat.com \
    --cc=richard@nod.at \
    --cc=sasha.levin@oracle.com \
    --cc=stsp@users.sourceforge.net \
    --cc=tj@kernel.org \
    --cc=vdavydov@parallels.com \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).