linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: thp: Deny THP for guest_memfd and secretmem in file_thp_enabled()
@ 2026-02-09  3:35 Deepanshu Kartikey
  2026-02-09 10:24 ` David Hildenbrand (Arm)
                   ` (2 more replies)
  0 siblings, 3 replies; 29+ messages in thread
From: Deepanshu Kartikey @ 2026-02-09  3:35 UTC (permalink / raw)
  To: akpm, david, lorenzo.stoakes, baolin.wang, Liam.Howlett, npache,
	ryan.roberts, dev.jain, baohua, ackerleytng, seanjc, pbonzini,
	michael.roth, vannapurve
  Cc: ziy, linux-mm, linux-kernel, Deepanshu Kartikey,
	syzbot+33a04338019ac7e43a44, Deepanshu Kartikey

file_thp_enabled() incorrectly returns true for guest_memfd and secretmem
inodes because they appear as regular read-only files when
CONFIG_READ_ONLY_THP_FOR_FS is enabled. This allows khugepaged and
MADV_COLLAPSE to create large folios in the page cache, but their fault
handlers do not support large folios.

Add explicit checks for GUEST_MEMFD_MAGIC and SECRETMEM_MAGIC to reject
these filesystems early in file_thp_enabled().

Reported-by: syzbot+33a04338019ac7e43a44@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=33a04338019ac7e43a44
Tested-by: syzbot+33a04338019ac7e43a44@syzkaller.appspotmail.com
Signed-off-by: Deepanshu Kartikey <Kartikey406@gmail.com>
---
 mm/huge_memory.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 40cf59301c21..4f57c78b57dd 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -93,6 +93,9 @@ static inline bool file_thp_enabled(struct vm_area_struct *vma)
 		return false;
 
 	inode = file_inode(vma->vm_file);
+	if (inode->i_sb->s_magic == GUEST_MEMFD_MAGIC ||
+	    inode->i_sb->s_magic == SECRETMEM_MAGIC)
+		return false;
 
 	return !inode_is_open_for_write(inode) && S_ISREG(inode->i_mode);
 }
-- 
2.43.0



^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2026-02-21  4:37 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-09  3:35 [PATCH] mm: thp: Deny THP for guest_memfd and secretmem in file_thp_enabled() Deepanshu Kartikey
2026-02-09 10:24 ` David Hildenbrand (Arm)
2026-02-09 10:41   ` David Hildenbrand (Arm)
2026-02-09 13:06     ` Deepanshu Kartikey
2026-02-09 18:22       ` Ackerley Tng
2026-02-09 19:45         ` David Hildenbrand (Arm)
2026-02-09 20:13           ` David Hildenbrand (Arm)
2026-02-09 21:31             ` Ackerley Tng
2026-02-10  9:33               ` David Hildenbrand (Arm)
2026-02-10 23:00                 ` Ackerley Tng
2026-02-11  0:58                   ` Ackerley Tng
2026-02-11  2:01                     ` Deepanshu Kartikey
2026-02-11  9:29                     ` David Hildenbrand (Arm)
2026-02-11 16:16                       ` Ackerley Tng
2026-02-11 16:35                         ` David Hildenbrand (Arm)
2026-02-11 16:44                           ` David Hildenbrand (Arm)
2026-02-11  1:59                   ` Deepanshu Kartikey
2026-02-11  9:28                   ` David Hildenbrand (Arm)
2026-02-11 14:50                     ` Deepanshu Kartikey
2026-02-11 15:38                     ` Ackerley Tng
2026-02-11 16:45                       ` David Hildenbrand (Arm)
2026-02-12 22:19                         ` Ackerley Tng
2026-02-13  5:02                           ` Deepanshu Kartikey
2026-02-13  9:06                             ` David Hildenbrand (Arm)
2026-02-21  4:37                               ` Deepanshu Kartikey
2026-02-10  1:51             ` Deepanshu Kartikey
2026-02-10  9:33               ` David Hildenbrand (Arm)
2026-02-09 23:37 ` kernel test robot
2026-02-10 17:51 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox