Forwarded: [PATCH] ext4: make ext4_write_inline_data_end() handle file conversion gracefully

From: syzbot

Date: Fri Jul 17 2026 - 06:54:43 EST


For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx, syzkaller-bugs@xxxxxxxxxxxxxxxx.

***

Subject: [PATCH] ext4: make ext4_write_inline_data_end() handle file conversion gracefully
Author: kartikey406@xxxxxxxxx

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci


Replace BUG_ON(!ext4_has_inline_data(inode)) with a defensive check in
ext4_write_inline_data_end(). A file can be converted from inline to block
storage by concurrent paths while a write completion is in flight.

When this race occurs, the write completion handler should gracefully fall
back to block_write_end() instead of crashing. The data in the folio can
still be written to block storage via the fallback path.

This handles all inline-to-block conversion races regardless of which lock
protects the conversion (i_data_sem, xattr_sem, etc.).

Reported-by: syzbot+293a57918b36cfae3d48@xxxxxxxxxxxxxxxxxxxxxxxxx
Link: https://syzkaller.appspot.com/bug?extid=293a57918b36cfae3d48
Signed-off-by: Deepanshu Kartikey <kartikey406@xxxxxxxxx>
---
fs/ext4/inline.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 8045e4ff270c..04b9cd01fd7b 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -812,7 +812,11 @@ int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
goto out;
}
ext4_write_lock_xattr(inode, &no_expand);
- BUG_ON(!ext4_has_inline_data(inode));
+ /* File may have been converted to block storage by concurrent path */
+ if (!ext4_has_inline_data(inode)) {
+ ext4_write_unlock_xattr(inode, &no_expand);
+ return block_write_end(pos, len, copied, folio);
+ }

/*
* ei->i_inline_off may have changed since
--
2.43.0