Bug 1346397

Summary: glibc: debug/tst-longjump_chk2 calls printf from a signal handler
Product: Red Hat Enterprise Linux 7 Reporter: Florian Weimer <fweimer>
Component: glibcAssignee: Florian Weimer <fweimer>
Status: CLOSED ERRATA QA Contact: Sergey Kolosov <skolosov>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.3CC: ashankar, codonell, fweimer, mcermak, mnewsome, pfrankli, skolosov, yselkowi
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: glibc-2.17-140.el7 Doc Type: No Doc Update
Doc Text:
undefined
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 08:32:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1277314, 1335925    

Description Florian Weimer 2016-06-14 17:24:02 UTC
Quoting the upstream bug I filed:

stackoverflow_handler contains this:

  /* Using printf is not really kosher in signal handlers but we know
     it will work.  */
  printf ("%*sin signal handler\n", pass, "");

The comment is incorrect.  printf calls vfprintf (~1760 bytes of stack space), vfprintf calls buffered_vfprintf (~8592 bytes of stack space), and this calls vfprintf again (~1760 bytes of stack space).  Total space requirement is around 12 KiB, and the kernel places siginfo_t and ucontext_t on the stack (which can be as large 5 KiB).  As a result, a SIGSTKSZ value of 16 KiB is just not large enough.

This causes the test case to fail on aarch64 since the value of SIGSTKSZ has been increased.  Before that, the test passed, presumably because the 8 KiB stack allocation in buffered_vfprintf conveniently jumped over the stack frame created by do_test.  (Currently, the return address saved by do_test is clobbered by vfprintf.)

Fixing this is preferred to ignore scary-looking error messages such as:

*** longjmp causes uninitialized stack frame ***: /builddir/build/BUILD/glibc-2.17-c758a686/build-aarch64-redhat-linux/debug/tst-longjmp_chk2 terminated
======= Backtrace: =========
/builddir/build/BUILD/glibc-2.17-c758a686/build-aarch64-redhat-linux/libc.so.6(__fortify_fail+0x48)[0x3ffb7f61c24]
/builddir/build/BUILD/glibc-2.17-c758a686/build-aarch64-redhat-linux/libc.so.6(+0xf1b48)[0x3ffb7f61b48]
/builddir/build/BUILD/glibc-2.17-c758a686/build-aarch64-redhat-linux/libc.so.6(__longjmp_chk+0x30)[0x3ffb7f61ad8]
/builddir/build/BUILD/glibc-2.17-c758a686/build-aarch64-redhat-linux/debug/tst-longjmp_chk2[0x40187c]
[0x3ffb8000510]
======= Memory map: ========
00400000-00410000 r-xp 00000000 08:05 3042772                            /builddir/build/BUILD/glibc-2.17-c758a686/build-aarch64-redhat-linux/debug/tst-longjmp_chk2
…

Comment 11 errata-xmlrpc 2016-11-03 08:32:12 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2016-2573.html