Re: [PATCH v7 0/2] badblocks: fix rounding bug and validate input range
"Coly Li" <[email protected]> Tue, 4 Aug 2026 13:49:46 +0800
| Newsgroups | org.kernel.vger.linux-block,org.kernel.vger.stable |
|---|---|
| Message-ID | <[email protected]> |
Hi Ramesh, I will review the 2nd patch soon. Thanks. Coly Li > 2026=E5=B9=B48=E6=9C=884=E6=97=A5 13:41=EF=BC=8CRamesh Adhikari <adhikari= [email protected]> =E5=86=99=E9=81=93=EF=BC=9A >=20 > Hi Jens, Coly, >=20 > Gentle ping on this series. Patch 1/2 has Coly's Reviewed-by, and > both patches address: >=20 > - an RCU stall / kernel hang reachable via the nvdimm ioctl path > (badblocks_check() looping with a non-advancing cursor) > - a 32-bit (arm/i386) build break from 64-bit division helpers, > reported by the kernel test robot >=20 > Both are tagged Fixes: and Cc: stable, so happy to resend or rebase > if anything's needed on my end just let me know. >=20 > Thanks, > Ramesh >=20 > On Tue, Jul 21, 2026 at 10:11=E2=80=AFPM Ramesh Adhikari > <[email protected]> wrote: >>=20 >> Two related fixes to block/badblocks.c: >>=20 >> 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. >>=20 >> 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 =E2=80=94 see the changelog in that patch for de= tails. >> 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). >>=20 >> Ramesh Adhikari (2): >> badblocks: fix in-place round_up/round_down usage bug >> badblocks: validate sector range and shift before rounding >>=20 >> block/badblocks.c | 40 ++++++++++++++++++++++++++++++++------- >> include/linux/badblocks.h | 6 +++++- >> 2 files changed, 38 insertions(+), 8 deletions(-) >>=20 >> -- >> 2.43.0 >>