* [PATCH] ext3: Avoid underflow of in ext3_trim_fs()
@ 2012-10-11 10:28 Lukas Czerner
2012-10-11 11:04 ` Jan Kara
0 siblings, 1 reply; 2+ messages in thread
From: Lukas Czerner @ 2012-10-11 10:28 UTC (permalink / raw)
To: linux-ext4; +Cc: jack, Lukas Czerner
Currently if len argument in ext3_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>
---
fs/ext3/balloc.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index 7320a66..22548f5 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -2101,8 +2101,9 @@ int ext3_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 > EXT3_BLOCKS_PER_GROUP(sb)) ||
- unlikely(start >= max_blks))
+ if (minlen > EXT3_BLOCKS_PER_GROUP(sb) ||
+ start >= max_blks ||
+ range->len < sb->s_blocksize)
return -EINVAL;
if (end >= max_blks)
end = max_blks - 1;
--
1.7.7.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ext3: Avoid underflow of in ext3_trim_fs()
2012-10-11 10:28 [PATCH] ext3: Avoid underflow of in ext3_trim_fs() Lukas Czerner
@ 2012-10-11 11:04 ` Jan Kara
0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2012-10-11 11:04 UTC (permalink / raw)
To: Lukas Czerner; +Cc: linux-ext4, jack
On Thu 11-10-12 12:28:38, Lukas Czerner wrote:
> Currently if len argument in ext3_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().
Thanks. I've added the patch to my tree.
Honza
>
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> ---
> fs/ext3/balloc.c | 5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
> index 7320a66..22548f5 100644
> --- a/fs/ext3/balloc.c
> +++ b/fs/ext3/balloc.c
> @@ -2101,8 +2101,9 @@ int ext3_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 > EXT3_BLOCKS_PER_GROUP(sb)) ||
> - unlikely(start >= max_blks))
> + if (minlen > EXT3_BLOCKS_PER_GROUP(sb) ||
> + start >= max_blks ||
> + range->len < sb->s_blocksize)
> return -EINVAL;
> if (end >= max_blks)
> end = max_blks - 1;
> --
> 1.7.7.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-10-11 11:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-11 10:28 [PATCH] ext3: Avoid underflow of in ext3_trim_fs() Lukas Czerner
2012-10-11 11:04 ` Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).