From 13c46fbc1e5a021f2b9ed32d83aecc93ae5e655d Mon Sep 17 00:00:00 2001 From: Christophe Lyon Date: Wed, 4 Jul 2018 18:09:21 +0200 Subject: rtld: Avoid crash on R_ARM_NONE relocation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R_ARM_NONE contains no data, so avoid dereferencing it. * ldso/ldso/arm/elfinterp.c (_dl_do_reloc): Handle R_ARM_NONE relocation (_dl_do_reloc_lazy): Likewise. Signed-off-by: Mickaël Guêné Signed-off-by: Christophe Lyon --- ldso/ldso/arm/elfinterp.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'ldso') diff --git a/ldso/ldso/arm/elfinterp.c b/ldso/ldso/arm/elfinterp.c index 1d79d925b..4c268356f 100644 --- a/ldso/ldso/arm/elfinterp.c +++ b/ldso/ldso/arm/elfinterp.c @@ -289,7 +289,10 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct r_scope_elem *scope, #if defined (__SUPPORT_LD_DEBUG__) { - unsigned long old_val = *reloc_addr; + unsigned long old_val; + + if (reloc_type != R_ARM_NONE) + old_val = *reloc_addr; #endif switch (reloc_type) { case R_ARM_NONE: @@ -388,7 +391,7 @@ _dl_do_reloc (struct elf_resolve *tpnt,struct r_scope_elem *scope, return -1; /*call _dl_exit(1) */ } #if defined (__SUPPORT_LD_DEBUG__) - if (_dl_debug_reloc && _dl_debug_detail) + if (_dl_debug_reloc && _dl_debug_detail && reloc_type != R_ARM_NONE) _dl_dprintf(_dl_debug_file, "\tpatch: %x ==> %x @ %x", old_val, *reloc_addr, reloc_addr); } @@ -409,7 +412,10 @@ _dl_do_lazy_reloc (struct elf_resolve *tpnt, struct r_scope_elem *scope, #if defined (__SUPPORT_LD_DEBUG__) { - unsigned long old_val = *reloc_addr; + unsigned long old_val; + + if (reloc_type != R_ARM_NONE) + old_val = *reloc_addr; #endif switch (reloc_type) { case R_ARM_NONE: @@ -432,7 +438,7 @@ _dl_do_lazy_reloc (struct elf_resolve *tpnt, struct r_scope_elem *scope, return -1; /*call _dl_exit(1) */ } #if defined (__SUPPORT_LD_DEBUG__) - if (_dl_debug_reloc && _dl_debug_detail) + if (_dl_debug_reloc && _dl_debug_detail && reloc_type != R_ARM_NONE) _dl_dprintf(_dl_debug_file, "\tpatch: %x ==> %x @ %x", old_val, *reloc_addr, reloc_addr); } -- cgit v1.2.3