mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] kdb: Reject zero BYTESPERWORD before calculating the repeat count
@ 2026-11-13 11:11 Alex Kazinsky
  0 siblings, 0 replies; only message in thread
From: Alex Kazinsky @ 2026-11-13 11:11 UTC (permalink / raw)
  To: Daniel Thompson
  Cc: Alex Kazinsky, Douglas Anderson, Naveen Kumar Chaudhary,
	Greg Kroah-Hartman, Tim Bird, Martin Hicks, kgdb-bugreport,
	linux-kernel, lvc-project

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 <a.kazinsky@ideco.ru>
---
 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;
+
 	/* Assume 'md <addr>' and start with environment values */
 	repeat = mdcount * 16 / bytesperword;
 
-- 
2.56.0



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-13 11:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-13 11:11 [PATCH] kdb: Reject zero BYTESPERWORD before calculating the repeat count Alex Kazinsky

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

all inboxes | Powered by JetHome®