]> git.karo-electronics.de Git - karo-tx-linux.git/commit
xfs: fix possible overflow in xfs_ioc_trim()
authorLukas Czerner <lczerner@redhat.com>
Wed, 21 Sep 2011 09:42:30 +0000 (09:42 +0000)
committerAlex Elder <aelder@sgi.com>
Fri, 23 Sep 2011 17:01:42 +0000 (12:01 -0500)
commite49f565973deb3408c0e1dd83d1f8dac5bcaa374
treecb6e5eee6c848e69e58343052240c11c840c5686
parentef49624be283c67c40dcdac94ca125e1ddda8ff6
xfs: fix possible overflow in xfs_ioc_trim()

In xfs_ioc_trim it is possible that computing the last allocation group
to discard might overflow for big start & len values, because the result
might be bigger then xfs_agnumber_t which is 32 bit long. Fix this by not
allowing the start and end block of the range to be beyond the end of the
file system.

Note that if the start is beyond the end of the file system we have to
return -EINVAL, but in the "end" case we have to truncate it to the fs
size.

Also introduce "end" variable, rather than using start+len which which
might be more confusing to get right as this bug shows.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Elder <aelder@sgi.com>
fs/xfs/xfs_discard.c