Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1360398
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] x86/tsc: Prevent NULL pointer deref in calibrate_delay_is_known() |
| Date | 2016-03-18 08:50 +0100 |
| Message-ID | <rdXku-2yP-11@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
Subject: x86/tsc: Prevent NULL pointer deref in calibrate_delay_is_known()
From: Thomas Gleixner <tglx@linutronix.de>
Date: Fri, 18 Mar 2016 08:35:29 +0100
The topology_core_cpumask is used to find a neighbour cpu in
calibrate_delay_is_known(). It might not be allocated at the first invocation
of that function on the boot cpu, when CONFIG_CPUMASK_OFFSTACK is set.
The mask is allocated later in native_smp_prepare_cpus. As a consequence the
underlying find_next_bit() call dereferences a NULL pointer.
Add a proper check to prevent this.
Reported-by: Richard W.M. Jones <rjones@redhat.com>
Fixes: c25323c07345 "x86/tsc: Use topology functions"
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Josh Boyer <jwboyer@fedoraproject.org>
---
arch/x86/kernel/tsc.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -1306,11 +1306,15 @@ void __init tsc_init(void)
unsigned long calibrate_delay_is_known(void)
{
int sibling, cpu = smp_processor_id();
+ struct cpumask *mask = topology_core_cpumask(cpu);
if (!tsc_disabled && !cpu_has(&cpu_data(cpu), X86_FEATURE_CONSTANT_TSC))
return 0;
- sibling = cpumask_any_but(topology_core_cpumask(cpu), cpu);
+ if (!mask)
+ return 0;
+
+ sibling = cpumask_any_but(mask, cpu);
if (sibling < nr_cpu_ids)
return cpu_data(sibling).loops_per_jiffy;
return 0;
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH] x86/tsc: Prevent NULL pointer deref in calibrate_delay_is_known() Thomas Gleixner <tglx@linutronix.de> - 2016-03-18 08:50 +0100 Re: [PATCH] x86/tsc: Prevent NULL pointer deref in calibrate_delay_is_known() "Richard W.M. Jones" <rjones@redhat.com> - 2016-03-18 11:20 +0100 [tip:x86/urgent] x86/tsc: Prevent NULL pointer deref in calibrate_delay_is_known() tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2016-03-18 15:00 +0100
csiph-web