Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4465966ybi; Fri, 19 Jul 2019 23:31:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/R0jUCTh/+5e55yZiESt8eCKOX0+qsvBoam7Wy6bNL31YPVgOT5jeGMfurNAmEeqq6PpW X-Received: by 2002:a17:90a:1b48:: with SMTP id q66mr59822412pjq.83.1563604280383; Fri, 19 Jul 2019 23:31:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563604280; cv=none; d=google.com; s=arc-20160816; b=yIkXcFcG8PT9lg//mRkc3Ppzuia8lvatz1et0DOtNNNvVrGV1tJFlPv7MskbINtmJY ZcGCxVmm9HflmL7pxDUOb1z/88px687V0HbKMPr3aMTChQHPnTIP9eOQpcjPtF5ylqG9 K3czs0oSFvSOmkPDmTqeB8g1nHxwgOHTqUCqPCSipmrkgGI0kZL9IWK5szPPp50jebij KV0KkCgwHPMRVeF+9rsYz9aa15kiXJVYaleOU8Wt3lB26f0fr4e7T3U4ox8wLvIC40Y5 chKenMQE57tLCgHRWxYI29EgFoRUQvBGd346neNZ8kG+3TVwrJN+Z5dLPklD8+xFT527 LN7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=xI8LOf4fxPcSsxglDOVp/cCd5OYFK/pJvjk7UZ910sw=; b=HFk7CnbMhMQb9AyV6xs7+apBuHq6VVIZcYQYaELmotWNf/10jEZFGFXtgkofz8TUTD algOKQmtUdQCv9lHcY/X6OVmUCX2LQy7ozZsTJd8H6BQ0n7nmCyQswM10x4XQmp4ksIc 9vdcpyc9muGRrEx8IQ/knJiRYnnrzrH84pXjMvZ7PwYSjsv2PS3MNdOvDKJssOoKMF/P 8zDrF5P6w/E4fzBS+cgFJdtPY4f/j1MzlmJ1NjH1zQTye+awD9DzIzB8OeoBQTOcXgd2 bvx0dWW/RQ2uFqUZHiWA6wPJebn92LRE2uwV4GVYPKEB7W2juStoR3jcMA3zbeEynBqY SAzg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s7si6041048plp.66.2019.07.19.23.31.04; Fri, 19 Jul 2019 23:31:20 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728877AbfGSWYP (ORCPT + 99 others); Fri, 19 Jul 2019 18:24:15 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:33046 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727344AbfGSWYO (ORCPT ); Fri, 19 Jul 2019 18:24:14 -0400 Received: from pd9ef1cb8.dip0.t-ipconnect.de ([217.239.28.184] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hobHp-0006IG-Ng; Sat, 20 Jul 2019 00:23:34 +0200 Date: Sat, 20 Jul 2019 00:23:32 +0200 (CEST) From: Thomas Gleixner To: Sean Christopherson cc: Steven Rostedt , Peter Zijlstra , Eiichi Tsukata , edwintorok@gmail.com, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, Josh Poimboeuf , Joel Fernandes Subject: Re: [PATCH] x86/stacktrace: Do not access user space memory unnecessarily In-Reply-To: <20190719202836.GB13680@linux.intel.com> Message-ID: References: <20190702053151.26922-1-devel@etsukata.com> <20190702072821.GX3419@hirez.programming.kicks-ass.net> <20190702113355.5be9ebfe@gandalf.local.home> <20190702133905.1482b87e@gandalf.local.home> <20190719202836.GB13680@linux.intel.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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 On Fri, 19 Jul 2019, Sean Christopherson wrote: > On Tue, Jul 02, 2019 at 01:39:05PM -0400, Steven Rostedt wrote: > > I'm hitting a similar panic that bisects to commit > > a0d14b8909de ("x86/mm, tracing: Fix CR2 corruption") > > except I'm experiencing death immediately after starting init. > > Through sheer dumb luck, I tracked (pun intended) this down to forcing > context tracking: > > CONFIG_CONTEXT_TRACKING=y > CONFIG_CONTEXT_TRACKING_FORCE=y > CONFIG_VIRT_CPU_ACCOUNTING_GEN=y > > I haven't attempted to debug further and I'll be offline for most of the > next few days. Hopefully this is enough to root cause the badness. > > [ 0.680477] Run /sbin/init as init process > [ 0.682116] init[1]: segfault at 2926a7ef ip 00007f98a49d9c30 sp 00007fffd83e6af0 error 14 in ld-2.23.so[7f98a49d9000+26000] That's because the call into the context tracking muck clobbers RDX which contains the CR2 value on pagefault. So the pagefault resolves to crap and kills init. Brute force fix below. That needs to be conditional on read_cr2 but for now it does the job. Thanks, tglx 8<------------ --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -887,7 +887,9 @@ apicinterrupt IRQ_WORK_VECTOR irq_work .if \paranoid == 0 testb $3, CS(%rsp) jz .Lfrom_kernel_no_context_tracking_\@ + pushq %rdx CALL_enter_from_user_mode + popq %rdx .Lfrom_kernel_no_context_tracking_\@: .endif