badblocks: fix rounding bug and validate input range
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v7 Latest posting 2/22 patches 0 repliesNew
- v7 posting 1/22 patches 4 repliesSuperseded
- v62 patches 2 repliesSuperseded
Patches in v7 posting 2/2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | badblocks: fix in-place round_up/round_down usage bugblock/ | +6 | 0 replies | |
| 2/2 | badblocks: validate sector range and shift before roundingblock/ include/ | +38 | 0 replies |
Reviews trailers per patch
All 2 patches have a Reviewed-by or Acked-by.
| Patch | Coly Li |
|---|---|
| 1/2 | R-b |
| 2/2 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v7 0/2] badblocks: fix rounding bug and validate input range
Two related fixes to block/badblocks.c:
Patch 1/2 fixes the actual reported bug: round_up()/round_down() don't modify their argument in place, they return the rounded value, and the callers in _badblocks_set()/_badblocks_clear()/badblocks_check() were discarding that return value. Depending on caller alignment this could leave sectors unrounded or, in the reported case, stall the CPU with a non-advancing cursor when reached via the nvdimm ioctl path. It also fixes a 32-bit build breakage reported by kernel test robot, since the old rounddown()/roundup() macros pull in 64-bit division helpers not linked on 32-bit builds. Unchanged since v6.
Patch 2/2 hardens the same three functions against the input-range and shift edge cases the round_up/round_down fix exposed: s + sectors overflow, and rounding itself wrapping past ULLONG_MAX. Revised in v7 per Coly's review of v6 -- see the changelog in that patch for details. The remaining open item, bounding bb->shift where it's populated from the on-disk MD superblock in drivers/md/md.c, is being sent separately since it's a different file and a different root cause (missing input validation, not a rounding bug).
Both patches carry Coly Li's Reviewed-by.
Ramesh Adhikari (2):
badblocks: fix in-place round_up/round_down usage bug
badblocks: validate sector range and shift before rounding
block/badblocks.c | 52 ++++++++++++++++++++++++++++++++++++++++------- include/linux/badblocks.h | 6 +++++- 2 files changed, 44 insertions(+), 14 deletions(-)
--
2.43.0