From nobody Thu Apr 2 22:21:29 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 75C4835FF53 for ; Fri, 13 Feb 2026 15:43:49 +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=1770997431; cv=none; b=FyTPkHbg/pcrkFSbij5Jr3peBRcau09oHoFwRMS3oNyYe+Q9qPrn6Dmvo+cKFK4+i6LYZuN/rnyaYSZg9yE6NKqLGSkIoVtVn48aBPSM1T2Mw+ly01DtjvbXVxUOo5A8wYiYCSZ/g+QmAW3WD3Y0J1SskN2l0m5KX6PlZw+xqVE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770997431; c=relaxed/simple; bh=uCLgV2PMp8gf2pLWiVYFR3V+Qluu7e3zMCSu7Z7lB9c=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=cu+WPEiz3awkZ9aaMCHHfmH5Dojg/U6EhClyi4jVDmEt/Waafo6osAo8LzTgTZoGq3Khb2ZmoZnAm2cnrYWFzC/HwNAT2yl2dTSHK31l6CEcjjOpQCk7gNzBF47OPi+JzRU71GgiQEJOpwYdARfEIgNQPr03YK4TrY+YQwnEdes= 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-7d4c14f388eso2990577a34.2 for ; Fri, 13 Feb 2026 07:43:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770997428; x=1771602228; 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=E8+B2lwzzYwd6RbFOa1wQ5YLlpTGYmp+dXAlV80tsVE=; b=oBSJTZKO607FDZ72Ws6XFF+/OP1CfQuA9YSYJ29HNNRFNGCBXrzEoGiKJAx6DAXKSy 0kbR+/DBNnaTMHbTwqHypjjmkaAJeXeHWMxp1HUkjBM77bAXgV8FNjDPvSxKDCOtUhRc 9u6hrkrYdZ65wlsAJ/oDnCO+uZXqR5Q5GYrkKm8x7p3yOyeoswgtq8133IkDuYq+l0RC yfb7//mrWZc/+8JXnrueBpCmc4nW/goiKOVtIWdfuq0hT5g4Z/Sipz4s0eV5YyiLqlxr 2bitu9s9UJa6DaSm3cjUv9JSBjoUq+7wDfFe1vLw8fChoVizSpMpVamqR7jQxVteMRGF 2Liw== X-Gm-Message-State: AOJu0YwDyAkz/wpB/C3s8FEXKWLZx9EaDzTS4+zZF3PdIiTekSKPzTUs +p3lcWwVcQ30R7mOciIq7i3/aBSg/aXM+QfL8DhKUyAy8Aajyy7WuYc8/0R8lWu1ZUpvlDMiJ9m rY7w6sxVsFW1uD/TzekfG1q7JCjC0eqpT0fh0OeHk5umhZiQ2gl5pGaUn5Zg= 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:4dc2:b0:662:f91f:4a91 with SMTP id 006d021491bc7-67767295528mr980897eaf.24.1770997428581; Fri, 13 Feb 2026 07:43:48 -0800 (PST) Date: Fri, 13 Feb 2026 07:43:48 -0800 In-Reply-To: <697d115a.050a0220.1d61ec.0004.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <698f46b4.a70a0220.2c38d7.00c7.GAE@google.com> Subject: Forwarded: [PATCH] mm: thp: deny THP for files on anonymous inodes 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: thp: deny THP for files on anonymous inodes Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git= master file_thp_enabled() incorrectly allows THP for files on anonymous inodes (e.g. guest_memfd and secretmem). These files are created via alloc_file_pseudo(), which does not call get_write_access() and leaves inode->i_writecount at 0. Combined with S_ISREG(inode->i_mode) being true, they appear as read-only regular files when CONFIG_READ_ONLY_THP_FOR_FS is enabled, making them eligible for THP collapse. Anonymous inodes can never pass the inode_is_open_for_write() check since their i_writecount is never incremented through the normal VFS open path. The right thing to do is to exclude them from THP eligibility altogether, since CONFIG_READ_ONLY_THP_FOR_FS was designed for real filesystem files (e.g. shared libraries), not for pseudo-filesystem inodes. For guest_memfd, this allows khugepaged and MADV_COLLAPSE to create large folios in the page cache via the collapse path, but the guest_memfd fault handler does not support large folios. This triggers WARN_ON_ONCE(folio_test_large(folio)) in kvm_gmem_fault_user_mapping(). For secretmem, collapse_file() tries to copy page contents through the direct map, but secretmem pages are removed from the direct map. This can result in a kernel crash: BUG: unable to handle page fault for address: ffff88810284d000 RIP: 0010:memcpy_orig+0x16/0x130 Call Trace: collapse_file hpage_collapse_scan_file madvise_collapse Secretmem is not affected by the crash on upstream as the memory failure recovery handles the failed copy gracefully, but it still triggers confusing false memory failure reports: Memory failure: 0x106d96f: recovery action for clean unevictable LRU page: Recovered Check IS_ANON_FILE(inode) in file_thp_enabled() to deny THP for all anonymous inode files. Link: https://syzkaller.appspot.com/bug?extid=3D33a04338019ac7e43a44 Link: https://lore.kernel.org/linux-mm/CAEvNRgHegcz3ro35ixkDw39ES8=3DU6rs6S= 7iP0gkR9enr7HoGtA@mail.gmail.com Reported-by: syzbot+33a04338019ac7e43a44@syzkaller.appspotmail.com Fixes: 7fbb5e188248 ("mm: remove VM_EXEC requirement for THP eligibility") Cc: stable@vger.kernel.org Signed-off-by: Deepanshu Kartikey --- v2: - Use IS_ANON_FILE(inode) to deny THP for all anonymous inode files instead of checking for specific subsystems (David Hildenbrand) - Updated Fixes tag to 7fbb5e188248 which removed the VM_EXEC requirement that accidentally protected secretmem - Expanded commit message with implications for both guest_memfd and secretmem --- mm/huge_memory.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 40cf59301c21..d3beddd8cc30 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -94,6 +94,9 @@ static inline bool file_thp_enabled(struct vm_area_struct= *vma) =20 inode =3D file_inode(vma->vm_file); =20 + if (IS_ANON_FILE(inode)) + return false; + return !inode_is_open_for_write(inode) && S_ISREG(inode->i_mode); } =20 --=20 2.43.0