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=-12.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham 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 411DEC2BA1A for ; Tue, 7 Apr 2020 00:47:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D2EEE20768 for ; Tue, 7 Apr 2020 00:47:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cdgVFwQz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2EEE20768 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6C7C38E0005; Mon, 6 Apr 2020 20:47:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6518A8E0001; Mon, 6 Apr 2020 20:47:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F2948E0005; Mon, 6 Apr 2020 20:47:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0037.hostedemail.com [216.40.44.37]) by kanga.kvack.org (Postfix) with ESMTP id 323BA8E0001 for ; Mon, 6 Apr 2020 20:47:55 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D51C1180AD806 for ; Tue, 7 Apr 2020 00:47:54 +0000 (UTC) X-FDA: 76679221668.23.cause19_450bc1311a50f X-HE-Tag: cause19_450bc1311a50f X-Filterd-Recvd-Size: 10391 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Apr 2020 00:47:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586220473; 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=joQ356/2rSOOl9akZr+4KkyKfLaFYNaFUee0hkyR2AU=; b=cdgVFwQzsh8we0YKoFcg7PE5zCgf47gaUyTotz4haExWsw6ISDPrJ4p/Nf3neSibXBNNor CjWiCDrkgxN/obldaTt/yeFlmYqeuBRTwubroJ/gN0zsRu32onJVz18sId3/aFFPocaD8u o+qgDsfI2A/cmVImSCFR/V1OKiTRVNw= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-129-NJQVOlKhOMSIijn1RAzmDA-1; Mon, 06 Apr 2020 20:47:49 -0400 X-MC-Unique: NJQVOlKhOMSIijn1RAzmDA-1 Received: by mail-qt1-f198.google.com with SMTP id g7so1673966qtr.0 for ; Mon, 06 Apr 2020 17:47:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=4A8YQ5Dh8Pgj3CT+hoT9bdocZnF590ggcBE/fA6MdEE=; b=oyxFtMeAcrM8g+mLycdTbC7a/oQrNbnUUkparnZtAY9jH64DkqphXVhIQaT8XOXGBc MvtuSxL4+UWkxDCqCuj02OEuLx/BIKGb25/WIX/Kcb/XzPSWgc1YyztoicI50R8PXDiD qgDJ8qs9lMVw2rRKLcm+UQYRXvQswKHHbR+u+5LCBUVLuRzekyCnCeWyGWkn/UtMCGRO gRLP52cxZz0aYGU18owZoWoTslbx9UE5XDCkT9fuhRPz3039eTuc13Tfy/3WGpMP6+YD hqUpaSBcms/PrTIqzt5KqryFfJhmVyCQ9jDq2FlHjX2tsDg2l9xAg/HYaAJMpBpH+pPC +vBw== X-Gm-Message-State: AGi0PuaZaqeBMt+SahQYip8NK84ArQ2+jSMj2J1pY2Ubm61cVgmQV5wh nG1zOX9tiuBVyU5MKqWB4ZEV5730sjKLy5j8+qsqGN+Za+UU+13dIQLnS+qyKcIrj8DhVob355O f6/icxCK6PIA= X-Received: by 2002:a37:7783:: with SMTP id s125mr23639958qkc.492.1586220468212; Mon, 06 Apr 2020 17:47:48 -0700 (PDT) X-Google-Smtp-Source: APiQypJthXq8oS2luLAC4buCmradNon+P1k+eclnAatgEv20AvDoW0IJySAEDm28yeYeY314bvR4bQ== X-Received: by 2002:a37:7783:: with SMTP id s125mr23639944qkc.492.1586220467864; Mon, 06 Apr 2020 17:47:47 -0700 (PDT) Received: from xz-x1 ([2607:9880:19c0:32::3]) by smtp.gmail.com with ESMTPSA id f24sm15097483qkk.127.2020.04.06.17.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 17:47:47 -0700 (PDT) Date: Mon, 6 Apr 2020 20:47:45 -0400 From: Peter Xu To: syzbot Cc: akpm@linux-foundation.org, bgeffon@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, syzkaller-bugs@googlegroups.com, torvalds@linux-foundation.org Subject: Re: BUG: unable to handle kernel paging request in kernel_get_mempolicy Message-ID: <20200407004745.GA48345@xz-x1> References: <0000000000002b25f105a2a3434d@google.com> MIME-Version: 1.0 In-Reply-To: <0000000000002b25f105a2a3434d@google.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 Mon, Apr 06, 2020 at 11:16:13AM -0700, syzbot wrote: > Hello, >=20 > syzbot found the following crash on: >=20 > HEAD commit: bef7b2a7 Merge tag 'devicetree-for-5.7' of git://git.kern= e.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=3D13966e8fe0000= 0 > kernel config: https://syzkaller.appspot.com/x/.config?x=3D91b674b8f0368= e69 > dashboard link: https://syzkaller.appspot.com/bug?extid=3D693dc11fcb53120= b5559 > compiler: gcc (GCC) 9.0.0 20181231 (experimental) > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=3D1738b02be00= 000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=3D17d2c76de0000= 0 >=20 > The bug was bisected to: >=20 > commit 4426e945df588f2878affddf88a51259200f7e29 > Author: Peter Xu > Date: Thu Apr 2 04:08:49 2020 +0000 >=20 > mm/gup: allow VM_FAULT_RETRY for multiple times >=20 > bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=3D14ac4a5de0= 0000 > final crash: https://syzkaller.appspot.com/x/report.txt?x=3D16ac4a5de0= 0000 > console output: https://syzkaller.appspot.com/x/log.txt?x=3D12ac4a5de0000= 0 >=20 > IMPORTANT: if you fix the bug, please add the following tag to the commit= : > Reported-by: syzbot+693dc11fcb53120b5559@syzkaller.appspotmail.com > Fixes: 4426e945df58 ("mm/gup: allow VM_FAULT_RETRY for multiple times") >=20 > BUG: unable to handle page fault for address: ffffffff00000000 > #PF: supervisor read access in kernel mode > #PF: error_code(0x0000) - not-present page > PGD 987c067 P4D 987c067 PUD 0=20 > Oops: 0000 [#1] PREEMPT SMP KASAN > CPU: 1 PID: 7181 Comm: syz-executor616 Not tainted 5.6.0-syzkaller #0 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS G= oogle 01/01/2011 > RIP: 0010:page_to_nid include/linux/mm.h:1245 [inline] > RIP: 0010:lookup_node mm/mempolicy.c:906 [inline] > RIP: 0010:do_get_mempolicy mm/mempolicy.c:970 [inline] > RIP: 0010:kernel_get_mempolicy+0x60e/0xfb0 mm/mempolicy.c:1615 > Code: 88 00 07 00 00 e8 b2 35 c5 ff 4c 8b 7c 24 78 48 b8 00 00 00 00 00 f= c ff df 4c 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 fb 08 00 00 <49> 8b 1f 48 c7= c7 ff ff ff ff 48 89 de e8 10 37 c5 ff 48 83 fb ff > RSP: 0018:ffffc900018d7de8 EFLAGS: 00010246 > RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff81adaaf1 > RDX: 1fffffffe0000000 RSI: ffffffff81adaafe RDI: 0000000000000005 > RBP: 0000000000000000 R08: ffff88808de924c0 R09: ffffed1011bd2499 > R10: ffff88808de924c7 R11: ffffed1011bd2498 R12: 0000000000000000 > R13: 1ffff9200031afc4 R14: ffffffff89a6df60 R15: ffffffff00000000 > FS: 00007f848cd4a700(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000= 000 > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > CR2: ffffffff00000000 CR3: 00000000a7a8d000 CR4: 00000000001406e0 > DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 > Call Trace: > __do_sys_get_mempolicy mm/mempolicy.c:1633 [inline] > __se_sys_get_mempolicy mm/mempolicy.c:1629 [inline] > __x64_sys_get_mempolicy+0xba/0x150 mm/mempolicy.c:1629 > do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295 > entry_SYSCALL_64_after_hwframe+0x49/0xb3 > RIP: 0033:0x446719 > Code: e8 5c b3 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f= 7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff= ff 0f 83 0b 08 fc ff c3 66 2e 0f 1f 84 00 00 00 00 > RSP: 002b:00007f848cd49db8 EFLAGS: 00000246 ORIG_RAX: 00000000000000ef > RAX: ffffffffffffffda RBX: 00000000006dbc28 RCX: 0000000000446719 > RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 > RBP: 00000000006dbc20 R08: 0000000000000003 R09: 0000000000000000 > R10: 000000002073b000 R11: 0000000000000246 R12: 00000000006dbc2c > R13: 00007ffcfe6ba66f R14: 00007f848cd4a9c0 R15: 20c49ba5e353f7cf > Modules linked in: > CR2: ffffffff00000000 > ---[ end trace 0becf554e06291c3 ]--- > RIP: 0010:page_to_nid include/linux/mm.h:1245 [inline] > RIP: 0010:lookup_node mm/mempolicy.c:906 [inline] > RIP: 0010:do_get_mempolicy mm/mempolicy.c:970 [inline] > RIP: 0010:kernel_get_mempolicy+0x60e/0xfb0 mm/mempolicy.c:1615 > Code: 88 00 07 00 00 e8 b2 35 c5 ff 4c 8b 7c 24 78 48 b8 00 00 00 00 00 f= c ff df 4c 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 fb 08 00 00 <49> 8b 1f 48 c7= c7 ff ff ff ff 48 89 de e8 10 37 c5 ff 48 83 fb ff > RSP: 0018:ffffc900018d7de8 EFLAGS: 00010246 > RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff81adaaf1 > RDX: 1fffffffe0000000 RSI: ffffffff81adaafe RDI: 0000000000000005 > RBP: 0000000000000000 R08: ffff88808de924c0 R09: ffffed1011bd2499 > R10: ffff88808de924c7 R11: ffffed1011bd2498 R12: 0000000000000000 > R13: 1ffff9200031afc4 R14: ffffffff89a6df60 R15: ffffffff00000000 > FS: 00007f848cd4a700(0000) GS:ffff8880ae700000(0000) knlGS:0000000000000= 000 > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > CR2: ffffffff00000000 CR3: 00000000a7a8d000 CR4: 00000000001406e0 > DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Hi, Andrew & all, I can reproduce this locally right after I run the test program, and below patch fixed it for me - the test program can run with quite a few minutes without crashing again. Is there a way I can feed this to the syzbot to re-verify this? Thanks, 8<--------------------------------------------------------------- >From 23800bff6fa346a4e9b3806dc0cfeb74498df757 Mon Sep 17 00:00:00 2001 From: Peter Xu Date: Mon, 6 Apr 2020 20:40:13 -0400 Subject: [PATCH] mm/mempolicy: Allow lookup_node() to handle fatal signal lookup_node() uses gup to pin the page and get node information. It checks against ret>=3D0 assuming the page will be filled in. However it's also possible that gup will return zero, for example, when the thread is quickly killed with a fatal signal. Teach lookup_node() to gracefully return an error -EFAULT if it happens. Reported-by: syzbot+693dc11fcb53120b5559@syzkaller.appspotmail.com Fixes: 4426e945df58 ("mm/gup: allow VM_FAULT_RETRY for multiple times") Signed-off-by: Peter Xu --- mm/mempolicy.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 5fb427aed612..1398578db025 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -902,7 +902,10 @@ static int lookup_node(struct mm_struct *mm, unsigned = long addr) =20 =09int locked =3D 1; =09err =3D get_user_pages_locked(addr & PAGE_MASK, 1, 0, &p, &locked); -=09if (err >=3D 0) { +=09if (err =3D=3D 0) { +=09=09/* E.g. GUP interupted by fatal signal */ +=09=09err =3D -EFAULT; +=09} else if (err > 0) { =09=09err =3D page_to_nid(p); =09=09put_page(p); =09} --=20 2.24.1 --=20 Peter Xu