From: Stas Sergeev Subject: Re: [PATCH 1/2] sigaltstack: implement SS_AUTODISARM flag Date: Sat, 5 Mar 2016 10:40:56 +0300 Message-ID: <56DA8D88.5060301@list.ru> References: <1456781345-8243-1-git-send-email-stsp@list.ru> <1456781345-8243-2-git-send-email-stsp@list.ru> <56DA8D25.20600@list.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: <56DA8D25.20600-cmBhpYW9OiY@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Andy Lutomirski Cc: Ingo Molnar , Peter Zijlstra , Richard Weinberger , Andrew Morton , Oleg Nesterov , Tejun Heo , Heinrich Schuchardt , Jason Low , Andrea Arcangeli , Frederic Weisbecker , Konstantin Khlebnikov , Josh Triplett , "Eric W. Biederman" , Aleksa Sarai , Amanieu d'Antras , Paul Moore , Sasha Levin , Palmer Dabbelt , Vladimir Davydov , "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , Linux API , Stas Sergeev List-Id: linux-api@vger.kernel.org 05.03.2016 10:39, Stas Sergeev =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > 05.03.2016 01:22, Andy Lutomirski =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >> On Mon, Feb 29, 2016 at 1:29 PM, Stas Sergeev 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 corrup= t >>> 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 =3D sigaltstack(SS_ONSTACK | SS_AUTODISARM); > if (err =3D=3D EINVAL) { I guess I mean here if (err && errno =3D=3D EINVAL)