[PATCH] ext4: attach jinode before inline data conversion in setattr

From: Qing Zhang

Date: Mon Nov 16 2026 - 00:44:44 EST


Commit ed9356a30e59 ("ext4: convert inline data to extents when
truncate exceeds inline size") added inline data conversion to
ext4_setattr(). Pathname-based truncate bypasses ext4_file_open(),
so the inode may lack a jinode. In ordered mode, the conversion
can pass this NULL jinode to jbd2_journal_file_inode(), causing a
NULL pointer dereference.

Attach the jinode before ext4_convert_inline_data() and propagate
attachment errors. The attachment in ext4_truncate_up() occurs
after the conversion and is too late.

Fixes: ed9356a30e59 ("ext4: convert inline data to extents when truncate exceeds inline size")
Reported-by: Ahmed Khan <ahmadpsn95@xxxxxxxxx>
Link: https://lore.kernel.org/r/CAOaS1==g3mdoqmS2AjOC0_-woXJbA_X0LJQt7+M7d1=+gfyQqw@xxxxxxxxxxxxxx
Reported-by: syzbot+9c29b92a3b6500bb347d@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=9c29b92a3b6500bb347d
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Qing Zhang <diasyzhang@xxxxxxxxxxx>
---

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
fs/ext4/inode.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 10cd85d4c721..1e31933ae98c 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -7127,6 +7127,9 @@ int ext4_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
*/
if (ext4_has_inline_data(inode) &&
attr->ia_size > EXT4_I(inode)->i_inline_size) {
+ error = ext4_inode_attach_jinode(inode);
+ if (error)
+ goto err_out;
error = ext4_convert_inline_data(inode);
if (error)
goto err_out;
--
2.43.7