Received: by 2002:a17:90a:8504:0:0:0:0 with SMTP id l4csp2235763pjn; Thu, 24 Oct 2019 06:48:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/NYIvCI0ipIQnBhM/Otc1Y4VOXNcL3u2uMXFMXP94CMGxY09KUfqy/TXrTCrxWVStLWVP X-Received: by 2002:aa7:cfd4:: with SMTP id r20mr43400858edy.268.1571924913077; Thu, 24 Oct 2019 06:48:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571924913; cv=none; d=google.com; s=arc-20160816; b=Ep0xHWnP8mMwekFTX13dLF0teA/AKEK6LEXytIqcMTKCLKYKjTcoIWpGWXo6ACOyrB b4c772Dk2/2V2uATH+G+ePOWzPC0a/RhV/BfPloB8ap6DgKc7Ag7AYcyycTTeSg9AZ3s ze02vvZuRDJTInsl1vPy1tIQdvGiKL4ghE/6YdazMKAlz8oJO8VuTIgJJ0SaUwVFsz02 TXdIywMIiDndQHNOajikDDWRz8DjM1mIDqcbRG1Qb32EICJJGC75KlQ2C4sVN9ycthY7 zvRVb4gUkOPhjYExed5vdZSJ3artgKEB/L9HQyynFole5N33Qj8bJ38fNwqtFaGDoxaS NjaA== 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:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=B2jWJoLV4M/x0NOV2DvVdjIugn3QFhW+98dQqjMEXRs=; b=y3U3E4ZG8RGIORbkDHmrCwm+alsMPdet3PsjsnSQIV/lpG14ZQwxAPL2egcb485aaQ vDKIsjd7JxVxGAhLZX+DqyAOWiFqAzmeuG7DRNR/IoCU+TOzPtIsyRYVzUrgxp/xHcwV DVGV5l0mrBs6PotZYktIuh8Pg7rUf9IGjpSK7UrHXkAqHpycdr7eMnfj2w5ekFIkwDmV Z2Zdp2sQlYhXX0bUv9wBVDYIj5tRSKuNHi1km4IY9IE/FNi1vVt8I/TGfQDJqrEh2nUP oEI7NDB6qCPpw14MiJNoM2Ux+p2h78qBy8+rvUThSPk8595Oe1ozDrHsdSohg9kxyNfE e84w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TjHYF38Z; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gw3si4639580ejb.385.2019.10.24.06.48.07; Thu, 24 Oct 2019 06:48:33 -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=@redhat.com header.s=mimecast20190719 header.b=TjHYF38Z; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389696AbfJWTRg (ORCPT + 99 others); Wed, 23 Oct 2019 15:17:36 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:20314 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732232AbfJWTRg (ORCPT ); Wed, 23 Oct 2019 15:17:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571858255; h=from:from: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=B2jWJoLV4M/x0NOV2DvVdjIugn3QFhW+98dQqjMEXRs=; b=TjHYF38Z9lAFJaKAUzEiLl6KRn+Yz72OyN9m0GlOjTn5dqiWBWEy09PUnHXuC8ZrJ/wo3I 9ynJlrgmNSNJ1lISFJrHPfaPhgwufMr80FPFiVse5w6vwak1kTYrlKuPxHHu8Twy46DZTA 1wzkizizDejoFBaCnX3wLqgFZZQeaiM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-249-jDBA8Uu1MnGLZW0w92yTEw-1; Wed, 23 Oct 2019 15:17:31 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2A0A2107AD31; Wed, 23 Oct 2019 19:17:29 +0000 (UTC) Received: from treble (ovpn-121-225.rdu2.redhat.com [10.10.121.225]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7892D1001B3F; Wed, 23 Oct 2019 19:17:27 +0000 (UTC) Date: Wed, 23 Oct 2019 14:17:25 -0500 From: Josh Poimboeuf To: Thomas Gleixner Cc: Cyrill Gorcunov , LKML , Ingo Molnar , Peter Zijlstra , linux-mm@kvack.org, Catalin Marinas , x86@kernel.org Subject: Re: [PATCH] x86/dumpstack/64: Don't evaluate exception stacks before setup Message-ID: <20191023191725.67dg3vwkpodmbrqv@treble> References: <20191019114421.GK9698@uranus.lan> <20191022142325.GD12121@uranus.lan> <20191022145619.GE12121@uranus.lan> <20191023135943.GK12121@uranus.lan> MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: jDBA8Uu1MnGLZW0w92yTEw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 23, 2019 at 08:05:49PM +0200, Thomas Gleixner wrote: > Cyrill reported the following crash: >=20 > BUG: unable to handle page fault for address: 0000000000001ff0 > #PF: supervisor read access in kernel mode > RIP: 0010:get_stack_info+0xb3/0x148 >=20 > It turns out that if the stack tracer is invoked before the exception sta= ck > mappings are initialized in_exception_stack() can erroneously classify an > invalid address as an address inside of an exception stack: >=20 > begin =3D this_cpu_read(cea_exception_stacks); <- 0 > end =3D begin + sizeof(exception stacks); >=20 > i.e. any address between 0 and end will be considered as exception stack > address and the subsequent code will then try to derefence the resulting > stack frame at a non mapped address. >=20 > end =3D begin + (unsigned long)ep->size; > =3D=3D> end =3D 0x2000 >=20 > regs =3D (struct pt_regs *)end - 1; > =3D=3D> regs =3D 0x2000 - sizeof(struct pt_regs *) =3D 0x1ff0 >=20 > info->next_sp =3D (unsigned long *)regs->sp; > =3D=3D> Crashes due to accessing 0x1ff0 >=20 > Prevent this by checking the validity of the cea_exception_stack base > address and bailing out if it is zero. >=20 > Fixes: afcd21dad88b ("x86/dumpstack/64: Use cpu_entry_area instead of ori= g_ist") > Reported-by: Cyrill Gorcunov > Signed-off-by: Thomas Gleixner > Tested-by: Cyrill Gorcunov > Cc: stable@vger.kernel.org Acked-by: Josh Poimboeuf --=20 Josh