diff options
| author | Kirtikumar Anandrao Ramchandani <kirtiar15502@gmail.com> | 2026-11-05 20:48:07 +0100 |
|---|---|---|
| committer | Mikulas Patocka <mpatocka@redhat.com> | 2026-11-05 21:04:55 +0100 |
| commit | df8daa4d916c88ef7888c738e0eb3b6f11714a6f (patch) | |
| tree | e269334063300787cc0e089f0d2b50a0ddcbb9df /rust/kernel/alloc/kvec/errors.rs | |
| parent | ae310e4ad872a42f4707a596e66417f2aaa52826 (diff) | |
dm cache: validate the discard block size before narrowing
The discard block size doubles until the origin fits within the discard
bitset limit. too_many_discard_blocks() passes this sector_t size to
sector_div(), whose divisor is only 32 bits. Once the size exceeds that
range, the division uses a truncated divisor, which can become zero.
Use a 64-bit divisor when checking the block count. The selected size is
stored in a u32, so reject sizes that cannot be represented before the
assignment and before calculating the bitset size. This prevents a
truncated zero size from reaching dm_sector_div_up().
An earlier proposal checks whether the mapped length exceeds the origin
device. This fix also covers an origin device whose valid size requires a
discard block size beyond the field's range.
Reported-by: syzbot+c8564fc0a96e3ecbe4d4@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=c8564fc0a96e3ecbe4d4
Cc: stable@vger.kernel.org
Fixes: 08b184514f65 ("dm cache: revert 'prevent corruption caused by discard_block_size > cache_block_size'")
Signed-off-by: Kirtikumar Anandrao Ramchandani <kirtiar15502@gmail.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Diffstat (limited to 'rust/kernel/alloc/kvec/errors.rs')
0 files changed, 0 insertions, 0 deletions
