From a42115375b1d7ae2a6c3f8c85819ef8182abaf52 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 18 May 2016 16:59:06 -0700 Subject: [PATCH] std: Update libbacktrace for a soundness fix This updates the vendor'd libbacktrace source to tpick up gcc-mirror/gcc@047a1c2f which is a soundness fix for when a backtrace is generated on executables that do not have debug information. --- src/libbacktrace/ChangeLog | 22 ++++++++++++++++++++-- src/libbacktrace/elf.c | 6 ++++-- src/libbacktrace/mmap.c | 4 ++++ src/libbacktrace/pecoff.c | 3 +++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/libbacktrace/ChangeLog b/src/libbacktrace/ChangeLog index 2afa4705539aa..acc07047f6729 100644 --- a/src/libbacktrace/ChangeLog +++ b/src/libbacktrace/ChangeLog @@ -1,15 +1,33 @@ +2016-05-18 Uros Bizjak + + PR target/71161 + * elf.c (phdr_callback) [__i386__]: Add + __attribute__((__force_align_arg_pointer__)). + +2016-03-02 Maxim Ostapenko + + * elf.c (backtrace_initialize): Properly initialize elf_fileline_fn to + avoid possible crash. + (elf_add): Don't set *fileline_fn to elf_nodebug value in case of + missing debug info anymore. + +2016-02-06 John David Anglin + + * mmap.c (MAP_FAILED): Define if not defined. + 2016-01-04 Jakub Jelinek Update copyright years. 2015-12-18 Andris Pavenis - * configure.ac: Specify that DJGPP do not have mmap even when sys/mman.h exists + * configure.ac: Specify that DJGPP do not have mmap + even when sys/mman.h exists. * configure: Regenerate 2015-12-09 John David Anglin - PR 68115/libfortran + PR libgfortran/68115 * configure.ac: Set libbacktrace_cv_sys_sync to no on hppa*-*-hpux*. * configure: Regenerate. * elf.c (backtrace_initialize): Cast __sync_bool_compare_and_swap call diff --git a/src/libbacktrace/elf.c b/src/libbacktrace/elf.c index 05cc5c04734b7..81ba3440ab7d1 100644 --- a/src/libbacktrace/elf.c +++ b/src/libbacktrace/elf.c @@ -791,7 +791,6 @@ elf_add (struct backtrace_state *state, int descriptor, uintptr_t base_address, { if (!backtrace_close (descriptor, error_callback, data)) goto fail; - *fileline_fn = elf_nodebug; return 1; } @@ -867,6 +866,9 @@ struct phdr_data libraries. */ static int +#ifdef __i386__ +__attribute__ ((__force_align_arg_pointer__)) +#endif phdr_callback (struct dl_phdr_info *info, size_t size ATTRIBUTE_UNUSED, void *pdata) { @@ -925,7 +927,7 @@ backtrace_initialize (struct backtrace_state *state, int descriptor, int ret; int found_sym; int found_dwarf; - fileline elf_fileline_fn; + fileline elf_fileline_fn = elf_nodebug; struct phdr_data pd; ret = elf_add (state, descriptor, 0, error_callback, data, &elf_fileline_fn, diff --git a/src/libbacktrace/mmap.c b/src/libbacktrace/mmap.c index 0ed4802d02de4..138ef70711a02 100644 --- a/src/libbacktrace/mmap.c +++ b/src/libbacktrace/mmap.c @@ -50,6 +50,10 @@ POSSIBILITY OF SUCH DAMAGE. */ #define MAP_ANONYMOUS MAP_ANON #endif +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + /* A list of free memory blocks. */ struct backtrace_freelist_struct diff --git a/src/libbacktrace/pecoff.c b/src/libbacktrace/pecoff.c index 31126cf4741c7..04e0bafb14981 100644 --- a/src/libbacktrace/pecoff.c +++ b/src/libbacktrace/pecoff.c @@ -602,6 +602,9 @@ coff_add (struct backtrace_state *state, int descriptor, const b_coff_section_header *sects; struct backtrace_view str_view; int str_view_valid; + // NOTE: upstream this is a `size_t` but this was fixed in Rust commit + // 55e2b7e1b, see #33729 for more info. If you see this in a diff + // against the upstream libbacktrace, that's what's going on. uint32_t str_size; off_t str_off; struct backtrace_view syms_view;