Skip to content

Commit

Permalink
Auto merge of #33729 - alexcrichton:patch-libbacktrace, r=sfackler
Browse files Browse the repository at this point in the history
std: Backport a libbacktrace soundness fix

This is a backport of gcc-mirror/gcc@047a1c2f which is a soundness fix for when
a backtrace is generated on executables that do not have debug information.
  • Loading branch information
bors committed May 20, 2016
2 parents d27bdaf + a421153 commit 55cabda
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
22 changes: 20 additions & 2 deletions src/libbacktrace/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
2016-05-18 Uros Bizjak <[email protected]>

PR target/71161
* elf.c (phdr_callback) [__i386__]: Add
__attribute__((__force_align_arg_pointer__)).

2016-03-02 Maxim Ostapenko <[email protected]>

* 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 <[email protected]>

* mmap.c (MAP_FAILED): Define if not defined.

2016-01-04 Jakub Jelinek <[email protected]>

Update copyright years.

2015-12-18 Andris Pavenis <[email protected]>

* 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 <[email protected]>

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
Expand Down
6 changes: 4 additions & 2 deletions src/libbacktrace/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions src/libbacktrace/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/libbacktrace/pecoff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 55cabda

Please sign in to comment.