From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 95343 invoked by alias); 15 Jul 2018 22:01:00 -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 90781 invoked by uid 89); 15 Jul 2018 22:00:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:sk:i12-v6s X-HELO: mail-oi0-f44.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=kg42TSsDxKjLCPbPOMDborkXMrCk38VYKaBX7WeBL6M=; b=IfqMis44QKp1Iwdb+S+8LD9ZNYWstZJqeI9qDHQ9iQW4KZqRzZj92KnckSjUedemyv q/NSn0WC8pIlmVwSV9qXQ8u5mOl1cX2J1E5Z4i/2iT5ZvoE/mitxYQuTk1jAmRvE9QkN cAAkH+J64tN2on3G7RffcuCoZvcYMKMLGWntzzobUW3NZo/FUMdmLxsyOK2zoIBmIpEC JE0xSf7ZFNPwYr/5PAPegSMz1LFQv9OUWH3cxT9ghe60BMi2esDi8bd8+xtPM+mnIdqt kHxRSOEgc0yNnZbAysK9ZCLldw1YavufQB4+VNdqQPhECVG4uEgWr4RBm8vx3CkXsbW8 d2cQ== MIME-Version: 1.0 In-Reply-To: <87wotwgv7e.fsf@mid.deneb.enyo.de> References: <20180613153207.57232-1-hjl.tools@gmail.com> <20180613153207.57232-3-hjl.tools@gmail.com> <20180713132252.GC2606@gmail.com> <87fu0lk2tf.fsf@mid.deneb.enyo.de> <87wotxifg7.fsf@mid.deneb.enyo.de> <87fu0kj50z.fsf@mid.deneb.enyo.de> <87wotwgv7e.fsf@mid.deneb.enyo.de> From: "H.J. Lu" Date: Sun, 15 Jul 2018 22:01:00 -0000 Message-ID: Subject: Re: V2: [PATCH 02/24] x86: Support shadow stack pointer in setjmp/longjmp To: Florian Weimer Cc: "Carlos O'Donell" , GNU C Library Content-Type: text/plain; charset="UTF-8" X-SW-Source: 2018-07/txt/msg00418.txt.bz2 On Sun, Jul 15, 2018 at 12:22 PM, Florian Weimer wrote: > * H. J. Lu: > >>> #undef. I think you can avoid that by using #if SHTSTK_ENABLED >>> instead of #ifdef SHADOW_STACK_POINTER_OFFSET, which also expresses >>> the intent more accurately. >> >> It is done on purpose. sysdeps/x86_64/__longjmp.S has >> >> /* Don't restore shadow stack register if >> 1. Shadow stack isn't enabled. Or >> 2. __longjmp is defined for __longjmp_cancel. >> */ >> #if !SHSTK_ENABLED || defined __longjmp >> # undef SHADOW_STACK_POINTER_OFFSET >> #endif > > It's a bit awkward. Linux and Hurd share the same implementation of setjmp/longjmp. But 1. For Linux, SHADOW_STACK_POINTER_OFFSET is always defined regardless if CET is enabled. 2.For Hurd, SHADOW_STACK_POINTER_OFFSET is undefined since it is unknown how to save shadow stack pointer. 3. When CET is enabled, setjmp/longjmp is assembled twice. One preserves shadow stack pointer and the other doesn't. Both versions support IBT. 4. All assembly files are compiled with the same compiler options. SHADOW_STACK_POINTER_OFFSET is used to control if shadow stack pointer should be preserved: 1. If CET isn't enabled, undef SHADOW_STACK_POINTER_OFFSET. 2. If CET is enabled, undef SHADOW_STACK_POINTER_OFFSET when not to preserve shadow stack pointer. >> Subject: [PATCH] x86_64: Undef SHADOW_STACK_POINTER_OFFSET last >> >> Since SHADOW_STACK_POINTER_OFFSET is defined in jmp_buf-ssp.h, we must >> undef SHADOW_STACK_POINTER_OFFSET after including . >> >> * sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S: Undef >> SHADOW_STACK_POINTER_OFFSET after including . > > This looks okay as a fix. I will check it in. Thanks. -- H.J.