Skip to contentSkip to conversation

xfs: don't use __GFP_NOFAIL in xfs_init_fs_context

PATCH Superseded Christoph Hellwig 2 participants 3 messages Sep 29, 2025 – Oct 3, 2025 XFS filesystem

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: don't use __GFP_NOFAIL in xfs_init_fs_context

xfs_init_fs_context is early in the mount process, and if we really are out of memory there we'd better give up ASAP.

---
 fs/xfs/xfs_super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_super.c +1 -1
index bb0a82635a77..a8fe8b042331 100644
@@ -2275,7 +2275,7 @@ xfs_init_fs_context(
 	struct xfs_mount	*mp;
 	int			i;
 
-	mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL | __GFP_NOFAIL);
+	mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL);
 	if (!mp)
 		return -ENOMEM;
 
Signature · 1 line
2.47.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Christoph Hellwig

xfs_init_fs_context is early in the mount process, and if we really are out of memory there we'd better give up ASAP.

Is this the fix for that recent sysbot report? If so, maybe you ought to link to the syzbot thread:

In any case the logic is sound and it's quite easy to bloat xfs_mount to be larger than 4k so the kzalloc is simply fallible:

--D

Quoted 21 lines
---
 fs/xfs/xfs_super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_super.c +1 -1
index bb0a82635a77..a8fe8b042331 100644
@@ -2275,7 +2275,7 @@ xfs_init_fs_context(
 	struct xfs_mount	*mp;
 	int			i;
 
-	mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL | __GFP_NOFAIL);
+	mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL);
 	if (!mp)
 		return -ENOMEM;
 
Signature · 1 line
2.47.3
#2 lore raw
Quoted 9 lines · Darrick J. Wong
Quoted 4 lines · Christoph Hellwig

xfs_init_fs_context is early in the mount process, and if we really are out of memory there we'd better give up ASAP.

Is this the fix for that recent sysbot report? If so, maybe you ought to link to the syzbot thread:

At least if my theory there was correct the bug is in the mm code and it doesn't actually fix the bug, it just removes one way to trigger it.

Quoted 2 lines

In any case the logic is sound and it's quite easy to bloat xfs_mount to be larger than 4k so the kzalloc is simply fallible:

If OTOH your theory here is correct, it does fix the bug. Let me check their .config to see which theory is correct.