+2017-07-24 H.J. Lu <hongjiu.lu@intel.com>
+
+ [BZ #21752]
+ * debug/fortify_fail.c (__fortify_fail_abort): Don't pass down
+ __libc_argv[0] if we aren't doing backtrace. Rename do_backtrace
+ to need_backtrace.
+ * sysdeps/posix/libc_fatal.c (__libc_message): Don't call
+ __libc_secure_getenv if we aren't doing backtrace.
+
2017-07-24 Andreas Schwab <schwab@suse.de>
[BZ #21804]
void
__attribute__ ((noreturn)) internal_function
-__fortify_fail_abort (_Bool do_backtrace, const char *msg)
+__fortify_fail_abort (_Bool need_backtrace, const char *msg)
{
- /* The loop is added only to keep gcc happy. */
+ /* The loop is added only to keep gcc happy. Don't pass down
+ __libc_argv[0] if we aren't doing backtrace since __libc_argv[0]
+ may point to the corrupted stack. */
while (1)
- __libc_message (do_backtrace ? (do_abort | do_backtrace) : do_abort,
+ __libc_message (need_backtrace ? (do_abort | do_backtrace) : do_abort,
"*** %s ***: %s terminated\n",
- msg, __libc_argv[0] ?: "<unknown>");
+ msg,
+ (need_backtrace && __libc_argv[0] != NULL
+ ? __libc_argv[0] : "<unknown>"));
}
void
FATAL_PREPARE;
#endif
- /* Open a descriptor for /dev/tty unless the user explicitly
- requests errors on standard error. */
- const char *on_2 = __libc_secure_getenv ("LIBC_FATAL_STDERR_");
- if (on_2 == NULL || *on_2 == '\0')
- fd = open_not_cancel_2 (_PATH_TTY, O_RDWR | O_NOCTTY | O_NDELAY);
+ /* Don't call __libc_secure_getenv if we aren't doing backtrace, which
+ may access the corrupted stack. */
+ if ((action & do_backtrace))
+ {
+ /* Open a descriptor for /dev/tty unless the user explicitly
+ requests errors on standard error. */
+ const char *on_2 = __libc_secure_getenv ("LIBC_FATAL_STDERR_");
+ if (on_2 == NULL || *on_2 == '\0')
+ fd = open_not_cancel_2 (_PATH_TTY, O_RDWR | O_NOCTTY | O_NDELAY);
+ }
if (fd == -1)
fd = STDERR_FILENO;