From patchwork Thu Mar 14 04:35:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: kpark3469@gmail.com X-Patchwork-Id: 2267481 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 1D3093FCF6 for ; Thu, 14 Mar 2013 04:39:32 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UFztY-0000z4-OA; Thu, 14 Mar 2013 04:36:00 +0000 Received: from mail-gg0-x234.google.com ([2607:f8b0:4002:c02::234]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UFztV-0000yl-42 for linux-arm-kernel@lists.infradead.org; Thu, 14 Mar 2013 04:35:58 +0000 Received: by mail-gg0-f180.google.com with SMTP id e5so321367ggk.25 for ; Wed, 13 Mar 2013 21:35:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=cScqZWoMKdgf2GaST9Jf9u/w+3IVgpIpOg0nNjaZ2yA=; b=OxhJkOHnrrzC/JkH5b1bS11ZUs42P9n2PfaU/cWtU1e+Uw2cJE04OSUvl/rldlViWj i4rRgmnHpLMm7Gtwaq7uqH2H0Fv9toRyNXlT92fKLNtdWfcCulwKSdq98riDN/0WewFr bhVkldURRqwWn5Ajl5Wew+r52FRV6R29JI7vvjh0v0X3oWOrYgH6x2pi/VUAKPXpGH9D jKkDn51jJYp+t5VdQdW+JrpxY5lmEv5rRNe1KckslhAvsED6QIHB7S0MnSSKHlGXKYKB E17SzTIGAmtopURRIEARbOM6cD2KVUh3euoHxjWatZRKx41m4a4sF/hc+YJfLv+oQ3IK 1YsQ== X-Received: by 10.236.193.102 with SMTP id j66mr1025985yhn.195.1363235755258; Wed, 13 Mar 2013 21:35:55 -0700 (PDT) Received: from localhost.localdomain ([61.107.31.52]) by mx.google.com with ESMTPS id w7sm1531198yhj.0.2013.03.13.21.35.52 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 13 Mar 2013 21:35:54 -0700 (PDT) From: kpark3469@gmail.com To: linux@arm.linux.org.uk Subject: [PATCH v3] arm: fix a wrong value returned from CALLER_ADDRn Date: Thu, 14 Mar 2013 13:35:01 +0900 Message-Id: <1363235701-21342-1-git-send-email-kpark3469@gmail.com> X-Mailer: git-send-email 1.7.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130314_003557_215596_C11F9FA0 X-CRM114-Status: GOOD ( 12.44 ) X-Spam-Score: -1.8 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (kpark3469[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (kpark3469[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: keun-o.park@windriver.com, dave.martin@linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kpark3469@gmail.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Sahara This makes return_address() return a correct value for CALLER_ADDRn. To have a correct value from CALLER_ADDRn, we need to fix three points. * The unwind_frame() does not update frame->lr but frame->pc for backtrace. So frame->pc is meaningful for backtrace. * data.level should be adjusted by adding 2 additional iteration levels. With the current +1 level adjustment, the result of CALLER_ADDR1 will be the same return address with CALLER_ADDR0. * The initialization of data.addr to NULL is needed. When unwind_fame() fails right after data.level reaches zero, the routine returns data.addr which has uninitialized garbage value. Signed-off-by: Sahara Reviewed-by: Dave Martin --- arch/arm/kernel/return_address.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm/kernel/return_address.c b/arch/arm/kernel/return_address.c index 8085417..fafedd8 100644 --- a/arch/arm/kernel/return_address.c +++ b/arch/arm/kernel/return_address.c @@ -26,7 +26,7 @@ static int save_return_addr(struct stackframe *frame, void *d) struct return_address_data *data = d; if (!data->level) { - data->addr = (void *)frame->lr; + data->addr = (void *)frame->pc; return 1; } else { @@ -41,7 +41,8 @@ void *return_address(unsigned int level) struct stackframe frame; register unsigned long current_sp asm ("sp"); - data.level = level + 1; + data.level = level + 2; + data.addr = NULL; frame.fp = (unsigned long)__builtin_frame_address(0); frame.sp = current_sp;