unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Carlos O'Donell <carlos@redhat.com>,
	GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH 0/2] nptl: Update struct pthread_unwind_buf
Date: Fri, 9 Feb 2018 15:33:52 +0100	[thread overview]
Message-ID: <a62f1819-12e9-9e11-51bf-96ed0c7fc2d5@redhat.com> (raw)
In-Reply-To: <CAMe9rOoW+h_Zkr5qy5T_Z2mt_gvipFYV_UYtCxzCtKvtb-4N2A@mail.gmail.com>

On 02/09/2018 03:13 PM, H.J. Lu wrote:
> I built glibc master with gcc-8.0.1 -mcet -fcf-protection.  Some object
> files do get CET marker as expected.  But static executable isn't:

I said static libraries.  If I compile this code (based on the example 
from the manual page) on Fedora rawhide:

#include <pthread.h>
#include <stdio.h>

static int done = 0;
static int cleanup_pop_arg = 0;
static int cnt = 0;

static void
cleanup_handler(void *arg)
{
   printf("Called clean-up handler\n");
   cnt = 0;
}

void *
thread_start(void *arg)
{
   time_t start, curr;

   printf("New thread started\n");

   pthread_cleanup_push(cleanup_handler, NULL);

   curr = start = time(NULL);

   while (!done) {
     pthread_testcancel();           /* A cancellation point */
     if (curr < time(NULL)) {
       curr = time(NULL);
       printf("cnt = %d\n", cnt);  /* A cancellation point */
       cnt++;
     }
   }

   pthread_cleanup_pop(cleanup_pop_arg);
   return NULL;
}

the small jump buffer is used:

0000000000000030 <thread_start>:
   30:   f3 0f 1e fa             endbr64
   34:   53                      push   %rbx
   35:   bf 00 00 00 00          mov    $0x0,%edi
                         36: R_X86_64_32 .rodata.str1.1+0x18
   3a:   48 83 ec 70             sub    $0x70,%rsp
   3e:   e8 00 00 00 00          callq  43 <thread_start+0x13>
                         3f: R_X86_64_PC32       puts-0x4
   43:   31 f6                   xor    %esi,%esi
   45:   48 89 e7                mov    %rsp,%rdi
   48:   e8 00 00 00 00          callq  4d <thread_start+0x1d>
                         49: R_X86_64_PC32       __sigsetjmp-0x4
   4d:   f3 0f 1e fa             endbr64
   51:   85 c0                   test   %eax,%eax
   53:   75 51                   jne    a6 <thread_start+0x76>
   55:   48 89 e7                mov    %rsp,%rdi
   58:   e8 00 00 00 00          callq  5d <thread_start+0x2d>
                         59: R_X86_64_PC32  __pthread_register_cancel-0x4

And it looks to me that readelf says the object file is compatible with CET:

Displaying notes found in: .note.gnu.property
   Owner                 Data size       Description
   GNU                  0x00000010       NT_GNU_PROPERTY_TYPE_0
       Properties: x86 feature: IBT, SHSTK

Thanks,
Florian


  reply	other threads:[~2018-02-09 14:31 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-01 20:57 [PATCH 0/2] nptl: Update struct pthread_unwind_buf H.J. Lu
2018-02-01 20:57 ` [PATCH 1/2] Revert "Revert Intel CET changes to __jmp_buf_tag (Bug 22743)" H.J. Lu
2018-02-01 20:57 ` [PATCH 2/2] nptl: Update struct pthread_unwind_buf [BZ #22743] H.J. Lu
2018-02-08  9:25 ` [PATCH 0/2] nptl: Update struct pthread_unwind_buf Carlos O'Donell
2018-02-08 11:55   ` Florian Weimer
2018-02-09  6:29     ` Carlos O'Donell
2018-02-09 10:48       ` Florian Weimer
2018-02-09 11:13         ` H.J. Lu
2018-02-09 12:11           ` Florian Weimer
2018-02-09 12:34             ` H.J. Lu
2018-02-09 14:13               ` H.J. Lu
2018-02-09 14:33                 ` Florian Weimer [this message]
2018-02-09 15:24                   ` H.J. Lu
2018-02-24  5:46               ` Carlos O'Donell
2018-02-24 15:19                 ` H.J. Lu
2018-02-24 15:46                   ` Florian Weimer
2018-02-25  2:04                     ` H.J. Lu
2018-02-25  9:26                       ` Florian Weimer
2018-02-25 11:37                         ` H.J. Lu
2018-02-25 11:59                           ` Florian Weimer
2018-02-25 12:53                             ` H.J. Lu
2018-02-25 12:55                               ` H.J. Lu
2018-02-25 12:58                                 ` Florian Weimer
2018-02-25 13:23                                   ` H.J. Lu
2018-02-25 13:31                                     ` Florian Weimer
2018-02-25 13:36                                       ` H.J. Lu
2018-02-25 13:49                                         ` H.J. Lu
2018-02-25 13:49                                         ` Florian Weimer
2018-02-25 14:00                                           ` H.J. Lu
2018-02-25 14:13                                             ` Florian Weimer
2018-02-26  3:55                                               ` H.J. Lu
2018-02-28 23:23                                                 ` Carlos O'Donell
2018-03-07 11:56                                                   ` H.J. Lu
2018-03-07 17:34                                                     ` Carlos O'Donell
2018-03-07 19:47                                                       ` H.J. Lu
2018-03-07 20:14                                                         ` H.J. Lu
2018-03-07 22:06                                                           ` H.J. Lu
2018-03-08 12:24                                                             ` Tsimbalist, Igor V
2018-03-08 12:48                                                               ` H.J. Lu
2018-03-09  0:47                                                                 ` Carlos O'Donell
2018-03-09  5:23                                                                   ` H.J. Lu
2018-03-15  4:20                                                                     ` Carlos O'Donell
2018-02-24  6:41         ` Carlos O'Donell
2018-02-08 13:27   ` H.J. Lu
2018-02-09  6:40     ` Carlos O'Donell

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

  List information: https://www.gnu.org/software/libc/involved.html

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

  git send-email \
    --in-reply-to=a62f1819-12e9-9e11-51bf-96ed0c7fc2d5@redhat.com \
    --to=fweimer@redhat.com \
    --cc=carlos@redhat.com \
    --cc=hjl.tools@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).