From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 111269 invoked by alias); 27 Mar 2018 15:43:10 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 111257 invoked by uid 89); 27 Mar 2018 15:43:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=comprehensive, H*i:sk:j5c63H_, H*f:sk:j5c63H_, H*i:CAMe9rOrWO X-HELO: mx1.redhat.com From: Florian Weimer Subject: Re: RFA: Need to extend x86 psABI to support thread cancellation and alternate signal stack To: "H.J. Lu" Cc: GNU C Library , GCC Development , Carlos O'Donell References: Message-ID: Date: Tue, 27 Mar 2018 15:43:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2018-03/txt/msg00572.txt.bz2 On 03/27/2018 01:26 PM, H.J. Lu wrote: > 2. Since shadow stack is never saved and restored by compiler, unwinder > in libgcc counts how many stack frame it has to unwind and uses INCSSP > to pop shadow stack. This can't unwind the original shadow stack when > the alternate shadow stack is used. _URC_NO_REASON_CANCEL > works only if longjmp will be used to finish stack unwinding, which is > the case for thread cancellation in glibc. > > Here are patches for GCC: > > https://github.com/hjl-tools/gcc/commit/e9ff815941406e38fa629947af4d809b9129e860 > > and glibc: > > https://github.com/hjl-tools/glibc/commit/1aec81528ab26aa8a8a7965317b6e1a8ba4526aa > > They fixed the issue. The patches are nice and short, but: Do they really fix the issue? They make cancellation work again, but they do not fix the general unwinding issue with alternate signal handler stacks AFAICS. >> It may be possible to implement this without kernel changes: Patch the >> interrupted context to continue unwinding, and then call sigreturn to switch >> both stacks at the same time. >> > > We passed almost all 5000+ tests in glibc with shadow stack and indirect > branch tracking enabled. The only remaining failures are thread cancellation > with alternate signal stack and -fasynchronous-unwind-tables. I couldn't > find a way to unwind shadow stack by counting stack frame when exception > happens in alternate signal stack. I'm not sure how comprehensive these tests are, considering that no one expected something like shadow stacks (maybe those dual ia64 stacks are somewhat similar, but I don't know anything about them). Thanks, Florian