This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug nptl/22563] __cancel_jmp_buf in __pthread_unwind_buf_t is incompatible with setjmp/longmp


https://sourceware.org/bugzilla/show_bug.cgi?id=22563

--- Comment #23 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  cba595c350e52194e10c0006732e1991e3d0803b (commit)
       via  f81ddabffd76ac9dd600b02adbf3e1dac4bb10ec (commit)
      from  1a49fc59e42513247eaeac3feac6b099157eea7c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=cba595c350e52194e10c0006732e1991e3d0803b

commit cba595c350e52194e10c0006732e1991e3d0803b
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Dec 19 02:45:16 2017 -0800

    x86: Add feature_1 to tcbhead_t [BZ #22563]

    On x86, padding in struct __jmp_buf_tag is used for shadow stack pointer
    to support Shadow Stack in Intel Control-flow Enforcemen Technology.
    cancel_jmp_buf has been updated to include saved_mask so that it is as
    large as struct __jmp_buf_tag.  We must suport the old cancel_jmp_buf
    in existing binaries.  Since symbol versioning doesn't work on
    cancel_jmp_buf, feature_1 is added to tcbhead_t so that setjmp and
    longjmp can check if shadow stack is enabled.  NB: Shadow stack is
    enabled only if all modules are shadow stack enabled.

        [BZ #22563]
        * sysdeps/i386/nptl/tcb-offsets.sym (FEATURE_1_OFFSET): New.
        * sysdeps/i386/nptl/tls.h (tcbhead_t): Add feature_1.
        * sysdeps/x86_64/nptl/tcb-offsets.sym (FEATURE_1_OFFSET): New.
        * sysdeps/x86_64/nptl/tls.h (tcbhead_t): Rename __glibc_unused1
        to feature_1.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=f81ddabffd76ac9dd600b02adbf3e1dac4bb10ec

commit f81ddabffd76ac9dd600b02adbf3e1dac4bb10ec
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Dec 19 02:43:50 2017 -0800

    Linux/x86: Update cancel_jmp_buf to match __jmp_buf_tag [BZ #22563]

    On x86, padding in struct __jmp_buf_tag is used for shadow stack pointer
    to support shadow stack in Intel Control-flow Enforcemen Technology.
    Since the cancel_jmp_buf array is passed to setjmp and longjmp by
    casting it to pointer to struct __jmp_buf_tag, it should be as large
    as struct __jmp_buf_tag.  Otherwise when shadow stack is enabled,
    setjmp and longjmp will write and read beyond cancel_jmp_buf when saving
    and restoring shadow stack pointer.

    This patch adds bits/types/__cancel_jmp_buf_tag.h to define struct
    __cancel_jmp_buf_tag so that Linux/x86 can add saved_mask to
    cancel_jmp_buf.

    Tested natively on i386, x86_64 and x32.  Tested hppa-linux-gnu with
    build-many-glibcs.py.

        [BZ #22563]
        * bits/types/__cancel_jmp_buf_tag.h: New file.
        * sysdeps/unix/sysv/linux/x86/bits/types/__cancel_jmp_buf_tag.h
        * sysdeps/unix/sysv/linux/x86/pthreaddef.h: Likewise.
        * sysdeps/unix/sysv/linux/x86/nptl/pthreadP.h: Likewise.
        * nptl/Makefile (headers): Add
        bits/types/__cancel_jmp_buf_tag.h.
        * nptl/descr.h [NEED_SAVED_MASK_IN_CANCEL_JMP_BUF]
        (pthread_unwind_buf): Add saved_mask to cancel_jmp_buf.
        * sysdeps/nptl/pthread.h: Include
        <bits/types/__cancel_jmp_buf_tag.h>.
        (__pthread_unwind_buf_t): Use struct __cancel_jmp_buf_tag with
        __cancel_jmp_buf.
        * sysdeps/unix/sysv/linux/hppa/pthread.h: Likewise.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                          |   26 ++++++++++++++
 bits/types/__cancel_jmp_buf_tag.h                  |   28 +++++++++++++++
 nptl/Makefile                                      |    3 +-
 nptl/descr.h                                       |    3 ++
 sysdeps/i386/nptl/tcb-offsets.sym                  |    1 +
 sysdeps/i386/nptl/tls.h                            |    4 ++
 sysdeps/nptl/pthread.h                             |    7 +---
 sysdeps/unix/sysv/linux/hppa/pthread.h             |    7 +---
 .../linux/x86/bits/types/__cancel_jmp_buf_tag.h    |   31 +++++++++++++++++
 sysdeps/unix/sysv/linux/x86/nptl/pthreadP.h        |   36 ++++++++++++++++++++
 sysdeps/unix/sysv/linux/x86/pthreaddef.h           |   22 ++++++++++++
 sysdeps/x86_64/nptl/tcb-offsets.sym                |    1 +
 sysdeps/x86_64/nptl/tls.h                          |    5 ++-
 13 files changed, 162 insertions(+), 12 deletions(-)
 create mode 100644 bits/types/__cancel_jmp_buf_tag.h
 create mode 100644
sysdeps/unix/sysv/linux/x86/bits/types/__cancel_jmp_buf_tag.h
 create mode 100644 sysdeps/unix/sysv/linux/x86/nptl/pthreadP.h
 create mode 100644 sysdeps/unix/sysv/linux/x86/pthreaddef.h

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]