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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D8A8C4725D for ; Fri, 12 Jan 2024 01:45:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C2DC26B0098; Thu, 11 Jan 2024 20:45:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BB6866B009C; Thu, 11 Jan 2024 20:45:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A31126B009D; Thu, 11 Jan 2024 20:45:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 8958F6B009C for ; Thu, 11 Jan 2024 20:45:13 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 5CA8D140DB6 for ; Fri, 12 Jan 2024 01:45:13 +0000 (UTC) X-FDA: 81668966106.09.7110E27 Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) by imf03.hostedemail.com (Postfix) with ESMTP id 997F720007 for ; Fri, 12 Jan 2024 01:45:11 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Ud7mgaDP; spf=pass (imf03.hostedemail.com: domain of surenb@google.com designates 209.85.128.171 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705023911; h=from:from:sender: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:dkim-signature; bh=LwfKNFvm8QyzmQofKZ8aVlq1/QWvi0cu1esaAtwrFUo=; b=unj4UVvUg0uxFFXJHN3vPDwEaoI1AUVEucTjuXYQbE12YJHE7TMtBrpA3mmiDKVuvfXOnU m5VAB+DgDijlqbVxCs1ACPSs6EO89yvRen73Cc+Fd7GmYSxDeQWUYIYzsZY12k0gtumeBp Kcy4hBShjZAt6tYGQ9BJhGEI4qTVeIU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705023911; a=rsa-sha256; cv=none; b=gjzVWltXaTiYZjBOahuEA55fzA0i6LezwV87lUlRHQtEvtDsU+ofMXpK/WWYvi2e+k4nRH +kLQST16l6B3pH2NhTyDg6qjgljkOEkatKKmLpbvU2vq22uTeD+VG04mViNhzsfSUUo0U9 CQ+b7cX88vO2su6+tBHlMDMrazWgxyg= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Ud7mgaDP; spf=pass (imf03.hostedemail.com: domain of surenb@google.com designates 209.85.128.171 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-5fa4b03f3f5so30055327b3.1 for ; Thu, 11 Jan 2024 17:45:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705023910; x=1705628710; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=LwfKNFvm8QyzmQofKZ8aVlq1/QWvi0cu1esaAtwrFUo=; b=Ud7mgaDPFqWCA1H5SwJFvskCwuBGuRwU0KGzLqojloSGuRSErC42YYkkjFUdB098XR pM6F3Yt6yJgA9tO5oeOZC9OgZpIYs2fqgWcmch9zpnxOHdRfL/sTDYuz1v+bHaRaEbVn Ppq05pkvbcLBf9vtIWnqNsTCr1VNjxMK1MSY8zdJFbWmHccIzz6agYl7Ol9RWBbEg/eI EBEBvbiX/SQGoG3Zr2UTcMvlMkHxjr770GQOgrbeUYb8XpAnPYgfHiPKc8l7UhU0df29 QRyqs72Z1wQbaW8U+LiUUSBlVsOw7dQv8FDvs8qz8rqkePfNso18jOq4BgB+Ie1NBkDM hyOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705023910; x=1705628710; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LwfKNFvm8QyzmQofKZ8aVlq1/QWvi0cu1esaAtwrFUo=; b=N02cso5r52k1ht3bjx6HJHsPsujEUycAyrdGa7kAv8voB/3Q5IBfvaCDJbeGQsYFqB rwNwP+EF7nn2kAqw5telm7wHzruCmVrHI/pTgDkSHnd5IvC8maOytkTjJ2aSpsZ7kfnA vyCCswnC0pCu9nyMY6/ceAi2nNBunXxfVpHvVVQi6njnOdvFT1XmejPTxXkxDL52elCm 7mGSMSjz71mAwvpONhS3PohS3dmvzESiPgiWRE9E/eiwj+dDO9A+B1doKqKpee8kgJUa jWjAKazJKAew+YRNHlxoROfX4BCJJBE46STSNM0x3B+CtT/GAEgUm1JauyJ27RlUiz8B cNqQ== X-Gm-Message-State: AOJu0YwRnKvgW9C2BDWaNz/+pBNCSLTmj04LVlsfvvqYHgsBrDpMWBeZ e4q1tmQJuVpvmMMeesrWzBxjg4ZPYUjoTc8QW6A45g/rdvki2nt04MZzbZQKGRqJ X-Google-Smtp-Source: AGHT+IFAsCOpo+2v4dWFZPCTajTA6UTDPtSXWSL2urXkzvdbQCrm4msG36fdjr9pKizgskUhBp49zrNYMYRbfm2MWC4= X-Received: by 2002:a81:8396:0:b0:5f8:9702:4040 with SMTP id t144-20020a818396000000b005f897024040mr636949ywf.52.1705023910394; Thu, 11 Jan 2024 17:45:10 -0800 (PST) MIME-Version: 1.0 References: <00000000000011d709060eadffd3@google.com> <5ed23cf3-eedd-44aa-a498-d2a9ab046535@redhat.com> <15ce90cd-ff0b-4bc3-bee4-880bee3200ae@redhat.com> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 11 Jan 2024 17:44:57 -0800 Message-ID: Subject: Re: [syzbot] [mm?] kernel BUG in move_pages To: Stephen Rothwell , akpm@linux-foundation.org Cc: syzbot , Peter Xu , David Hildenbrand , aarcange@redhat.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 997F720007 X-Rspam-User: X-Stat-Signature: woh43cjbi6376zdbpm1uzixiinokig4q X-Rspamd-Server: rspam03 X-HE-Tag: 1705023911-498131 X-HE-Meta: U2FsdGVkX18kHxChbJCtSAi5ZWYwxS5tgV7ChHGqjDFgXzg2ONBLjCj52FCVn1evoscZus68PpyfMne6zuJljxlHPbJEQWxstfkuzYqNrarnKAT041XSnB/hNORBddGu8nKlX9jgbhvzHmdLk9Ci3la/s8I1uVswkQAPcgsQHV+gZ8vrYgdF7Zz0u8M8dL/UXreFLONFU/WeaJ79SoJeD4l1G8aOLJkHtIBlaQE98Rh44mNgmu9OKYlMteeHGlnjTnCExp3l/zgEeVsrUjAcVt1kVCvaMyfqitJr+asKqs3/T8dIuZEoyX3nQNY0MI2Vuopts31DDyl5GAlOZX31lv5u4YWd3IrB1vya7Qmq7MYQY9+uUwDGQqX/oC3x+F7V6vkQgwkH186RtVkq55UDqTn/6y/2f+GAUF9leAsLA0lD1gFxil+Dp77780+JsTrvuVxqaEQpQk6M3sNKlzGsgTuOXEUyhktKDqRuPqlKbYqtg8mnxCRRpj2sSYr5RuI643o3UZM9Je2/7eEAZnnvT/UVOB82vKAljzLpzHgdbj7i99XcGDvt8n5B4gdeKfsHhT0e6dLLSnoUZ6LKBzkdPtSAYhTJ1LHDzANDSNPUCtAgXZuRiMVd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b9gyEw69aR+c5IMoJr4CCqMJZm4WOJyhHj2svQFafWNowO4cIo6peabAQQ1IexUTNJEZZjJH3W4Pkc1dShxmzcOw59oW+8HGJS+GABMiqmjxA059nbGpmbyLLYDw9/RrnlULxZOW+9n9tsiEAXy04MDXpdmCer+3C49yq/bYibrjEbKgisD0nuUR6OOrDLGdslob7j9XMLJdtjJynalQNFsCnbLWqNYbkoGpHE24Or7UDanXz30X2Uo7wObOk6e 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: List-Subscribe: List-Unsubscribe: On Thu, Jan 11, 2024 at 3:23=E2=80=AFPM Suren Baghdasaryan wrote: > > On Thu, Jan 11, 2024 at 9:13=E2=80=AFPM Suren Baghdasaryan wrote: > > > > On Thu, Jan 11, 2024 at 1:06=E2=80=AFPM David Hildenbrand wrote: > > > > > > On 11.01.24 22:04, Suren Baghdasaryan wrote: > > > > On Thu, Jan 11, 2024 at 9:00=E2=80=AFPM David Hildenbrand wrote: > > > >> > > > >> On 11.01.24 21:20, Suren Baghdasaryan wrote: > > > >>> On Thu, Jan 11, 2024 at 6:58=E2=80=AFPM David Hildenbrand wrote: > > > >>>> > > > >>>> On 11.01.24 19:34, Suren Baghdasaryan wrote: > > > >>>>> On Thu, Jan 11, 2024 at 8:44=E2=80=AFAM Suren Baghdasaryan wrote: > > > >>>>>> > > > >>>>>> On Thu, Jan 11, 2024 at 8:40=E2=80=AFAM Suren Baghdasaryan wrote: > > > >>>>>>> > > > >>>>>>> On Thu, Jan 11, 2024 at 8:25=E2=80=AFAM syzbot > > > >>>>>>> wrote= : > > > >>>>>>>> > > > >>>>>>>> Hello, > > > >>>>>>>> > > > >>>>>>>> syzbot found the following issue on: > > > >>>>>>>> > > > >>>>>>>> HEAD commit: e2425464bc87 Add linux-next specific files f= or 20240105 > > > >>>>>>>> git tree: linux-next > > > >>>>>>>> console+strace: https://syzkaller.appspot.com/x/log.txt?x=3D= 14941cdee80000 > > > >>>>>>>> kernel config: https://syzkaller.appspot.com/x/.config?x=3D= 4056b9349f3da8c9 > > > >>>>>>>> dashboard link: https://syzkaller.appspot.com/bug?extid=3D70= 5209281e36404998f6 > > > >>>>>>>> compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU B= inutils for Debian) 2.40 > > > >>>>>>>> syz repro: https://syzkaller.appspot.com/x/repro.syz?x= =3D125d0a09e80000 > > > >>>>>>>> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=3D= 15bc7331e80000 > > > >>>>>>>> > > > >>>>>>>> Downloadable assets: > > > >>>>>>>> disk image: https://storage.googleapis.com/syzbot-assets/2f7= 38185e2cf/disk-e2425464.raw.xz > > > >>>>>>>> vmlinux: https://storage.googleapis.com/syzbot-assets/b248fc= f4ea46/vmlinux-e2425464.xz > > > >>>>>>>> kernel image: https://storage.googleapis.com/syzbot-assets/a= 9945c8223f4/bzImage-e2425464.xz > > > >>>>>>>> > > > >>>>>>>> The issue was bisected to: > > > >>>>>>>> > > > >>>>>>>> commit adef440691bab824e39c1b17382322d195e1fab0 > > > >>>>>>>> Author: Andrea Arcangeli > > > >>>>>>>> Date: Wed Dec 6 10:36:56 2023 +0000 > > > >>>>>>>> > > > >>>>>>>> userfaultfd: UFFDIO_MOVE uABI > > > >>>>>>>> > > > >>>>>>>> bisection log: https://syzkaller.appspot.com/x/bisect.txt?x= =3D11cb6ea9e80000 > > > >>>>>>>> final oops: https://syzkaller.appspot.com/x/report.txt?x= =3D13cb6ea9e80000 > > > >>>>>>>> console output: https://syzkaller.appspot.com/x/log.txt?x=3D= 15cb6ea9e80000 > > > >>>>>>>> > > > >>>>>>>> IMPORTANT: if you fix the issue, please add the following ta= g to the commit: > > > >>>>>>>> Reported-by: syzbot+705209281e36404998f6@syzkaller.appspotma= il.com > > > >>>>>>>> Fixes: adef440691ba ("userfaultfd: UFFDIO_MOVE uABI") > > > >>>>>>>> > > > >>>>>>>> do_one_initcall+0x128/0x680 init/main.c:1237 > > > >>>>>>>> do_initcall_level init/main.c:1299 [inline] > > > >>>>>>>> do_initcalls init/main.c:1315 [inline] > > > >>>>>>>> do_basic_setup init/main.c:1334 [inline] > > > >>>>>>>> kernel_init_freeable+0x692/0xc30 init/main.c:1552 > > > >>>>>>>> kernel_init+0x1c/0x2a0 init/main.c:1442 > > > >>>>>>>> ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147 > > > >>>>>>>> ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:24= 2 > > > >>>>>>>> ------------[ cut here ]------------ > > > >>>>>>>> kernel BUG at include/linux/page-flags.h:1035! > > > >>>>>>>> invalid opcode: 0000 [#1] PREEMPT SMP KASAN > > > >>>>>>>> CPU: 0 PID: 5068 Comm: syz-executor191 Not tainted 6.7.0-rc8= -next-20240105-syzkaller #0 > > > >>>>>>>> Hardware name: Google Google Compute Engine/Google Compute E= ngine, BIOS Google 11/17/2023 > > > >>>>>>>> RIP: 0010:PageAnonExclusive include/linux/page-flags.h:1035 = [inline] > > > >>>>>>> > > > >>>>>>> From a quick look, I think the new ioctl is being used aga= inst a > > > >>>>>>> file-backed page and that's why PageAnonExclusive() throws th= is error. > > > >>>>>>> I'll confirm if this is indeed the case and will add checks f= or that > > > >>>>>>> case. Thanks! > > > >>>>>> > > > >>>>>> Hmm. Looking at the reproducer it does not look like a file-ba= cked > > > >>>>>> memory... Anyways, I'm on it. > > > >>>>> > > > >>>>> Looks like the test is trying to move the huge_zero_page. Wonde= r how > > > >>>>> we should handle this. Just fail or do something else? Adding D= avid > > > >>>>> and Peter for feedback. > > > >>>> > > > >>>> You'll need some special-casing to handle that. But it should be= fairly > > > >>>> easy. > > > >>> > > > >>> Ok, so should we treat zeropage the same as PAE and map destinati= on > > > >>> PTE/PMD to zeropage while clearing source PTE/PMD? > > > >> > > > >> Likely yes. So it's transparent for user space what we are moving.= (this > > > >> sounds like an easy case to not require a prior write access just = to > > > >> move it) > > > > > > > > Ok, working on it. split_huge_pmd() already knows how to split > > > > huge_zero_page but I think I'll need special handling in both > > > > move_pages_pte() and move_pages_huge_pmd(). > > > > > > A PTE-mapped huge zeropage is just a page table populated with the > > > ordinary shared zeropage. Are you moving the ordinary shared zeropage= as > > > well? If not, you should do so for consistency (or not do either :) )= . > > > > Yes, I think I should move ordinary zeropages as well. > > I have a version that seems to work but I want to test it more and > it's too heavy to be considered a quick fix for linux-next. I'll post > a simple one-line fix which takes care of this crash and keeps the > behavior for zeropages the same (ioctl returns -EBUSY). Later will > post a separate patch to move huge and ordinary zeropages. I posted a quick fix for this issue here: https://lore.kernel.org/all/20240112013935.1474648-1-surenb@google.com/ It cleanly applies over linux-next, mm-stable and mm-unstable. Andrew, Stephen, could you please pull the fix into your branches? Thanks, Suren. > > > > > > > > > -- > > > Cheers, > > > > > > David / dhildenb > > >