mirror of
https://github.com/torvalds/linux.git
synced 2026-12-02 19:42:26 +00:00
ext4: verify fast symlink length
Verify fast symlink length stored in inode->i_size matches the string
stored in the inode to avoid surprises from corrupted filesystems.
Reported-by: [email protected]
Tested-by: [email protected]
Fixes: bae80473f7 ("ext4: use inode_set_cached_link()")
Suggested-by: Darrick J. Wong <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
Reviewed-by: Baokun Li <[email protected]>
Reviewed-by: Darrick J. Wong <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Theodore Ts'o <[email protected]>
This commit is contained in:
+10
-2
@@ -5029,8 +5029,16 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
|
||||
inode->i_op = &ext4_encrypted_symlink_inode_operations;
|
||||
} else if (ext4_inode_is_fast_symlink(inode)) {
|
||||
inode->i_op = &ext4_fast_symlink_inode_operations;
|
||||
nd_terminate_link(ei->i_data, inode->i_size,
|
||||
sizeof(ei->i_data) - 1);
|
||||
if (inode->i_size == 0 ||
|
||||
inode->i_size >= sizeof(ei->i_data) ||
|
||||
strnlen((char *)ei->i_data, inode->i_size + 1) !=
|
||||
inode->i_size) {
|
||||
ext4_error_inode(inode, function, line, 0,
|
||||
"invalid fast symlink length %llu",
|
||||
(unsigned long long)inode->i_size);
|
||||
ret = -EFSCORRUPTED;
|
||||
goto bad_inode;
|
||||
}
|
||||
inode_set_cached_link(inode, (char *)ei->i_data,
|
||||
inode->i_size);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user