Re: [syzbot] [hardening?] [mm?] BUG: bad usercopy in vfs_readlink

From: Mateusz Guzik
Date: Wed Feb 05 2025 - 07:26:38 EST


On Tue, Feb 04, 2025 at 01:46:28AM -0800, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 69b8923f5003 Merge tag 'for-linus-6.14-ofs4' of git://git...
> git tree: upstream
> console+strace: https://syzkaller.appspot.com/x/log.txt?x=1258aeb0580000
> kernel config: https://syzkaller.appspot.com/x/.config?x=57ab43c279fa614d
> dashboard link: https://syzkaller.appspot.com/bug?extid=48a99e426f29859818c0
> compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15825724580000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1658aeb0580000
>

#syz test upstream master

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 7c54ae5fcbd4..30cff983e601 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -5010,7 +5010,7 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
nd_terminate_link(ei->i_data, inode->i_size,
sizeof(ei->i_data) - 1);
inode_set_cached_link(inode, (char *)ei->i_data,
- inode->i_size);
+ strlen((char *)ei->i_data));
} else {
inode->i_op = &ext4_symlink_inode_operations;
}