mirror of
https://github.com/torvalds/linux.git
synced 2026-06-09 23:23:53 +02:00
ext4: Avoid underflow in ext4_trim_fs()
commit 5de35e8d5c upstream.
Currently if len argument in ext4_trim_fs() is smaller than one block,
the 'end' variable underflow. Avoid that by returning EINVAL if len is
smaller than file system block.
Also remove useless unlikely().
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
4319fd0000
commit
2807664df5
|
|
@ -4984,8 +4984,9 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
|
|||
end = start + (range->len >> sb->s_blocksize_bits) - 1;
|
||||
minlen = range->minlen >> sb->s_blocksize_bits;
|
||||
|
||||
if (unlikely(minlen > EXT4_CLUSTERS_PER_GROUP(sb)) ||
|
||||
unlikely(start >= max_blks))
|
||||
if (minlen > EXT4_CLUSTERS_PER_GROUP(sb) ||
|
||||
start >= max_blks ||
|
||||
range->len < sb->s_blocksize)
|
||||
return -EINVAL;
|
||||
if (end >= max_blks)
|
||||
end = max_blks - 1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user