kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Stephen <stephenackerman16@gmail.com>
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?
Date: Wed, 29 Sep 2021 15:21:09 +0000	[thread overview]
Message-ID: <YVSEZTCbFZ+HD/f0@google.com> (raw)
In-Reply-To: <16c7a433-6e58-4213-bc00-5f6196fe22f5@gmail.com>

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;

  reply	other threads:[~2021-09-29 15:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-14  2:58 kvm crash in 5.14.1? Darrick J. Wong
2021-09-23 17:50 ` Stephen
2021-09-29  4:44   ` Stephen
2021-09-29 15:21     ` Sean Christopherson [this message]
2021-09-30 17:59       ` Darrick J. Wong
2021-10-04 16:54         ` Darrick J. Wong
2021-10-06 16:34           ` Darrick J. Wong
2021-10-03  5:47       ` Stephen
2021-10-09 19:00         ` Stephen
2021-10-13 19:00           ` Salvatore Bonaccorso
2021-10-13 19:05             ` Paolo Bonzini
2021-10-13 19:29               ` Sean Christopherson
2021-10-13 19:33                 ` Salvatore Bonaccorso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YVSEZTCbFZ+HD/f0@google.com \
    --to=seanjc@google.com \
    --cc=djwong@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=stephenackerman16@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).