Skip to content

block: fix infinite loop in badblocks_clear() and badblocks_check()#771

Open
blktests-ci[bot] wants to merge 1 commit intolinus-master_basefrom
series/1085695=>linus-master
Open

block: fix infinite loop in badblocks_clear() and badblocks_check()#771
blktests-ci[bot] wants to merge 1 commit intolinus-master_basefrom
series/1085695=>linus-master

Conversation

@blktests-ci
Copy link
Copy Markdown

@blktests-ci blktests-ci Bot commented Apr 26, 2026

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

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 <[email protected]>
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Apr 26, 2026

Upstream branch: dd6c438
series: https://patchwork.kernel.org/project/linux-block/list/?series=1085695
version: 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant