From patchwork Sun Sep 17 19:05:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 9954997 X-Patchwork-Delegate: deller@gmx.de Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 297E960208 for ; Sun, 17 Sep 2017 19:05:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17F382894F for ; Sun, 17 Sep 2017 19:05:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 094092895B; Sun, 17 Sep 2017 19:05:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03A7E2894F for ; Sun, 17 Sep 2017 19:05:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751352AbdIQTFO (ORCPT ); Sun, 17 Sep 2017 15:05:14 -0400 Received: from mout.gmx.net ([212.227.17.21]:60862 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751334AbdIQTFN (ORCPT ); Sun, 17 Sep 2017 15:05:13 -0400 Received: from p100.box ([193.159.28.181]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MGFz9-1df80l3U3T-00FE6Q; Sun, 17 Sep 2017 21:05:04 +0200 Date: Sun, 17 Sep 2017 21:05:02 +0200 From: Helge Deller To: linux-parisc@vger.kernel.org, James Bottomley , John David Anglin Subject: [PATCH] parisc: Stop unwinding at start of stack Message-ID: <20170917190502.GA8355@p100.box> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Provags-ID: V03:K0:Ngx1ACnQjpO4ISFDDJtnFQBWxcX6O5c6vjmayguBOmolLqAlHbr IVhduJwC0Nn/+biyixAExCqBPQA/KoXw+DWPyHROCuUl8LzXwjUbTkNrN4bS2zlBZAK/sjB pVPQGp9z01gnFbH0f74khFl3ZGLBbemmU3t4H99f/PDx2ChicfPZKRUQOM4bCe92e9Sb1XB 88Mrm5b4/MrYzltc94Zxw== X-UI-Out-Filterresults: notjunk:1; V01:K0:QtltUC33oHo=:fShDR7z+54NAETrRI8HKHp jmIA47+qB5Mc/pjOz+So7CmIRZjCVOXIG/JUhYdyWbJA8fuaC/8LK8Y1maiSHV9uKYiYV3kXc mUaXzjGWuzbkJ/IRniXOlz+B3HSPWhPu6wjXjV7/+GNaPy7FETZVK/kZ9t7hn6MKVTpa5eXLa aMGTqd6aw/RHmcWbfj7ulobaZ0o4F3t8poz86x5rDzdI2G+kvEgDHtxnNOnewnABpcERiEkrh qXPGpDznCIa0M/830lQK+CqQfEKmfDJHQdXZs+173+rdzVGN8nkf5d+erV6DomnP6rJlCvZT8 x227vI4bld/3NoPwiLcxHOcZPbSwIwDroGaBEQsfnO2pL5b8Gpp7EVmA26EFEfYjY8a+yTHX7 oeCWb782QQO8+qbw7+Xe6SBpEIN9t8v4xpkHUPw4J6Rx5vUhHhHbELqn+3z6IhdIlQ9UfrRGT ZsIsAFIiau5U/u8HzRhO2XHSdb5uxC9DgLp3TZTDy39JEwjt7u3HuDLi7ytwF93wHD8O8Cz5L yXVEyDkD65nANBLBbwBmH2vkcBeVOfPZWPXk9fncHU9P/AzpLnjizJr8R935vpGLep2Nv0/3h aNxiZrsgGSwajm0CD2Vrb7F0o2C+D374bVkmlhWl/WzqQ8xam91SLopuWLxnMipwCtKP1Hi6X 1ZAbSH8EQOBsTW3JaQG+N5sbCSbrxi9LLhtAOYRUmnftqe6aJbNQq0GLOWhKlsHdRwgRRYY35 4cRVmzSEAPrVLjHH4ENAP5bUNp5LN1VaVOVO3eb+CRor9670hoVuhaNczwzR5VyTf+YvHkos0 9QEVwl1Pd8ixoFT7LvfHsG+r1bZiA== Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Check stack pointer if we are reaching the stack end and stop unwinding if we do. This fixes early backtraces and avoids showing unrealistic call stacks. Signed-off-by: Helge Deller --- To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/parisc/kernel/unwind.c b/arch/parisc/kernel/unwind.c index 48dc7d4..caab39d 100644 --- a/arch/parisc/kernel/unwind.c +++ b/arch/parisc/kernel/unwind.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -279,6 +280,17 @@ static void unwind_frame_regs(struct unwind_frame_info *info) info->prev_sp = sp - 64; info->prev_ip = 0; + + /* The stack is at the end inside the thread_union + * struct. If we reach data, we have reached the + * beginning of the stack and should stop unwinding. */ + if (info->prev_sp >= (unsigned long) task_thread_info(info->t) && + info->prev_sp < ((unsigned long) task_thread_info(info->t) + + THREAD_SZ_ALGN)) { + info->prev_sp = 0; + break; + } + if (get_user(tmp, (unsigned long *)(info->prev_sp - RP_OFFSET))) break; info->prev_ip = tmp;