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 X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BB71C433DF for ; Sat, 18 Jul 2020 08:54:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7F3E12173E for ; Sat, 18 Jul 2020 08:54:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F3E12173E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B23546B0007; Sat, 18 Jul 2020 04:54:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AD4AB8D0001; Sat, 18 Jul 2020 04:54:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9EA126B000C; Sat, 18 Jul 2020 04:54:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0065.hostedemail.com [216.40.44.65]) by kanga.kvack.org (Postfix) with ESMTP id 88B7D6B0007 for ; Sat, 18 Jul 2020 04:54:26 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id ED6131803106D for ; Sat, 18 Jul 2020 08:54:25 +0000 (UTC) X-FDA: 77050585290.20.event46_480ad2d26f12 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id C26A71807B5EA for ; Sat, 18 Jul 2020 08:54:25 +0000 (UTC) X-HE-Tag: event46_480ad2d26f12 X-Filterd-Recvd-Size: 5713 Received: from r3-23.sinamail.sina.com.cn (r3-23.sinamail.sina.com.cn [202.108.3.23]) by imf30.hostedemail.com (Postfix) with SMTP for ; Sat, 18 Jul 2020 08:54:23 +0000 (UTC) Received: from unknown (HELO localhost.localdomain)([221.219.4.152]) by sina.com with ESMTP id 5F12B8BA00030CFF; Sat, 18 Jul 2020 16:54:20 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com X-SMAIL-MID: 61265754919459 From: Hillf Danton To: syzbot Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Song Liu , "Kirill A . Shutemov" , syzkaller-bugs@googlegroups.com, Markus Elfring , Hillf Danton Subject: Re: general protection fault in khugepaged Date: Sat, 18 Jul 2020 16:54:09 +0800 Message-Id: <20200718085409.1448-1-hdanton@sina.com> In-Reply-To: <000000000000358aec05a9fc8aa8@google.com> References: MIME-Version: 1.0 X-Rspamd-Queue-Id: C26A71807B5EA X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.007606, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Wed, 08 Jul 2020 23:43:19 -0700 > syzbot found the following crash on: >=20 > HEAD commit: e44f65fd xen-netfront: remove redundant assignment to v= ari.. > git tree: net-next > console output: https://syzkaller.appspot.com/x/log.txt?x=3D15de54a7100= 000 > kernel config: https://syzkaller.appspot.com/x/.config?x=3D829871134ca= 5e230 > dashboard link: https://syzkaller.appspot.com/bug?extid=3Ded318e8b790ca= 72c5ad0 > compiler: gcc (GCC) 10.1.0-syz 20200507 > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=3D113406a71= 00000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=3D175597d3100= 000 >=20 > IMPORTANT: if you fix the bug, please add the following tag to the comm= it: > Reported-by: syzbot+ed318e8b790ca72c5ad0@syzkaller.appspotmail.com >=20 > general protection fault, probably for non-canonical address 0xdffffc00= 00000000: 0000 [#1] PREEMPT SMP KASAN > KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] > CPU: 1 PID: 1155 Comm: khugepaged Not tainted 5.8.0-rc2-syzkaller #0 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS= Google 01/01/2011 > RIP: 0010:anon_vma_lock_write include/linux/rmap.h:120 [inline] > RIP: 0010:collapse_huge_page mm/khugepaged.c:1110 [inline] > RIP: 0010:khugepaged_scan_pmd mm/khugepaged.c:1349 [inline] > RIP: 0010:khugepaged_scan_mm_slot mm/khugepaged.c:2110 [inline] > RIP: 0010:khugepaged_do_scan mm/khugepaged.c:2193 [inline] > RIP: 0010:khugepaged+0x3bba/0x5a10 mm/khugepaged.c:2238 > Code: 01 00 00 48 8d bb 88 00 00 00 48 89 f8 48 c1 e8 03 42 80 3c 30 00= 0f 85 fa 0f 00 00 48 8b 9b 88 00 00 00 48 89 d8 48 c1 e8 03 <42> 80 3c 3= 0 00 0f 85 d4 0f 00 00 48 8b 3b 48 83 c7 08 e8 9f ff 30 > RSP: 0018:ffffc90004be7c80 EFLAGS: 00010246 > RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff81a72d8b > RDX: ffff8880a69d8100 RSI: ffffffff81b7606b RDI: ffff88809f0577c0 > RBP: 0000000000000000 R08: 0000000000000000 R09: ffff8881ff213a7f > R10: 0000000000000080 R11: 0000000000000000 R12: ffffffff8aae6110 > R13: ffffc90004be7de0 R14: dffffc0000000000 R15: 0000000020000000 > FS: 0000000000000000(0000) GS:ffff8880ae700000(0000) knlGS:00000000000= 00000 > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > CR2: 0000000000000000 CR3: 00000001fe0cf000 CR4: 00000000001406e0 > DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 > Call Trace: > kthread+0x3b5/0x4a0 kernel/kthread.c:291 > ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) F= S") --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -435,7 +435,8 @@ static inline int khugepaged_test_exit(s } =20 static bool hugepage_vma_check(struct vm_area_struct *vma, - unsigned long vm_flags) + unsigned long vm_flags, + bool anon) { if ((!(vm_flags & VM_HUGEPAGE) && !khugepaged_always()) || (vm_flags & VM_NOHUGEPAGE) || @@ -446,6 +447,8 @@ static bool hugepage_vma_check(struct vm (IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS) && vma->vm_file && (vm_flags & VM_DENYWRITE))) { + if (anon) + return false; return IS_ALIGNED((vma->vm_start >> PAGE_SHIFT) - vma->vm_pgoff, HPAGE_PMD_NR); } @@ -499,7 +502,7 @@ int khugepaged_enter_vma_merge(struct vm * khugepaged does not yet work on special mappings. And * file-private shmem THP is not supported. */ - if (!hugepage_vma_check(vma, vm_flags)) + if (!hugepage_vma_check(vma, vm_flags, false)) return 0; =20 hstart =3D (vma->vm_start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK; @@ -956,7 +959,7 @@ static int hugepage_vma_revalidate(struc hend =3D vma->vm_end & HPAGE_PMD_MASK; if (address < hstart || address + HPAGE_PMD_SIZE > hend) return SCAN_ADDRESS_RANGE; - if (!hugepage_vma_check(vma, vma->vm_flags)) + if (!hugepage_vma_check(vma, vma->vm_flags, true)) return SCAN_VMA_CHECK; return 0; } @@ -1426,7 +1429,7 @@ void collapse_pte_mapped_thp(struct mm_s * the valid THP. Add extra VM_HUGEPAGE so hugepage_vma_check() * will not fail the vma for missing VM_HUGEPAGE */ - if (!hugepage_vma_check(vma, vma->vm_flags | VM_HUGEPAGE)) + if (!hugepage_vma_check(vma, vma->vm_flags | VM_HUGEPAGE, false)) return; =20 pmd =3D mm_find_pmd(mm, haddr); @@ -2071,7 +2074,7 @@ static unsigned int khugepaged_scan_mm_s progress++; break; } - if (!hugepage_vma_check(vma, vma->vm_flags)) { + if (!hugepage_vma_check(vma, vma->vm_flags, false)) { skip: progress++; continue;