Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH v7 0/2] badblocks: fix rounding bug and validate input range
@ 2026-09-02 16:02 Ramesh Adhikari
  2026-09-02 16:02 ` [PATCH v7 2/2] badblocks: validate sector range and shift before rounding Ramesh Adhikari
  0 siblings, 1 reply; 13+ messages in thread
From: Ramesh Adhikari @ 2026-09-02 16:02 UTC (permalink / raw)
  To: axboe; +Cc: colyli, gregkh, linux-block, stable, Ramesh Adhikari

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-09-02 16:02 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <ak9CC591ivuQ4BP1@studio.local>
2026-07-09 13:19 ` [PATCH v6 0/2] badblocks: fix infinite loop and validate sector range/shift Ramesh Adhikari
2026-07-09 13:19   ` [PATCH v6 1/2] badblocks: fix in-place round_up/round_down usage bug Ramesh Adhikari
2026-07-09 15:16     ` Coly Li
2026-07-09 13:19   ` [PATCH v6 2/2] badblocks: validate sector range and shift before rounding Ramesh Adhikari
2026-07-20  7:40     ` Coly Li
2026-07-21 16:40     ` [PATCH v7 0/2] badblocks: fix rounding bug and validate input range Ramesh Adhikari
2026-07-21 16:40       ` [PATCH v7 1/2] badblocks: fix in-place round_up/round_down usage bug Ramesh Adhikari
2026-07-21 16:40       ` [PATCH v7 2/2] badblocks: validate sector range and shift before rounding Ramesh Adhikari
2026-08-06  7:22         ` Coly Li
2026-09-02 15:17           ` Coly Li
2026-08-04  5:41       ` [PATCH v7 0/2] badblocks: fix rounding bug and validate input range Ramesh Adhikari
2026-08-04  5:49         ` Coly Li
2026-09-02 16:02 Ramesh Adhikari
2026-09-02 16:02 ` [PATCH v7 2/2] badblocks: validate sector range and shift before rounding Ramesh Adhikari

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox