Skip to content

badblocks: fix infinite loop due to incorrect rounding and overflow#774

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

badblocks: fix infinite loop due to incorrect rounding and overflow#774
blktests-ci[bot] wants to merge 1 commit intolinus-master_basefrom
series/1086213=>linus-master

Conversation

@blktests-ci
Copy link
Copy Markdown

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

Pull request for series with
subject: badblocks: fix infinite loop due to incorrect rounding and overflow
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=1086213

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Apr 27, 2026

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

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Apr 29, 2026

Upstream branch: dca922e
series: https://patchwork.kernel.org/project/linux-block/list/?series=1086216
version: 4

@blktests-ci blktests-ci Bot force-pushed the series/1086213=>linus-master branch from 7ac44d2 to 6a567cb Compare April 29, 2026 02:22
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 482ce5b to 5a9f7c7 Compare April 30, 2026 07:29
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Apr 30, 2026

Upstream branch: e75a43c
series: https://patchwork.kernel.org/project/linux-block/list/?series=1086216
version: 4

@blktests-ci blktests-ci Bot force-pushed the series/1086213=>linus-master branch from 6a567cb to 5b169a8 Compare April 30, 2026 07:30
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 5a9f7c7 to 25a041f Compare May 3, 2026 02:07
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented May 3, 2026

Upstream branch: 66edb90
series: https://patchwork.kernel.org/project/linux-block/list/?series=1086216
version: 4

@blktests-ci blktests-ci Bot force-pushed the series/1086213=>linus-master branch from 5b169a8 to ca2611b Compare May 3, 2026 02:09
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 25a041f to 6f75bd1 Compare May 4, 2026 10:57
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented May 4, 2026

Upstream branch: 6d35786
series: https://patchwork.kernel.org/project/linux-block/list/?series=1086216
version: 4

@blktests-ci blktests-ci Bot force-pushed the series/1086213=>linus-master branch from ca2611b to 8ad5528 Compare May 4, 2026 10:59
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 6f75bd1 to 1f0d33a Compare May 5, 2026 15:39
The roundup() and rounddown() macros return the rounded value but
do not modify the input in place. In _badblocks_set(), _badblocks_clear(),
and badblocks_check(), the return values were being discarded, causing
s and target/next to remain unrounded. This resulted in sectors
being calculated from unrounded values, which could lead to sectors
being way too large (or zero), causing infinite loops in the
re_insert/re_clear/re_check loops.

Additionally, add integer overflow checks (s > ULLONG_MAX - sectors)
before the s + sectors calculation in all three functions to prevent
overflow-related issues. Also add early return when sectors becomes
zero after rounding in badblocks_check().

Root cause: When s and sectors have specific values (e.g., from
syzkaller fuzzing via nvdimm ioctl), the unrounded values cause
sectors to be incorrectly calculated. In _badblocks_clear(), this
could result in needing 2^46 iterations to process 2^55 sectors,
triggering RCU stall warnings and effectively hanging the kernel.

Fix by properly capturing the return values from roundup() and
rounddown(), adding overflow checks before sector arithmetic, and
handling the zero-sectors case in badblocks_check().

Signed-off-by: Ramesh Adhikari <adhikari.resume@gmail.com>
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented May 5, 2026

Upstream branch: 6d35786
series: https://patchwork.kernel.org/project/linux-block/list/?series=1086216
version: 4

@blktests-ci blktests-ci Bot force-pushed the series/1086213=>linus-master branch from 8ad5528 to e16a4aa Compare May 5, 2026 15:41
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