]> git.baikalelectronics.ru Git - uboot.git/commit
fs: btrfs: volumes: prevent overflow for multiplying
authorQu Wenruo <wqu@suse.com>
Sat, 31 Oct 2020 01:07:50 +0000 (09:07 +0800)
committerTom Rini <trini@konsulko.com>
Wed, 20 Jan 2021 19:01:08 +0000 (14:01 -0500)
commited72e492519143f6a4f5b8758e1fe9deb12f9788
treeed99eb7a5d1b867efcc8b216c4fb0b545281c1a4
parent5038c1ede6f73118865074da6aa455033f398e52
fs: btrfs: volumes: prevent overflow for multiplying

In __btrfs_map_block() we do a int * int and assign it to u64.
This is not safe as the result (int * int) is still evaluated as (int)
thus it can overflow.

Convert one of the multiplier to u64 to prevent such problem.

In real world, this should not cause problem as we have device number
limit thus it won't go beyond 4G for a single stripe.

But it's harder to teach coverity about all these hidden limits, so just
fix the possible overflow.

Reported-by: Coverity CID 312957
Reported-by: Coverity CID 312948
Signed-off-by: Qu Wenruo <wqu@suse.com>
fs/btrfs/volumes.c