From patchwork Wed Jul 4 16:09:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 939471 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=uclibc-ng.org (client-ip=89.238.66.15; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=st.com Received: from helium.openadk.org (helium.openadk.org [89.238.66.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41LQvT1LJZz9s3q for ; Thu, 5 Jul 2018 02:10:45 +1000 (AEST) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id 41EB31009E; Wed, 4 Jul 2018 18:10:42 +0200 (CEST) X-Original-To: devel@uclibc-ng.org Delivered-To: devel@helium.openadk.org Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by helium.openadk.org (Postfix) with ESMTPS id D4D0F1009E for ; Wed, 4 Jul 2018 18:10:40 +0200 (CEST) Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w64G8scI013562; Wed, 4 Jul 2018 18:10:40 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2k0dnwvspu-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 04 Jul 2018 18:10:40 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D048E31; Wed, 4 Jul 2018 16:10:38 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BDFF02C50B; Wed, 4 Jul 2018 16:10:38 +0000 (GMT) Received: from gnb.st.com (10.75.127.46) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 4 Jul 2018 18:10:38 +0200 From: Christophe Lyon To: , Date: Wed, 4 Jul 2018 18:09:21 +0200 Message-ID: <20180704160941.3261-3-christophe.lyon@st.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180704160941.3261-1-christophe.lyon@st.com> References: <20180704160941.3261-1-christophe.lyon@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG5NODE1.st.com (10.75.127.13) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-04_06:, , signatures=0 Subject: [uclibc-ng-devel] [PATCH 32/32] [ARM] rtld: Avoid crash on R_ARM_NONE relocation X-BeenThere: devel@uclibc-ng.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: uClibc-ng Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: devel-bounces@uclibc-ng.org Sender: "devel" 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 diff --git a/ldso/ldso/arm/elfinterp.c b/ldso/ldso/arm/elfinterp.c index 3bcd675..2444ed7 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: @@ -386,7 +389,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); } @@ -407,7 +410,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: @@ -428,7 +434,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); }