Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10097472ybi; Wed, 10 Jul 2019 23:28:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXtL0HB8LhWo7ClTSq8g+5W/aFLfVq9aQQgktPF4W67B+acHsc84+wRUFFlXK0RX6s9YXl X-Received: by 2002:a17:90a:bb8a:: with SMTP id v10mr2953085pjr.78.1562826503315; Wed, 10 Jul 2019 23:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562826503; cv=none; d=google.com; s=arc-20160816; b=HIhbB0ZG1Dr+S/9B4MXYANeetSPmBOW1OjlIE6sKDqf/wxvLmUdk2tUhpBlAm9rG4g SDjwkw3zz08UtQM9RLMWCd5yPOmwG7N6TEJZbN88HMctc7rqgN8vAowgL2kH/tBUxfvl BRBLM/ewMucnhS2HSLydJ2Vhy6svw3gvGlq38UqVeIqS2gbasGVRACpnl3LbzUgFfxnK gRdBaY9sTnLYXPrpxDCOEoYsRu3K/2JpOPKOvxUROygOfvt+bBBpAIU2wOmVNTS0LVOe JKHf1lbD0G2DUrwOdMhzDisbSJyt95Lmo5GRftIQKZMGnNQ07sxXdAWLtS6VaUKg9t7h aRig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=9NVI2l+CH+yEiWCjAD0BrsgJmmpUAM62JcwOjoeTemo=; b=KOMRh7VNwu/AwHAGTX1cT2RcsTfl7HXpebBcYx7H54prb1UFQjWaaog50FjtJ81YaT 9R34fsZZNKq/Z1QVWgfMd59+6I7IL/L3dlbQWBC8DYfsfF4tKhQkeutwLknn44Ls2Ynj Ct2vcfA+JsvAwM5txhCf/UqPexskMBJM7WdE11pdiOS47xxdDRWhbwtMMH7674pdulMQ m+Dw0FATfov5qBRV/fpb5EpyV3aI4jvCB95cn7OD8HkbTMzJTntvCf75+rpOBBztwY77 PMhFRsHOSriKoZVrYAborPH48uGO35KIlJS5Rb3tLBxiGD2GRyikd6zU0Z4GBc6zeEMj rSsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=N0bOZpjX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t23si4029768pjw.56.2019.07.10.23.28.07; Wed, 10 Jul 2019 23:28:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=N0bOZpjX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728009AbfGKGZ3 (ORCPT + 99 others); Thu, 11 Jul 2019 02:25:29 -0400 Received: from terminus.zytor.com ([198.137.202.136]:51913 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725963AbfGKGZ3 (ORCPT ); Thu, 11 Jul 2019 02:25:29 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x6B6PFuS2773761 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 10 Jul 2019 23:25:15 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x6B6PFuS2773761 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019061801; t=1562826315; bh=9NVI2l+CH+yEiWCjAD0BrsgJmmpUAM62JcwOjoeTemo=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=N0bOZpjXhw3kxTbBt80ktau/p5t4PNSkEt4xeiRCyJGlAw3kMPGcLWSHTcQr+YtUr N145DHirneNzJFK0dqvId4XDFmDQ6Qy8BQhbDu+B/oiShI47wAf5pjPin/WlKJvqXm iqgtTT+zJFv66shJWD6kwcWURzjc9FZVZHXK6ua7mK5ZSOCNyRQwc27GucSh+GaE8v BD/ui5Evl0vjbqSl3AsYuGKSXX5QoFwbpX8Uma4MQLc4IlZWX0af08Ov9ItQGmtcIn H837ei4VHkT00hJ53wXe7L9B7LVeQvc+C1bhAls5MxhlgvdShm6CSLSSSdFrHBhKI0 yMUAL9Bv7XadQ== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x6B6PEMG2773758; Wed, 10 Jul 2019 23:25:14 -0700 Date: Wed, 10 Jul 2019 23:25:14 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Eiichi Tsukata Message-ID: Cc: torvalds@linux-foundation.org, devel@etsukata.com, tglx@linutronix.de, mingo@kernel.org, linux-kernel@vger.kernel.org, hpa@zytor.com Reply-To: torvalds@linux-foundation.org, mingo@kernel.org, tglx@linutronix.de, devel@etsukata.com, hpa@zytor.com, linux-kernel@vger.kernel.org In-Reply-To: <20190711023501.963-1-devel@etsukata.com> References: <20190711023501.963-1-devel@etsukata.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/stacktrace: Prevent infinite loop in arch_stack_walk_user() Git-Commit-ID: cbf5b73d162b22e044fe0b7d51dcaa33be065253 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_03_06,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, DKIM_VALID_EF autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: cbf5b73d162b22e044fe0b7d51dcaa33be065253 Gitweb: https://git.kernel.org/tip/cbf5b73d162b22e044fe0b7d51dcaa33be065253 Author: Eiichi Tsukata AuthorDate: Thu, 11 Jul 2019 11:35:01 +0900 Committer: Thomas Gleixner CommitDate: Thu, 11 Jul 2019 08:22:03 +0200 x86/stacktrace: Prevent infinite loop in arch_stack_walk_user() arch_stack_walk_user() checks `if (fp == frame.next_fp)` to prevent a infinite loop by self reference but it's not enogh for circular reference. Once a lack of return address is found, there is no point to continue the loop, so break out. Fixes: 02b67518e2b1 ("tracing: add support for userspace stacktraces in tracing/iter_ctrl") Signed-off-by: Eiichi Tsukata Signed-off-by: Thomas Gleixner Acked-by: Linus Torvalds Link: https://lkml.kernel.org/r/20190711023501.963-1-devel@etsukata.com --- arch/x86/kernel/stacktrace.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/stacktrace.c b/arch/x86/kernel/stacktrace.c index 2abf27d7df6b..4f36d3241faf 100644 --- a/arch/x86/kernel/stacktrace.c +++ b/arch/x86/kernel/stacktrace.c @@ -129,11 +129,9 @@ void arch_stack_walk_user(stack_trace_consume_fn consume_entry, void *cookie, break; if ((unsigned long)fp < regs->sp) break; - if (frame.ret_addr) { - if (!consume_entry(cookie, frame.ret_addr, false)) - return; - } - if (fp == frame.next_fp) + if (!frame.ret_addr) + break; + if (!consume_entry(cookie, frame.ret_addr, false)) break; fp = frame.next_fp; }