Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp664969ybk; Fri, 15 May 2020 10:19:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAfxZPBiG4gdNBPPbqENhneyM+QcPcD3jofsZb3YHCtC5zV0m3tt7S9FdVeRjSIffJDgJC X-Received: by 2002:a05:6402:1547:: with SMTP id p7mr3809463edx.31.1589563152949; Fri, 15 May 2020 10:19:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589563152; cv=none; d=google.com; s=arc-20160816; b=NdOBWBo9Kvgwraw3Gr/cghcx6u6hauyW5AhGm+hHqLHO12SdnuH7yXtO4VUUw0jVyL v0mPRQPTrT2igiwyRDEVrs5wX3EX3ELMHtvgU+/bdmzHp6sZLrK1BY00mGQt70phj1XS u8OsOmVfu+pj5IlDHzzbkAgvgcGfV0jvFQg6vmNqyouKGs9W37AQNAP+eLOPvaVbdwop K3FPqAmE3j3t/ocxj1aN+RMD9ielWXFi9zG3tqiIv4Lgyf7ZhZ0pTGiePuslNJbfzmL6 qc7DCGC/H6nrvjzW19cyN7R6nJXAbFO4sPIg/uUDWp4Dd1A1l0IwZVbkDOXxRsDfPPW+ lzzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=4c9cPgDLPjjHOF6J1YAmifQQkCjCoYoRmrkVxh7GKFo=; b=ZuBI9ex3ixdeEO8FHeq/Vq0J4MBTURs0mMUrgtB5pNuhtC8MSUq9j1cVXZwsz99vLY pWmMsnxvfvWLgtkuz40n/uCAuvYwsd471YbEdw66nP8kyDYHTwUszl8B1dC13LEQkhsO ME9Rs/jze/yjDPBMOS3I5jGUzrUOzdALCQcbm9wf8GhJlo7fTziUXX+Ww1vPFErCnegH q2QOE7boEH2GpwF9a6MpZ4ixeAz9VDohJg2DGs8VFCIKMp4kcqTj8yoxxyuI7f2LFimK GhuOxd5SsZlCWZE/Iscl/+WOKkbeMVPvAK/Fo7kAbvtuj6fkoF3Yrd8Yzl6kZv52YykL dl3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y4si1608206edt.104.2020.05.15.10.18.49; Fri, 15 May 2020 10:19:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726652AbgEORRe (ORCPT + 99 others); Fri, 15 May 2020 13:17:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726234AbgEORRe (ORCPT ); Fri, 15 May 2020 13:17:34 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DDD9C061A0C; Fri, 15 May 2020 10:17:34 -0700 (PDT) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jZdxe-0005OG-40; Fri, 15 May 2020 19:17:26 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 77A2B1C007F; Fri, 15 May 2020 19:17:25 +0200 (CEST) Date: Fri, 15 May 2020 17:17:25 -0000 From: "tip-bot2 for Josh Poimboeuf" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/urgent] x86/unwind/orc: Fix error handling in __unwind_start() Cc: Pavel Machek , Josh Poimboeuf , "Peter Zijlstra (Intel)" , x86 , LKML In-Reply-To: References: MIME-Version: 1.0 Message-ID: <158956304535.17951.17376884758306410761.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the objtool/urgent branch of tip: Commit-ID: 71c95825289f585014fe9741b051d32a7a916680 Gitweb: https://git.kernel.org/tip/71c95825289f585014fe9741b051d32a7a916680 Author: Josh Poimboeuf AuthorDate: Thu, 14 May 2020 15:31:10 -05:00 Committer: Peter Zijlstra CommitterDate: Fri, 15 May 2020 10:35:08 +02:00 x86/unwind/orc: Fix error handling in __unwind_start() The unwind_state 'error' field is used to inform the reliable unwinding code that the stack trace can't be trusted. Set this field for all errors in __unwind_start(). Also, move the zeroing out of the unwind_state struct to before the ORC table initialization check, to prevent the caller from reading uninitialized data if the ORC table is corrupted. Fixes: af085d9084b4 ("stacktrace/x86: add function for detecting reliable stack traces") Fixes: d3a09104018c ("x86/unwinder/orc: Dont bail on stack overflow") Fixes: 98d0c8ebf77e ("x86/unwind/orc: Prevent unwinding before ORC initialization") Reported-by: Pavel Machek Signed-off-by: Josh Poimboeuf Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/d6ac7215a84ca92b895fdd2e1aa546729417e6e6.1589487277.git.jpoimboe@redhat.com --- arch/x86/kernel/unwind_orc.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/unwind_orc.c b/arch/x86/kernel/unwind_orc.c index 5b0bd85..fa79e42 100644 --- a/arch/x86/kernel/unwind_orc.c +++ b/arch/x86/kernel/unwind_orc.c @@ -617,23 +617,23 @@ EXPORT_SYMBOL_GPL(unwind_next_frame); void __unwind_start(struct unwind_state *state, struct task_struct *task, struct pt_regs *regs, unsigned long *first_frame) { - if (!orc_init) - goto done; - memset(state, 0, sizeof(*state)); state->task = task; + if (!orc_init) + goto err; + /* * Refuse to unwind the stack of a task while it's executing on another * CPU. This check is racy, but that's ok: the unwinder has other * checks to prevent it from going off the rails. */ if (task_on_another_cpu(task)) - goto done; + goto err; if (regs) { if (user_mode(regs)) - goto done; + goto the_end; state->ip = regs->ip; state->sp = regs->sp; @@ -666,6 +666,7 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task, * generate some kind of backtrace if this happens. */ void *next_page = (void *)PAGE_ALIGN((unsigned long)state->sp); + state->error = true; if (get_stack_info(next_page, state->task, &state->stack_info, &state->stack_mask)) return; @@ -691,8 +692,9 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task, return; -done: +err: + state->error = true; +the_end: state->stack_info.type = STACK_TYPE_UNKNOWN; - return; } EXPORT_SYMBOL_GPL(__unwind_start);