block: fix infinite loop in badblocks_clear() and badblocks_check()#771
block: fix infinite loop in badblocks_clear() and badblocks_check()#771blktests-ci[bot] wants to merge 1 commit intolinus-master_basefrom
Conversation
|
Upstream branch: dd6c438 |
857ada9 to
482ce5b
Compare
|
Upstream branch: dca922e |
c7e9309 to
d4bb75a
Compare
482ce5b to
5a9f7c7
Compare
|
Upstream branch: e75a43c |
d4bb75a to
01614ce
Compare
5a9f7c7 to
25a041f
Compare
|
Upstream branch: 66edb90 |
01614ce to
8c9505c
Compare
25a041f to
6f75bd1
Compare
|
Upstream branch: 6d35786 |
8c9505c to
deb68de
Compare
6f75bd1 to
1f0d33a
Compare
|
Upstream branch: 6d35786 |
deb68de to
f4fe77d
Compare
1f0d33a to
b1870f6
Compare
An infinite loop can occur in both _badblocks_clear() and _badblocks_check()
when BB_OFFSET() equals the start position, resulting in len = 0. This causes
the update_sectors loop to spin forever without making progress:
s += 0; // no advancement
sectors -= 0; // stays positive
goto re_clear; // infinite loop
The bug exists in three code paths:
1. _badblocks_clear() at line 1100 (start before all badblocks)
2. _badblocks_clear() at line 1153 (behind overlap check)
3. _badblocks_check() at line 1240 (behind overlap check)
Add checks in all three locations to ensure len is non-zero before
entering the loop.
Signed-off-by: Ramesh Adhikari <adhikari.resume@gmail.com>
|
Upstream branch: aa54b1d |
f4fe77d to
02e7612
Compare
Pull request for series with
subject: block: fix infinite loop in badblocks_clear() and badblocks_check()
version: 3
url: https://patchwork.kernel.org/project/linux-block/list/?series=1085695