From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754215AbcBAR1l (ORCPT ); Mon, 1 Feb 2016 12:27:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47781 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754117AbcBAR1j (ORCPT ); Mon, 1 Feb 2016 12:27:39 -0500 Date: Mon, 1 Feb 2016 18:27:33 +0100 From: Oleg Nesterov To: Stas Sergeev Cc: Linux kernel , linux-api@vger.kernel.org, Andy Lutomirski , Ingo Molnar , Peter Zijlstra , Andrew Morton , "Amanieu d'Antras" , Richard Weinberger , Tejun Heo , "Kirill A. Shutemov" , Jason Low , Heinrich Schuchardt , Andrea Arcangeli , Konstantin Khlebnikov , Josh Triplett , "Eric W. Biederman" , Aleksa Sarai , Paul Moore , Palmer Dabbelt , Vladimir Davydov Subject: Re: [PATCH 4/4] sigaltstack: allow disabling and re-enabling sas within sighandler Message-ID: <20160201172733.GA20831@redhat.com> References: <56AE3369.2090709@list.ru> <56AE3626.7080706@list.ru> <20160201160625.GA18276@redhat.com> <56AF8E89.5090400@list.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56AF8E89.5090400@list.ru> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/01, Stas Sergeev wrote: > > >So the sequence is > > > > // running on alt stack > > > > sigaltstack(SS_DISABLE); > > > > temporary_run_on_another_stack(); > > > > sigaltstack(SS_ONSTACK); > > > >and SS_DISABLE saves us from another SA_ONSTACK signal, right? > Yes. > Note: there is a test-case in that patch serie from which > you can see or copy/paste the sample code. OK, I wasn't cc'ed > >But afaics it can only help after we change the stack. Suppose that SA_ONSTACK signal > >comess before temporary_run_on_another_stack(). get_sigframe() should be fine after > >your changes (afaics), it won't pick the alt stack after SS_DISABLE. > > > >However, unless I missed something save_altstack_ex() will record SS_ONSTACK in > >uc_stack->ss_flags, and after return from signal handler restore_altstack() will > >enable alt stack again? > I don't think so. Please see the following hunk: Yes, see another email, I already noticed this change. > So I understand this is very confusing, but I think the patch > is correct. Not sure, but I can hardly read this patch and I can't apply it. > Do you think adding the SS_FORCE flag would be a better solution? Yes, certainly. I see no point to remember that a thread actually has the alt stack but it was disabled. Oleg.