mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alex Kazinsky <a.kazinsky@ideco.ru>
To: Daniel Thompson <danielt@kernel.org>
Cc: Alex Kazinsky <a.kazinsky@ideco.ru>,
	Douglas Anderson <dianders@chromium.org>,
	Naveen Kumar Chaudhary <naveen.osdev@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Tim Bird <tim.bird@sony.com>, Martin Hicks <mort@sgi.com>,
	kgdb-bugreport@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org
Subject: [PATCH] kdb: Reject zero BYTESPERWORD before calculating the repeat count
Date: Fri, 13 Nov 2026 15:11:51 +0400	[thread overview]
Message-ID: <20261113111152.4190309-1-a.kazinsky@ideco.ru> (raw)

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



                 reply	other threads:[~2026-11-13 11:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261113111152.4190309-1-a.kazinsky@ideco.ru \
    --to=a.kazinsky@ideco.ru \
    --cc=danielt@kernel.org \
    --cc=dianders@chromium.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=mort@sgi.com \
    --cc=naveen.osdev@gmail.com \
    --cc=tim.bird@sony.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®