Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp841894ybh; Wed, 22 Jul 2020 14:59:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcmjOd9IWJ9kcQ8fZ/3MwnBK+MV9Eb9Iz06uTFA1FN8uQwe33iza/33DVZVoxtEnZShkID X-Received: by 2002:a17:906:9348:: with SMTP id p8mr1586249ejw.467.1595455149695; Wed, 22 Jul 2020 14:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595455149; cv=none; d=google.com; s=arc-20160816; b=qnE4B+YuLPyKzNRrz196zYnWnKQ3QJjeTckz+lRl943jAiZ0rsOZ/o77UYYp38jBSG FXWZbsVBKCyBLzone8ZVbmJH4FfkhtFm29ourji9GXcdzCBlF/dc6rRGLa9Mk/x9kbye 95nk+IR9FcrfZLSgDJElyMCRxQBU2BqVhg/+HAysA5unOup/9JRmxkQL3WE9ZVCt/tj8 BKXfp1WkVxISxwDOq5b5Le680/p0XqHkE2emxcOZd7ylHW6QM7UW9Je/Srcpzij5Tjzj EL7UViTkvY1se2tBoNdIdyMrl+T4tf9xl6nFLX1wwxw2RDdHyOx4AHIP6ifVDCnljsI7 gJ8g== 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:dkim-signature :dkim-signature:date; bh=sMB1u185xELWvtA2XnvmJscfBxUyPz4bqw9RjDthIVI=; b=JCowL3jX+jlpZkd5KE+UH4yOZr5U31GkJVQRkLvftN2XBov9THHCA5PPxvAK9CkXGy 87jca+8uAyrnBkuWCxLwn03upbT6139JojWKnyQaw9317f2dL2/Y2V3aB9SipuEhdcTY bBB5lPzeojltBCcqtabe8p57joMvNo8SQvuY06m8GfcdYbyH2RcGfCqbTxL3WOm2mv75 Mh3TsgMY/BTuFE5O4VUIkqC2c406vgh0ZFNXHZI6dSBLSJ1crpHJff/ldRkwmGZ7H4GY cK3nfjke2BsYdBmDaCMYZ7rHJcyVb935KxnBwen4wB3MXS1Gwn+yya7p51+WvG2RU2Mj PFmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b="3lMKpZG/"; dkim=neutral (no key) header.i=@vger.kernel.org; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ni2si826956ejb.19.2020.07.22.14.58.46; Wed, 22 Jul 2020 14:59:09 -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=fail header.i=@linutronix.de header.s=2020 header.b="3lMKpZG/"; dkim=neutral (no key) header.i=@vger.kernel.org; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733022AbgGVVzr (ORCPT + 99 others); Wed, 22 Jul 2020 17:55:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730938AbgGVVzj (ORCPT ); Wed, 22 Jul 2020 17:55:39 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1D7AC0619DC; Wed, 22 Jul 2020 14:55:38 -0700 (PDT) Date: Wed, 22 Jul 2020 21:55:36 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1595454937; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sMB1u185xELWvtA2XnvmJscfBxUyPz4bqw9RjDthIVI=; b=3lMKpZG/UiGjsx6/N2dDssrsL3jVrUs5qDF+6q/Iq0Cm3o1RosA0QOaVUAlIcyF/pAwgAO jkezdH+vDeQjqCNHcvkdnctyhKq4Cs8H8goD4QGPWtGrq2Fa+126zRppfOfPOCmjZDpXCM ZOM5CCyShZJvxfdW+i73q9EQTUTEFBZP9KShreZWtYQ7AzLdyqICDNbfzjudiRdOuVd0zH IdAD0xuoimVXcgDz8aVzeYNyrpCfsF1u0dMUvss9FVr+6eDIXa4zFaXlAg6Km2oUTKnt6N eNCcq7Oo+YVRHzISOsU0zKMaJ0MA/rC2ZtlwXUKH/i5sfksjAePvh5mvuwrlpQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1595454937; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sMB1u185xELWvtA2XnvmJscfBxUyPz4bqw9RjDthIVI=; b=kjsOPflk0wpTa2tK3KGbDlupC+qxx5K7elor+2bG1p4fBKoX0NIC1D+KtjrC17/ldRPPs2 yaoopoiR6+Gh6UAg== From: "tip-bot2 for Josh Poimboeuf" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/unwind/orc: Fix ORC for newly forked tasks Cc: Wang ShaoBo , Josh Poimboeuf , Thomas Gleixner , x86 , LKML In-Reply-To: References: MIME-Version: 1.0 Message-ID: <159545493667.4006.9690401904155723707.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 x86/urgent branch of tip: Commit-ID: 372a8eaa05998cd45b3417d0e0ffd3a70978211a Gitweb: https://git.kernel.org/tip/372a8eaa05998cd45b3417d0e0ffd3a70978211a Author: Josh Poimboeuf AuthorDate: Fri, 17 Jul 2020 09:04:25 -05:00 Committer: Thomas Gleixner CommitterDate: Wed, 22 Jul 2020 23:47:47 +02:00 x86/unwind/orc: Fix ORC for newly forked tasks 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 --- 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 7f969b2..ec88bbe 100644 --- a/arch/x86/kernel/unwind_orc.c +++ b/arch/x86/kernel/unwind_orc.c @@ -440,8 +440,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) { @@ -662,6 +665,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,