From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99B4AC433FE for ; Wed, 29 Sep 2021 15:21:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 52738613D0 for ; Wed, 29 Sep 2021 15:21:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 52738613D0 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id C18E6940020; Wed, 29 Sep 2021 11:21:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BC8B06B00A8; Wed, 29 Sep 2021 11:21:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB774940020; Wed, 29 Sep 2021 11:21:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0184.hostedemail.com [216.40.44.184]) by kanga.kvack.org (Postfix) with ESMTP id 9C9656B00A7 for ; Wed, 29 Sep 2021 11:21:15 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3E53A3947E for ; Wed, 29 Sep 2021 15:21:15 +0000 (UTC) X-FDA: 78640974510.09.F258B94 Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by imf06.hostedemail.com (Postfix) with ESMTP id EE033801AB14 for ; Wed, 29 Sep 2021 15:21:14 +0000 (UTC) Received: by mail-pg1-f171.google.com with SMTP id r2so3050942pgl.10 for ; Wed, 29 Sep 2021 08:21:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=hVd1gH+kQJeE39pFKVVrRFFFNBYhMYhDCh6W6dICdvg=; b=jxJaXVqLKmWeXRITZqbu/yFnOyoHEMy0nb1Vv4kwcyJCbrHuyudWxfXkDcUdLeeV5u oVJq9/Ap6P6u68TkD+22snpv2Dw6k2Pjt3AUc3NdvII749AokEMB1NkzkHOVHcjJdAyY Hlf7AAZpgx2hLOXn7sH6XpO6BvsT6zEyoY3PTDff32Rpi39Yww2IL04sus5DIfbQF7I1 QHxsmXgWCGtO+a1hlr5p4wQTPYFTc6JpE+rd5AP3BhZNmKQDaDY61PoPjf0GStMwn0Eo FWus/VQmH38ncDI6zC/7cG3mvQisORwuUozeCsJRYttLzbLVndb9ruzP3JYu3VDpuy1V qYaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=hVd1gH+kQJeE39pFKVVrRFFFNBYhMYhDCh6W6dICdvg=; b=fh1eeIphCJD/gaCaluqhkIUncrRsuIM5d+tiqcUVL/mKAOFbTAsUXaQpXWk3TpBSZj x9HNqy/iz7lmquPK5oG/cHlhagOccNB2pTelmp7LE5omKfo+lU6Db0/ifqut7zDzBdAx GJ7eVehzg2CqRuM33bjgO/K0fS9MF4Fw1Ih/SPR2qOFSglaUTsp8Fpv15O2Q88UriHkU pPT58XUifns/PYySRjv4hwEiTsncaFIQdgwj8OkK0v6MP31u3HYTaAtGGd/k5riN+aQZ i9XAXmmZCgqORAQIuuFUOCMjBZXeUwerDzxi3q9t3zMcNLGRO950LT8WwEUdBycE9hzA TtpQ== X-Gm-Message-State: AOAM530kxcPbV6C+/SJfyVUj8UV91tIa+avfU3QlDJnw8ZWTAMvvVJhu jI4a3QjlreB4hXKPcFK/xmABgw== X-Google-Smtp-Source: ABdhPJwknkO3jUb/3aE2bLJWkGe1nnBdpCwNHtCzopo/FM06iJLWiO7fnWcQuoA+N1ZtZtsABeFIjw== X-Received: by 2002:a63:790b:: with SMTP id u11mr454949pgc.71.1632928873659; Wed, 29 Sep 2021 08:21:13 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id p17sm197322pfo.9.2021.09.29.08.21.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 08:21:13 -0700 (PDT) Date: Wed, 29 Sep 2021 15:21:09 +0000 From: Sean Christopherson To: Stephen Cc: djwong@kernel.org, kvm@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: kvm crash in 5.14.1? Message-ID: References: <2b5ca6d3-fa7b-5e2f-c353-f07dcff993c1@gmail.com> <16c7a433-6e58-4213-bc00-5f6196fe22f5@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <16c7a433-6e58-4213-bc00-5f6196fe22f5@gmail.com> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: EE033801AB14 X-Stat-Signature: pzmi3xocfphtpob493zkddhpx7tu9a5p Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=jxJaXVqL; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf06.hostedemail.com: domain of seanjc@google.com designates 209.85.215.171 as permitted sender) smtp.mailfrom=seanjc@google.com X-HE-Tag: 1632928874-280023 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Sep 28, 2021, Stephen wrote: > Hello, >=20 > I got this crash again on 5.14.7 in the early morning of the 27th. > Things hung up shortly after I'd gone to bed. Uptime was 1 day 9 hours = 9 > minutes. ... > BUG: kernel NULL pointer dereference, address: 0000000000000068 > #PF: supervisor read access in kernel mode > #PF: error_code(0x0000) - not-present page > PGD 0 P4D 0 > Oops: 0000 [#1] SMP NOPTI > CPU: 21 PID: 8494 Comm: CPU 7/KVM Tainted: G=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0 E=A0=A0=A0=A0 5.14.7 #32 > Hardware name: Gigabyte Technology Co., Ltd. X570 AORUS ELITE WIFI/X570 > AORUS ELITE WIFI, BIOS F35 07/08/2021 > RIP: 0010:internal_get_user_pages_fast+0x738/0xda0 > Code: 84 24 a0 00 00 00 65 48 2b 04 25 28 00 00 00 0f 85 54 06 00 00 48 > 81 c4 a8 00 00 00 44 89 e0 5b 5d 41 5c 41 5d 41 5e 41 5f c3 <48> 81 78 > 68 a0 a3 > I haven't reproduced the crash, but the code signature (CMP against an ab= solute address) is quite distinct, and is consistent across all three crashes. = I'm pretty sure the issue is that page_is_secretmem() doesn't check for a null page-= >mapping, e.g. if the page is truncated, which IIUC can happen in parallel since gu= p() doesn't hold the lock. I think this should fix the problems? diff --git a/include/linux/secretmem.h b/include/linux/secretmem.h index 21c3771e6a56..988528b5da43 100644 --- a/include/linux/secretmem.h +++ b/include/linux/secretmem.h @@ -23,7 +23,7 @@ static inline bool page_is_secretmem(struct page *page) mapping =3D (struct address_space *) ((unsigned long)page->mapping & ~PAGE_MAPPING_FLAGS); - if (mapping !=3D page->mapping) + if (!mapping || mapping !=3D page->mapping) return false; return mapping->a_ops =3D=3D &secretmem_aops;