Bug 22637

Summary: guard size is subtracted from thread stack size instead of adding it on top
Product: glibc Reporter: Szabolcs Nagy <nszabolcs>
Component: nptlAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: drepper.fsp, fweimer, jeremip11
Priority: P2 Flags: fweimer: security-
Version: 2.27   
Target Milestone: 2.27   
See Also: https://sourceware.org/bugzilla/show_bug.cgi?id=22636
Host: Target:
Build: Last reconfirmed:
Bug Depends on:    
Bug Blocks: 22636    

Description Szabolcs Nagy 2017-12-20 15:10:56 UTC
this is related to bug 11787, but only about the guard size instead of tls accounting.

requesting large guardsize can result in tiny actually usable stack now.
Comment 1 Sourceware Commits 2018-01-08 19:06:53 UTC
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  630f4cc3aa019ede55976ea561f1a7af2f068639 (commit)
      from  c70e4e9c9efff9df4c847dd7cfd81bae674219ab (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=630f4cc3aa019ede55976ea561f1a7af2f068639

commit 630f4cc3aa019ede55976ea561f1a7af2f068639
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Wed Dec 6 13:05:50 2017 +0000

    [BZ #22637] Fix stack guard size accounting
    
    Previously if user requested S stack and G guard when creating a
    thread, the total mapping was S and the actual available stack was
    S - G - static_tls, which is not what the user requested.
    
    This patch fixes the guard size accounting by pretending the user
    requested S+G stack.  This way all later logic works out except
    when reporting the user requested stack size (pthread_getattr_np)
    or when computing the minimal stack size (__pthread_get_minstack).
    
    Normally this will increase thread stack allocations by one page.
    TLS accounting is not affected, that will require a separate fix.
    
    	[BZ #22637]
    	* nptl/descr.h (stackblock, stackblock_size): Update comments.
    	* nptl/allocatestack.c (allocate_stack): Add guardsize to stacksize.
    	* nptl/nptl-init.c (__pthread_get_minstack): Remove guardsize from
    	stacksize.
    	* nptl/pthread_getattr_np.c (pthread_getattr_np): Likewise.

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

Summary of changes:
 ChangeLog                 |    9 +++++++++
 nptl/allocatestack.c      |    4 ++++
 nptl/descr.h              |    4 ++--
 nptl/nptl-init.c          |    5 +----
 nptl/pthread_getattr_np.c |    7 +++++--
 5 files changed, 21 insertions(+), 8 deletions(-)
Comment 2 Szabolcs Nagy 2018-01-09 10:19:13 UTC
fixed for 2.27.
Comment 3 Sourceware Commits 2018-01-15 15:08:05 UTC
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, release/2.26/master has been updated
       via  247c1ddd309e3f4135045eab554f3817b7d765be (commit)
       via  3feefa1cc80140693581b0ae825dabd145b3cd9a (commit)
       via  89d6a6583367a90ab562207a2180c44a77c658a1 (commit)
       via  0b5cdd80c1e0076b67d0d9689a30589fd59d4d76 (commit)
       via  477cd2b1830c719f2b074f259c28dddcef8687bf (commit)
       via  c247c5366581ce0948de0cde22a49e2bf8c538df (commit)
      from  fabef2edbc29424a8048bdd60eba1a201f95682b (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=247c1ddd309e3f4135045eab554f3817b7d765be

commit 247c1ddd309e3f4135045eab554f3817b7d765be
Author: Florian Weimer <fweimer@redhat.com>
Date:   Mon Jan 15 15:30:00 2018 +0100

    nptl: Add PTHREAD_MIN_STACK C++ throw test [BZ #22636]
    
    (cherry picked from commit 860b0240a5645edd6490161de3f8d1d1f2786025)

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

commit 3feefa1cc80140693581b0ae825dabd145b3cd9a
Author: Florian Weimer <fweimer@redhat.com>
Date:   Thu Jan 11 13:13:14 2018 +0100

    nptl: Add tst-minstack-cancel, tst-minstack-exit [BZ #22636]
    
    I verified that without the guard accounting change in commit
    630f4cc3aa019ede55976ea561f1a7af2f068639 (Fix stack guard size
    accounting) and RTLD_NOW for libgcc_s introduced by commit
    f993b8754080ac7572b692870e926d8b493db16c (nptl: Open libgcc.so with
    RTLD_NOW during pthread_cancel), the tst-minstack-cancel test fails on
    an AVX-512F machine.  tst-minstack-exit still passes, and either of
    the mentioned commit by itself frees sufficient stack space to make
    tst-minstack-cancel pass, too.
    
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
    (cherry picked from commit d8b778907e5270fdeb70459842ffbc20bd2ca5e1)

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

commit 89d6a6583367a90ab562207a2180c44a77c658a1
Author: Florian Weimer <fweimer@redhat.com>
Date:   Mon Jan 15 16:05:36 2018 +0100

    nptl: Open libgcc.so with RTLD_NOW during pthread_cancel [BZ #22636]
    
    Disabling lazy binding reduces stack usage during unwinding.
    
    Note that RTLD_NOW only makes a difference if libgcc.so has not
    already been loaded, so this is only a partial fix.
    
    Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
    (cherry picked from commit f993b8754080ac7572b692870e926d8b493db16c)

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

commit 0b5cdd80c1e0076b67d0d9689a30589fd59d4d76
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Mon Jan 15 16:06:31 2018 +0100

    [BZ #22637] Fix stack guard size accounting
    
    Previously if user requested S stack and G guard when creating a
    thread, the total mapping was S and the actual available stack was
    S - G - static_tls, which is not what the user requested.
    
    This patch fixes the guard size accounting by pretending the user
    requested S+G stack.  This way all later logic works out except
    when reporting the user requested stack size (pthread_getattr_np)
    or when computing the minimal stack size (__pthread_get_minstack).
    
    Normally this will increase thread stack allocations by one page.
    TLS accounting is not affected, that will require a separate fix.
    
    	[BZ #22637]
    	* nptl/descr.h (stackblock, stackblock_size): Update comments.
    	* nptl/allocatestack.c (allocate_stack): Add guardsize to stacksize.
    	* nptl/nptl-init.c (__pthread_get_minstack): Remove guardsize from
    	stacksize.
    	* nptl/pthread_getattr_np.c (pthread_getattr_np): Likewise.
    
    (cherry picked from commit 630f4cc3aa019ede55976ea561f1a7af2f068639)

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

commit 477cd2b1830c719f2b074f259c28dddcef8687bf
Author: Florian Weimer <fweimer@redhat.com>
Date:   Mon Jan 8 14:57:25 2018 +0100

    nptl: Add test for callee-saved register restore in pthread_exit
    
    GCC PR 83641 results in a miscompilation of libpthread, which
    causes pthread_exit not to restore callee-saved registers before
    running destructors for objects on the stack.  This test detects
    this situation:
    
    info: unsigned int, direct pthread_exit call
    tst-thread-exit-clobber.cc:80: numeric comparison failure
       left: 4148288912 (0xf741dd90); from: value
      right: 1600833940 (0x5f6ac994); from: magic_values.v2
    info: double, direct pthread_exit call
    info: unsigned int, indirect pthread_exit call
    info: double, indirect pthread_exit call
    error: 1 test failures
    
    (cherry picked from commit 579396ee082565ab5f42ff166a264891223b7b82)

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

commit c247c5366581ce0948de0cde22a49e2bf8c538df
Author: Florian Weimer <fweimer@redhat.com>
Date:   Mon Jan 15 15:23:35 2018 +0100

    Synchronize support/ infrastructure with master
    
    This commit updates the support/ subdirectory to
    commit 1a51e46e4a87e1cd9528ac5e5656011636e4086b
    on the master branch.

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

Summary of changes:
 ChangeLog                                  |   38 ++++
 NEWS                                       |    2 +
 nptl/Makefile                              |   12 +-
 nptl/allocatestack.c                       |    4 +
 nptl/descr.h                               |    4 +-
 nptl/nptl-init.c                           |    5 +-
 nptl/pthread_getattr_np.c                  |    7 +-
 nptl/tst-minstack-cancel.c                 |   48 +++++
 nptl/tst-minstack-exit.c                   |   46 +++++
 nptl/tst-minstack-throw.cc                 |   87 ++++++++
 nptl/tst-thread-exit-clobber.cc            |  243 +++++++++++++++++++++++
 scripts/backport-support.sh                |    2 +-
 support/Makefile                           |    2 +-
 support/capture_subprocess.h               |    2 +-
 support/check.c                            |    5 +-
 support/check.h                            |   58 +++---
 support/check_addrinfo.c                   |    2 +-
 support/check_dns_packet.c                 |    2 +-
 support/check_hostent.c                    |    2 +-
 support/check_netent.c                     |    2 +-
 support/check_nss.h                        |    2 +-
 support/delayed_exit.c                     |    2 +-
 support/format_nss.h                       |    2 +-
 support/ignore_stderr.c                    |    2 +-
 support/namespace.h                        |    2 +-
 support/next_to_fault.c                    |    2 +-
 support/next_to_fault.h                    |    2 +-
 support/oom_error.c                        |    2 +-
 support/resolv_test.c                      |  298 +++++++++++++++-------------
 support/resolv_test.h                      |    2 +-
 support/run_diff.h                         |    2 +-
 support/set_fortify_handler.c              |    2 +-
 support/support-xfstat.c                   |    2 +-
 support/support-xstat.c                    |    2 +-
 support/support.h                          |    2 +-
 support/support_become_root.c              |    2 +-
 support/support_can_chroot.c               |    2 +-
 support/support_capture_subprocess.c       |    2 +-
 support/support_capture_subprocess_check.c |    2 +-
 support/support_chroot.c                   |    2 +-
 support/support_enter_mount_namespace.c    |    6 +-
 support/support_enter_network_namespace.c  |    2 +-
 support/support_format_address_family.c    |    2 +-
 support/support_format_addrinfo.c          |    2 +-
 support/support_format_dns_packet.c        |    2 +-
 support/support_format_herrno.c            |    2 +-
 support/support_format_hostent.c           |    2 +-
 support/support_format_netent.c            |    2 +-
 support/support_isolate_in_subprocess.c    |    2 +-
 support/support_record_failure.c           |    2 +-
 support/support_run_diff.c                 |    2 +-
 support/support_shared_allocate.c          |    2 +-
 support/support_test_compare_failure.c     |   21 ++-
 support/support_test_main.c                |    2 +-
 support/support_test_verify_impl.c         |    5 +-
 support/support_write_file_string.c        |    2 +-
 support/temp_file-internal.h               |    2 +-
 support/temp_file.c                        |    2 +-
 support/temp_file.h                        |    2 +-
 support/test-driver.c                      |    2 +-
 support/test-driver.h                      |    2 +-
 support/tst-support-namespace.c            |    2 +-
 support/tst-support_capture_subprocess.c   |    2 +-
 support/tst-support_format_dns_packet.c    |    2 +-
 support/tst-support_record_failure-2.sh    |    2 +-
 support/tst-support_record_failure.c       |    2 +-
 support/tst-test_compare.c                 |   20 ++-
 support/tst-xreadlink.c                    |    2 +-
 support/write_message.c                    |    5 +-
 support/xaccept.c                          |    2 +-
 support/xaccept4.c                         |    2 +-
 support/xasprintf.c                        |    2 +-
 support/xbind.c                            |    2 +-
 support/xcalloc.c                          |    2 +-
 support/xchroot.c                          |    2 +-
 support/xclose.c                           |    2 +-
 support/xconnect.c                         |    2 +-
 support/xdlfcn.c                           |    2 +-
 support/xdlfcn.h                           |    2 +-
 support/xdup2.c                            |    2 +-
 support/xfclose.c                          |    2 +-
 support/xfopen.c                           |    2 +-
 support/xfork.c                            |    2 +-
 support/xftruncate.c                       |    2 +-
 support/xgetsockname.c                     |    2 +-
 support/xlisten.c                          |    2 +-
 support/xlseek.c                           |    2 +-
 support/xmalloc.c                          |    2 +-
 support/xmemstream.c                       |    2 +-
 support/xmemstream.h                       |    2 +-
 support/xmkdir.c                           |    2 +-
 support/xmmap.c                            |    2 +-
 support/xmprotect.c                        |    2 +-
 support/xmunmap.c                          |    2 +-
 support/xopen.c                            |    2 +-
 support/xpipe.c                            |    2 +-
 support/xpoll.c                            |    2 +-
 support/xpthread_attr_destroy.c            |    2 +-
 support/xpthread_attr_init.c               |    2 +-
 support/xpthread_attr_setdetachstate.c     |    2 +-
 support/xpthread_attr_setguardsize.c       |    2 +-
 support/xpthread_attr_setstacksize.c       |    2 +-
 support/xpthread_barrier_destroy.c         |    2 +-
 support/xpthread_barrier_init.c            |    2 +-
 support/xpthread_barrier_wait.c            |    2 +-
 support/xpthread_cancel.c                  |    2 +-
 support/xpthread_check_return.c            |    2 +-
 support/xpthread_cond_wait.c               |    2 +-
 support/xpthread_create.c                  |    2 +-
 support/xpthread_detach.c                  |    2 +-
 support/xpthread_join.c                    |    2 +-
 support/xpthread_mutex_consistent.c        |    2 +-
 support/xpthread_mutex_destroy.c           |    2 +-
 support/xpthread_mutex_init.c              |    2 +-
 support/xpthread_mutex_lock.c              |    2 +-
 support/xpthread_mutex_unlock.c            |    2 +-
 support/xpthread_mutexattr_destroy.c       |    2 +-
 support/xpthread_mutexattr_init.c          |    2 +-
 support/xpthread_mutexattr_setprotocol.c   |    2 +-
 support/xpthread_mutexattr_setpshared.c    |    2 +-
 support/xpthread_mutexattr_setrobust.c     |    2 +-
 support/xpthread_mutexattr_settype.c       |    2 +-
 support/xpthread_once.c                    |    2 +-
 support/xpthread_rwlock_init.c             |    2 +-
 support/xpthread_rwlock_rdlock.c           |    2 +-
 support/xpthread_rwlock_unlock.c           |    2 +-
 support/xpthread_rwlock_wrlock.c           |    2 +-
 support/xpthread_rwlockattr_init.c         |    2 +-
 support/xpthread_rwlockattr_setkind_np.c   |    2 +-
 support/xpthread_sigmask.c                 |    2 +-
 support/xpthread_spin_lock.c               |    2 +-
 support/xpthread_spin_unlock.c             |    2 +-
 support/xraise.c                           |    2 +-
 support/xreadlink.c                        |    2 +-
 support/xrealloc.c                         |    2 +-
 support/xrecvfrom.c                        |    2 +-
 support/xsendto.c                          |    2 +-
 support/xsetsockopt.c                      |    2 +-
 support/xsigaction.c                       |    2 +-
 support/xsignal.c                          |    2 +-
 support/xsignal.h                          |    2 +-
 support/xsocket.c                          |    2 +-
 support/xsocket.h                          |    2 +-
 support/xstdio.h                           |    2 +-
 support/xstrdup.c                          |    2 +-
 support/xstrndup.c                         |    2 +-
 support/xsysconf.c                         |    2 +-
 support/xthread.h                          |    2 +-
 support/xunistd.h                          |    2 +-
 support/xunlink.c                          |    2 +-
 support/xwaitpid.c                         |    2 +-
 support/xwrite.c                           |    2 +-
 sysdeps/nptl/unwind-forcedunwind.c         |    2 +-
 153 files changed, 855 insertions(+), 327 deletions(-)
 create mode 100644 nptl/tst-minstack-cancel.c
 create mode 100644 nptl/tst-minstack-exit.c
 create mode 100644 nptl/tst-minstack-throw.cc
 create mode 100644 nptl/tst-thread-exit-clobber.cc
Comment 4 Sourceware Commits 2018-01-16 08:47:56 UTC
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, release/2.25/master has been updated
       via  abf2e34ee6a9cf1b7e5afddd13971754e5c5fa82 (commit)
       via  8343b9da62a81c6bbdf997f48778793553142f47 (commit)
       via  ea2da72230169601f06944b27ffeb6071e879b7d (commit)
       via  41acd32eb74ed1f93114cad8a49438038eaf42ba (commit)
       via  3e75e676da29d95cf8fbef1b1a441a40cba7ac2b (commit)
       via  5d4c589ca4b527f24f04b8ad23c579499aa510bc (commit)
       via  aedc861c42aa371864c5c64b361181c9bcb872bb (commit)
      from  771c846a71d9ee14aa3b91fd184026482da585d9 (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=abf2e34ee6a9cf1b7e5afddd13971754e5c5fa82

commit abf2e34ee6a9cf1b7e5afddd13971754e5c5fa82
Author: Florian Weimer <fweimer@redhat.com>
Date:   Thu Jan 11 13:13:28 2018 +0100

    csu: Update __libgcc_s_init comment
    
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
    (cherry picked from commit 08c6e95234c60a5c2f37532d1111acf084f39345)

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

commit 8343b9da62a81c6bbdf997f48778793553142f47
Author: Florian Weimer <fweimer@redhat.com>
Date:   Tue Jan 16 07:19:28 2018 +0100

    nptl/tst-minstack-throw: Compile in C++11 mode with GNU extensions
    
    (cherry picked from commit b725132d2b0aeddf970b1ce3e5a24f8637a7b4c2)

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

commit ea2da72230169601f06944b27ffeb6071e879b7d
Author: Florian Weimer <fweimer@redhat.com>
Date:   Mon Jan 15 15:30:00 2018 +0100

    nptl: Add PTHREAD_MIN_STACK C++ throw test [BZ #22636]
    
    (cherry picked from commit 860b0240a5645edd6490161de3f8d1d1f2786025)

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

commit 41acd32eb74ed1f93114cad8a49438038eaf42ba
Author: Florian Weimer <fweimer@redhat.com>
Date:   Thu Jan 11 13:13:14 2018 +0100

    nptl: Add tst-minstack-cancel, tst-minstack-exit [BZ #22636]
    
    I verified that without the guard accounting change in commit
    630f4cc3aa019ede55976ea561f1a7af2f068639 (Fix stack guard size
    accounting) and RTLD_NOW for libgcc_s introduced by commit
    f993b8754080ac7572b692870e926d8b493db16c (nptl: Open libgcc.so with
    RTLD_NOW during pthread_cancel), the tst-minstack-cancel test fails on
    an AVX-512F machine.  tst-minstack-exit still passes, and either of
    the mentioned commit by itself frees sufficient stack space to make
    tst-minstack-cancel pass, too.
    
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
    (cherry picked from commit d8b778907e5270fdeb70459842ffbc20bd2ca5e1)

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

commit 3e75e676da29d95cf8fbef1b1a441a40cba7ac2b
Author: Florian Weimer <fweimer@redhat.com>
Date:   Mon Jan 15 16:05:36 2018 +0100

    nptl: Open libgcc.so with RTLD_NOW during pthread_cancel [BZ #22636]
    
    Disabling lazy binding reduces stack usage during unwinding.
    
    Note that RTLD_NOW only makes a difference if libgcc.so has not
    already been loaded, so this is only a partial fix.
    
    Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
    (cherry picked from commit f993b8754080ac7572b692870e926d8b493db16c)

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

commit 5d4c589ca4b527f24f04b8ad23c579499aa510bc
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Mon Jan 15 16:06:31 2018 +0100

    [BZ #22637] Fix stack guard size accounting
    
    Previously if user requested S stack and G guard when creating a
    thread, the total mapping was S and the actual available stack was
    S - G - static_tls, which is not what the user requested.
    
    This patch fixes the guard size accounting by pretending the user
    requested S+G stack.  This way all later logic works out except
    when reporting the user requested stack size (pthread_getattr_np)
    or when computing the minimal stack size (__pthread_get_minstack).
    
    Normally this will increase thread stack allocations by one page.
    TLS accounting is not affected, that will require a separate fix.
    
    	[BZ #22637]
    	* nptl/descr.h (stackblock, stackblock_size): Update comments.
    	* nptl/allocatestack.c (allocate_stack): Add guardsize to stacksize.
    	* nptl/nptl-init.c (__pthread_get_minstack): Remove guardsize from
    	stacksize.
    	* nptl/pthread_getattr_np.c (pthread_getattr_np): Likewise.
    
    (cherry picked from commit 630f4cc3aa019ede55976ea561f1a7af2f068639)

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

commit aedc861c42aa371864c5c64b361181c9bcb872bb
Author: Florian Weimer <fweimer@redhat.com>
Date:   Mon Jan 8 14:57:25 2018 +0100

    nptl: Add test for callee-saved register restore in pthread_exit
    
    GCC PR 83641 results in a miscompilation of libpthread, which
    causes pthread_exit not to restore callee-saved registers before
    running destructors for objects on the stack.  This test detects
    this situation:
    
    info: unsigned int, direct pthread_exit call
    tst-thread-exit-clobber.cc:80: numeric comparison failure
       left: 4148288912 (0xf741dd90); from: value
      right: 1600833940 (0x5f6ac994); from: magic_values.v2
    info: double, direct pthread_exit call
    info: unsigned int, indirect pthread_exit call
    info: double, indirect pthread_exit call
    error: 1 test failures
    
    (cherry picked from commit 579396ee082565ab5f42ff166a264891223b7b82)

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

Summary of changes:
 ChangeLog                          |   48 +++++++
 NEWS                               |    2 +
 nptl/Makefile                      |   14 ++-
 nptl/allocatestack.c               |    4 +
 nptl/descr.h                       |    4 +-
 nptl/nptl-init.c                   |    5 +-
 nptl/pthread_getattr_np.c          |    7 +-
 nptl/tst-minstack-cancel.c         |   48 +++++++
 nptl/tst-minstack-exit.c           |   46 +++++++
 nptl/tst-minstack-throw.cc         |   87 +++++++++++++
 nptl/tst-thread-exit-clobber.cc    |  243 ++++++++++++++++++++++++++++++++++++
 sysdeps/gnu/unwind-resume.c        |    8 +-
 sysdeps/nptl/unwind-forcedunwind.c |    2 +-
 13 files changed, 504 insertions(+), 14 deletions(-)
 create mode 100644 nptl/tst-minstack-cancel.c
 create mode 100644 nptl/tst-minstack-exit.c
 create mode 100644 nptl/tst-minstack-throw.cc
 create mode 100644 nptl/tst-thread-exit-clobber.cc
Comment 5 Sourceware Commits 2018-12-28 22:26:38 UTC
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, release/2.24/master has been updated
       via  e853f05a5757dfee0c8b7f301e6a52047cc9864a (commit)
       via  d8d97c0539c4258ecf8d46a184e853acad577199 (commit)
       via  9ae4fa0c5b5087f3a1391753d54d7f3086224f77 (commit)
       via  fff112f4c4442af52bec90353e80bc4e801ab79b (commit)
       via  23758d3539232de8368ea601f2df1c2a9da145e8 (commit)
      from  659b3df5db97948f4c6042203163873fb96ec512 (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=e853f05a5757dfee0c8b7f301e6a52047cc9864a

commit e853f05a5757dfee0c8b7f301e6a52047cc9864a
Author: Florian Weimer <fweimer@redhat.com>
Date:   Thu Jan 11 13:13:28 2018 +0100

    csu: Update __libgcc_s_init comment
    
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
    (cherry picked from commit 08c6e95234c60a5c2f37532d1111acf084f39345)

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

commit d8d97c0539c4258ecf8d46a184e853acad577199
Author: Florian Weimer <fweimer@redhat.com>
Date:   Tue Jan 16 07:19:28 2018 +0100

    nptl/tst-minstack-throw: Compile in C++11 mode with GNU extensions
    
    (cherry picked from commit b725132d2b0aeddf970b1ce3e5a24f8637a7b4c2)

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

commit 9ae4fa0c5b5087f3a1391753d54d7f3086224f77
Author: Florian Weimer <fweimer@redhat.com>
Date:   Thu Jan 11 13:13:14 2018 +0100

    nptl: Add tst-minstack-cancel, tst-minstack-exit [BZ #22636]
    
    I verified that without the guard accounting change in commit
    630f4cc3aa019ede55976ea561f1a7af2f068639 (Fix stack guard size
    accounting) and RTLD_NOW for libgcc_s introduced by commit
    f993b8754080ac7572b692870e926d8b493db16c (nptl: Open libgcc.so with
    RTLD_NOW during pthread_cancel), the tst-minstack-cancel test fails on
    an AVX-512F machine.  tst-minstack-exit still passes, and either of
    the mentioned commit by itself frees sufficient stack space to make
    tst-minstack-cancel pass, too.
    
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
    (cherry picked from commit d8b778907e5270fdeb70459842ffbc20bd2ca5e1)

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

commit fff112f4c4442af52bec90353e80bc4e801ab79b
Author: Florian Weimer <fweimer@redhat.com>
Date:   Mon Jan 15 16:05:36 2018 +0100

    nptl: Open libgcc.so with RTLD_NOW during pthread_cancel [BZ #22636]
    
    Disabling lazy binding reduces stack usage during unwinding.
    
    Note that RTLD_NOW only makes a difference if libgcc.so has not
    already been loaded, so this is only a partial fix.
    
    Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
    (cherry picked from commit f993b8754080ac7572b692870e926d8b493db16c)

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

commit 23758d3539232de8368ea601f2df1c2a9da145e8
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Mon Jan 15 16:06:31 2018 +0100

    [BZ #22637] Fix stack guard size accounting
    
    Previously if user requested S stack and G guard when creating a
    thread, the total mapping was S and the actual available stack was
    S - G - static_tls, which is not what the user requested.
    
    This patch fixes the guard size accounting by pretending the user
    requested S+G stack.  This way all later logic works out except
    when reporting the user requested stack size (pthread_getattr_np)
    or when computing the minimal stack size (__pthread_get_minstack).
    
    Normally this will increase thread stack allocations by one page.
    TLS accounting is not affected, that will require a separate fix.
    
    	[BZ #22637]
    	* nptl/descr.h (stackblock, stackblock_size): Update comments.
    	* nptl/allocatestack.c (allocate_stack): Add guardsize to stacksize.
    	* nptl/nptl-init.c (__pthread_get_minstack): Remove guardsize from
    	stacksize.
    	* nptl/pthread_getattr_np.c (pthread_getattr_np): Likewise.
    
    (cherry picked from commit 630f4cc3aa019ede55976ea561f1a7af2f068639)

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

Summary of changes:
 ChangeLog                                     |   31 +++++++++++++++++
 NEWS                                          |    2 +
 nptl/Makefile                                 |    4 ++-
 nptl/allocatestack.c                          |    4 ++
 nptl/descr.h                                  |    4 +-
 nptl/nptl-init.c                              |    5 +--
 nptl/pthread_getattr_np.c                     |    7 +++-
 nptl/{tst-detach1.c => tst-minstack-cancel.c} |   45 ++++++++++--------------
 nptl/{tst-detach1.c => tst-minstack-exit.c}   |   43 +++++++++--------------
 sysdeps/gnu/unwind-resume.c                   |    8 +++-
 sysdeps/nptl/unwind-forcedunwind.c            |    2 +-
 11 files changed, 91 insertions(+), 64 deletions(-)
 copy nptl/{tst-detach1.c => tst-minstack-cancel.c} (55%)
 copy nptl/{tst-detach1.c => tst-minstack-exit.c} (55%)