From nobody Wed Apr 1 22:34:16 2026 Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D9CD31326C for ; Wed, 1 Apr 2026 07:52:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.71 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775029945; cv=none; b=FnUSMAJgUm3WQUfsDm4mJ6/1VbqmP7JKqw5c3OIxTbHSov82Xsv9D/GcHIYuXfzd0TAE9y4gE+cGcRMBpQfWqgzjhPH+f/145tYsm8SSkiW9Zixr8i3myTx1K7KhdCz46cJASd1iJYYBpSbYqtkxsq1cmK9fK8jfufBdAFdVet0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775029945; c=relaxed/simple; bh=FyHQrRixNuHY3TuPGX20owqGrB2OlzAiKA8xiEPHVFA=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=V0nrfCgasXsHft9JCiKYDKouV+/jHIJb6IpRfuld8++mljJqkxxv1O9+OntcycMwlOFojTbPP/9GHkxVYxlQMn1CbqtL9t7PICHxwzJ1WuKQxstUPC7eauUUWcReBOglqnsVot+zn1trBUbOj0nMJFY2cg7CYrqngrF+qQGpVCE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.210.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-ot1-f71.google.com with SMTP id 46e09a7af769-7d7e2c62d70so17483506a34.2 for ; Wed, 01 Apr 2026 00:52:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775029943; x=1775634743; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=S+68sZmqCexfhfw+WSxzxGkIMnh+0KSYlcjzrkgumr0=; b=cliHYO8SV9bJM2m5ScNsLfqVyg0gw2YWKW+TbH41Yb8ooHh6jMN86wZZ68x3zKtSUt d4Pi5h5ysUiBtU9nhLoRScutxAb2KbyE4aEkOnaBi/lsbLbV5vx3EgDBIHnTd2ekKWcC zL2CazT0Iz1xJPByjx4LbJDQL3EBb8mlSFY9+GdeIqil0Wy8bfmsASUycjgXr4y1zG89 ZAuBkYngFSEYe7upFn8jUi7Em7GjpLkvudXC7PvLoM0QnZCS6eamIuInwszAaWSr1mly L3OXbJxCAVeOBpUgEaChU/Ax+pHtgOELvZP3LgJk76PnDm/gR6GuvCbmC1nq7n2S3E0P PeSQ== X-Gm-Message-State: AOJu0Yx28WQr4S4BN8N3uozYUw9nyMO/uocqZGkfUIR7eTGCz3R3++tr 5afM/MzI7AcTYP0q4ZqWXSKzs/Z6YQr3LNTsXXHVYI/QcB8Tot0TLJg/sLYZIcUUEIkICLRS5Wy aNc6g7IZ06FqK4EP1t7DAbKhfCiyztFzZKVN4o7SvRY12oIazX626gJWhTyo= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:1693:b0:67e:2d6d:139a with SMTP id 006d021491bc7-67fabcc93e8mr1240974eaf.35.1775029942935; Wed, 01 Apr 2026 00:52:22 -0700 (PDT) Date: Wed, 01 Apr 2026 00:52:22 -0700 In-Reply-To: <69ccb65b.050a0220.183828.003a.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69ccceb6.050a0220.183828.0040.GAE@google.com> Subject: Forwarded: [PATCH] mm/migrate: fix stale partially_mapped arg to deferred_split_folio() From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] mm/migrate: fix stale partially_mapped arg to deferred_spl= it_folio() Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.gi= t master In migrate_folio_move(), src_partially_mapped is sampled from the source folio before move_to_new_folio() is called: if (folio_order(src) > 1 && !data_race(list_empty(&src->_deferred_list))) { src_deferred_split =3D true; src_partially_mapped =3D folio_test_partially_mapped(src); } A concurrent thread can unmap pages from the source folio between this read and the actual migration, making the sampled value stale. After move_to_new_folio() succeeds, __folio_migrate_mapping() has already copied all folio flags including PG_partially_mapped from src to dst. Passing the stale src_partially_mapped=3Dfalse to deferred_split_folio(dst) while dst already has PG_partially_mapped=3Dtrue triggers the invariant check in deferred_split_folio(): VM_WARN_ON_FOLIO(folio_test_partially_mapped(folio), folio) at mm/huge_memory.c:4371, because the argument contradicts the flag already set on the folio. Fix this by removing the src_partially_mapped variable entirely and reading PG_partially_mapped directly from dst after move_to_new_folio() completes, where it is authoritative and race-free. Reported-by: syzbot+a7067a757858ac8eb085@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3Da7067a757858ac8eb085 Signed-off-by: Deepanshu Kartikey --- mm/migrate.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 05cb408846f2..11236779e910 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1361,7 +1361,6 @@ static int migrate_folio_move(free_folio_t put_new_fo= lio, unsigned long private, int old_page_state =3D 0; struct anon_vma *anon_vma =3D NULL; bool src_deferred_split =3D false; - bool src_partially_mapped =3D false; struct list_head *prev; =20 __migrate_folio_extract(dst, &old_page_state, &anon_vma); @@ -1378,7 +1377,6 @@ static int migrate_folio_move(free_folio_t put_new_fo= lio, unsigned long private, if (folio_order(src) > 1 && !data_race(list_empty(&src->_deferred_list))) { src_deferred_split =3D true; - src_partially_mapped =3D folio_test_partially_mapped(src); } =20 rc =3D move_to_new_folio(dst, src, mode); @@ -1404,11 +1402,13 @@ static int migrate_folio_move(free_folio_t put_new_= folio, unsigned long private, /* * Requeue the destination folio on the deferred split queue if * the source was on the queue. The source is unqueued in - * __folio_migrate_mapping(), so we recorded the state from - * before move_to_new_folio(). + * __folio_migrate_mapping(). Read PG_partially_mapped directly from + * dst: move_to_new_folio() copies all flags from src to dst, so dst + * now holds the correct authoritative state. The pre-migration value + * sampled from src is racy and must not be used. */ if (src_deferred_split) - deferred_split_folio(dst, src_partially_mapped); + deferred_split_folio(dst, folio_test_partially_mapped(dst)); =20 out_unlock_both: folio_unlock(dst); --=20 2.43.0