Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp723675pxb; Wed, 29 Sep 2021 08:25:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwy5DXiF7E0/L8lfx/TJkWS6LJwFrA2umqT5in2ZdllUDF2gPy9E+54IIdeB0K51rz2vNxJ X-Received: by 2002:a50:dac4:: with SMTP id s4mr537981edj.374.1632929105012; Wed, 29 Sep 2021 08:25:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632929105; cv=none; d=google.com; s=arc-20160816; b=OzgTbQ0/gQZ9GiIJfpILgkWWOXkVWRtfSHCJTEeo8995j9aSDGylijf1MhVaunNmJ5 3f2g5zB9u9TAmH5BqiUsBpH2FkHOKv0Jpjc2VZAGYO/r0qrXg3qF2IeWY5N3xuUVestP jSOuX/5fxRxhXDwO6q5qxlZWIUh4NdtRjp4OQYsyMEDdcuPpZFOvoIroSkfsmbTS0K5a 0ByvHQpEf9MZ3+a/p10TMFJJEwb9yClvD1di2way8cNT9h4NF9A2LeaQCDSP8QZKAKx0 b83o5VH8LaH85P8NuJ2LMTX7P0ZVrziLHyH3f0CyaJ0+y5///qC5OYzmYQ0xa7knCiDa dbxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=hVd1gH+kQJeE39pFKVVrRFFFNBYhMYhDCh6W6dICdvg=; b=Sa9GjPUgQN/MSUMq6/noUZBeMhBr7l7jHVUPEJfGrZ+GD9aAGEZL9UO+z7Rr08bMOV hdQTyxRzUlzSGBHfpGmO8tz0AZ61MtfR0IkN8XQQE5feEMvQNOY1ELkV7vtWheaTVEZj ZsMpBDMxVwLyt27yrRv2Xt9ApvLWwCg6nIEYdMpHSfBtnd1klfTpaSjkow1GOmK26i+p oXLXuADrl6YCP7eIy9Jw5FvHMP3ihPZcspBdypqBL6ImdfJUjFB+r9/Kfpz1FGP2uv60 kGyvFFYxXyXMBFOI02n0fVD8Nf2HAYUfCTQJIJLypXzGxYKwk5OTMl8BYG+VeR8RpNrF ezsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=jxJaXVqL; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gt13si150632ejc.682.2021.09.29.08.24.40; Wed, 29 Sep 2021 08:25:04 -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=@google.com header.s=20210112 header.b=jxJaXVqL; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345091AbhI2PW4 (ORCPT + 99 others); Wed, 29 Sep 2021 11:22:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345102AbhI2PWz (ORCPT ); Wed, 29 Sep 2021 11:22:55 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B090C061764 for ; Wed, 29 Sep 2021 08:21:14 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id e7so3087074pgk.2 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=bHxUluuUren85rM7q8kjT5hvLd5SBgOUKPan0pUgl6f7rZaUPqhAmYIF+AYiUZRqKl n8wraG7pIJlZ50vvROZpCKAdPRBsjy/EIM8gxYQWgx1Bw5JpN3Ic7gCTyJV2v6v1NAe0 oGpz3GHuwzkaj4yGaFoDcGdUO0qYQyyNOKtri4qqLRiireHJBs+MOBmv5hGq6oG/NrkP AaxuVwR0cg/QMqVPC4CYt/ZA03ytoi2X9gSes59QEf589L2OnxruaAleMqcNKRJ6PVMf QdULZMK0sk8jEGGYKzlwx7c+wjdNOaMOyRvlT9Ozb16jatvNNXlLWsqsjFs4zHxapHx6 Q/Qw== X-Gm-Message-State: AOAM532GXEikg5GhiFr8QwAalRZuoHsItbF5B+z9UTVUQk6DG7487GOj 3lBQ33dZys7CjkW3v+oY0Hlqpw== 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 Content-Transfer-Encoding: 8bit In-Reply-To: <16c7a433-6e58-4213-bc00-5f6196fe22f5@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 28, 2021, Stephen wrote: > Hello, > > 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??????????? E???? 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 absolute 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 gup() 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 = (struct address_space *) ((unsigned long)page->mapping & ~PAGE_MAPPING_FLAGS); - if (mapping != page->mapping) + if (!mapping || mapping != page->mapping) return false; return mapping->a_ops == &secretmem_aops;