Skip to content

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

Open
blktests-ci[bot] wants to merge 1 commit into
linus-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 into
linus-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
@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
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 1f0d33a to b1870f6 Compare May 10, 2026 15:59
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented May 10, 2026

Upstream branch: aa54b1d
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 e16a4aa to 8e11fa9 Compare May 10, 2026 16:24
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from b1870f6 to ca57796 Compare May 15, 2026 07:55
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented May 15, 2026

Upstream branch: 70eda68
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 8e11fa9 to 20e0908 Compare May 15, 2026 08:33
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from ca57796 to c1feb59 Compare May 21, 2026 02:54
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented May 21, 2026

Upstream branch: 8bc67e4
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 20e0908 to 4016081 Compare May 21, 2026 03:36
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from c1feb59 to ea833a1 Compare May 22, 2026 01:53
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented May 22, 2026

Upstream branch: 6779b50
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 4016081 to 7741e24 Compare May 22, 2026 02:33
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from ea833a1 to 7af85d1 Compare May 23, 2026 06:11
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented May 23, 2026

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

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 blktests-ci Bot force-pushed the series/1086213=>linus-master branch from 7741e24 to cb2ab88 Compare May 23, 2026 07:29
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