mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thorsten Blum <blum@kernel.org>
To: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Juergen Gross <jgross@suse.com>,
	Sean Christopherson <seanjc@google.com>,
	Wangyang Guo <wangyang.guo@intel.com>,
	Krzysztof Piecuch <piecuch@protonmail.com>
Cc: Thorsten Blum <blum@kernel.org>, Ingo Molnar <mingo@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] x86/tsc: Fix early boot crash with bare tsc_early_khz parameter
Date: Tue, 10 Nov 2026 16:05:23 +0100	[thread overview]
Message-ID: <20261110150523.187164-3-blum@kernel.org> (raw)

When a bare tsc_early_khz parameter is specified on the kernel command
line without the '=' separator, early parameter parsing passes NULL to
tsc_early_khz_setup(), which dereferences it in kstrtouint() and can
crash the system during early boot.

Reject a NULL argument in tsc_early_khz_setup() by returning -EINVAL so
early parameter parsing reports the malformed option instead.

Fixes: bd35c77e32e4 ("x86/tsc: Add tsc_early_khz command line parameter")
Cc: stable@vger.kernel.org
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
 arch/x86/kernel/tsc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 723347e2cf7f..82ff4b7490a0 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -70,6 +70,9 @@ static DEFINE_PER_CPU_ALIGNED(struct cyc2ns, cyc2ns);
 
 static int __init tsc_early_khz_setup(char *buf)
 {
+	if (!buf)
+		return -EINVAL;
+
 	return kstrtouint(buf, 0, &tsc_early_khz);
 }
 early_param("tsc_early_khz", tsc_early_khz_setup);

                 reply	other threads:[~2026-11-10 15:06 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=20261110150523.187164-3-blum@kernel.org \
    --to=blum@kernel.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=piecuch@protonmail.com \
    --cc=seanjc@google.com \
    --cc=tglx@kernel.org \
    --cc=wangyang.guo@intel.com \
    --cc=x86@kernel.org \
    /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®