Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2021287pxa; Mon, 3 Aug 2020 05:35:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJHaBY1NNZuWmPkBdXpVSubU8VbqsYPkFwrrOzMCEX1eQIDC830S27WeaTZ+nxuyvvHi0r X-Received: by 2002:a05:6402:b32:: with SMTP id bo18mr15835006edb.201.1596458136493; Mon, 03 Aug 2020 05:35:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596458136; cv=none; d=google.com; s=arc-20160816; b=BmjK/g4cR0LRKLs77lkZbvH8dI5ENcPMXpKyC9Z1btIstL3aNfbC8EylSi+iiCMQVd 8Fjl3Sm+EUgn1VluecWfYmL5PArgkTaBWgjauWZ/8sM6Xzc/jYP7jwfkH9zpDEL+nY4J U8VtviCAbealDS1a1TW6WE38nxFa4vu3ds27AklSwsFQrTyeuea3H6BfVZSpMVmlJlg1 dxwLHYrD9kMmfRufdKh66L0pYaGvI4XWCXk7pLj+4ebD3/+xI9K4w1zhnhhfOcLtsMXy jJ+hoYGhuwlN0Q7pX632+G0oFgd6LduQdlJeCeXavwQa6etZEJ3Wk8bhEwqovPmBJCaT iIwg== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=beHWA/G71nvh7RKNCAdrZe8pPHux5cd+7V32jrcYB9o=; b=qxcDtXOeyk2J2OzX/oipEG94oPwndue8/m0DIyKqlyS07VxdySwUMY9bkTAo+tcXOh sMu/u/AWV/HNV9u5UxSfqIflEd+TzmV0LUsYjedHg1fCzgww6XHexlgkarJAvnZZt4iT ryfsL/BHR+zcKJ7DFGutl2vyc2PXZ5/LS7JrXrb8z73kw02HCNVAsovegrYv7E899kod 110zV6DSZcb8Sf/hk2YgqbLecN4pvivENevJrNpf1BuOzdqeToesy+CsEjs1mXaWU9aN Wa7mU2PRdIn1I0PNoNqDUfo7dnVAQ5qbLRfJZDZ2aNOrAAOieyUG1btp40gLOhnmTHCc dM2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Kp4RF5e6; 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 qw20si268600ejb.371.2020.08.03.05.35.14; Mon, 03 Aug 2020 05:35:36 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Kp4RF5e6; 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 S1729404AbgHCMdO (ORCPT + 99 others); Mon, 3 Aug 2020 08:33:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:32900 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728608AbgHCMdF (ORCPT ); Mon, 3 Aug 2020 08:33:05 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E267B2076B; Mon, 3 Aug 2020 12:33:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596457984; bh=KP2S6zjMVIV//HHt0ckkmTyuYNbrWQFsrRLKQQLWScM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kp4RF5e6c4AYx0kMN8O4UyRTljlgAvRHTt272KbNkLR/8MEm7sp0T7TM4yY8e2vDg 1aJYLuz0uZamTmBt75kc7L6eIFnyhOqUp+modpwVmBUKyvKT7TUTemC2ML+LdvZL2o 2ree9cpM+LCSTAdKLipHI+ikpgq+hlb30DbTG5tc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wang ShaoBo , Josh Poimboeuf , Thomas Gleixner , Sasha Levin Subject: [PATCH 4.19 52/56] x86/unwind/orc: Fix ORC for newly forked tasks Date: Mon, 3 Aug 2020 14:20:07 +0200 Message-Id: <20200803121852.874529785@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200803121850.306734207@linuxfoundation.org> References: <20200803121850.306734207@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josh Poimboeuf [ Upstream commit 372a8eaa05998cd45b3417d0e0ffd3a70978211a ] The ORC unwinder fails to unwind newly forked tasks which haven't yet run on the CPU. It correctly reads the 'ret_from_fork' instruction pointer from the stack, but it incorrectly interprets that value as a call stack address rather than a "signal" one, so the address gets incorrectly decremented in the call to orc_find(), resulting in bad ORC data. Fix it by forcing 'ret_from_fork' frames to be signal frames. Reported-by: Wang ShaoBo Signed-off-by: Josh Poimboeuf Signed-off-by: Thomas Gleixner Tested-by: Wang ShaoBo Link: https://lkml.kernel.org/r/f91a8778dde8aae7f71884b5df2b16d552040441.1594994374.git.jpoimboe@redhat.com Signed-off-by: Sasha Levin --- arch/x86/kernel/unwind_orc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/unwind_orc.c b/arch/x86/kernel/unwind_orc.c index 2701b370e58fe..1d264ba1e56d1 100644 --- a/arch/x86/kernel/unwind_orc.c +++ b/arch/x86/kernel/unwind_orc.c @@ -420,8 +420,11 @@ bool unwind_next_frame(struct unwind_state *state) /* * Find the orc_entry associated with the text address. * - * Decrement call return addresses by one so they work for sibling - * calls and calls to noreturn functions. + * For a call frame (as opposed to a signal frame), state->ip points to + * the instruction after the call. That instruction's stack layout + * could be different from the call instruction's layout, for example + * if the call was to a noreturn function. So get the ORC data for the + * call instruction itself. */ orc = orc_find(state->signal ? state->ip : state->ip - 1); if (!orc) @@ -634,6 +637,7 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task, state->sp = task->thread.sp; state->bp = READ_ONCE_NOCHECK(frame->bp); state->ip = READ_ONCE_NOCHECK(frame->ret_addr); + state->signal = (void *)state->ip == ret_from_fork; } if (get_stack_info((unsigned long *)state->sp, state->task, -- 2.25.1