Hi, On Fri, Nov 13, 2026 at 3:12 AM Alex Kazinsky <[email protected]> wrote: > > Setting BYTESPERWORD to zero in the kdb environment causes kdb_md() > to divide by zero when calculating the initial repeat count. The > existing width validation happens after this division. > > Reject a zero width with KDB_BADWIDTH before calculating the repeat > count. > > Found by Linux Verification Center (linuxtesting.org) with SVACE static > analysis tool. > > Fixes: 5d5314d6795f ("kdb: core for kgdb back end (1 of 2)") > Signed-off-by: Alex Kazinsky <[email protected]> > --- > kernel/debug/kdb/kdb_main.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c > index 40c332d2179d..c3cbeb25f6fb 100644 > --- a/kernel/debug/kdb/kdb_main.c > +++ b/kernel/debug/kdb/kdb_main.c > @@ -1527,6 +1527,9 @@ static int kdb_md(int argc, const char **argv) > kdbgetintenv("RADIX", &radix); > kdbgetintenv("BYTESPERWORD", &bytesperword); > > + if (!bytesperword) > + return KDB_BADWIDTH; > +
Could you check `bytesperword <= 0` rather than `!bytesperword` (and update the commit message accordingly)? AI-generated details, in case they are interesting to you: kdbgetintenv() parses an `unsigned long` with kstrtoul() and casts it to `int`, so on 64-bit systems `set BYTESPERWORD=0xffffffff` gives `bytesperword = -1`. Combined with `set MDCOUNT=0x8000000` (so `mdcount * 16` wraps to `INT_MIN`, `-2147483648`), `mdcount * 16 / bytesperword` computes `INT_MIN / -1`. Because `+2147483648` overflows a 32-bit signed `int` (`INT_MAX` is `2147483647`), x86's signed `idiv` instruction raises the same `#DE` divide error exception as dividing by zero. -Doug _______________________________________________ Kgdb-bugreport mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport
