linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 0/2] smp/hotplug: Fix last minute wreckage
@ 2016-12-26 21:58 Thomas Gleixner
  2016-12-26 21:58 ` [patch 1/2] smp/hotplug: Undo tglxs brainfart Thomas Gleixner
  2016-12-26 21:58 ` [patch 2/2] x86/mce/AMD: Make the init code more robust Thomas Gleixner
  0 siblings, 2 replies; 4+ messages in thread
From: Thomas Gleixner @ 2016-12-26 21:58 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: LKML, Ingo Molnar, Borislav Petkov, Peter Zijlstra,
	Markus Trippelsdorf, Boris Ostrovsky

The last minute changes to the hotplug core code wreckaged the dynamically
allocated states. The AMD mce code crashes as a result.

Fix the brainfart and make the AMD code more robust.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [patch 1/2] smp/hotplug: Undo tglxs brainfart
  2016-12-26 21:58 [patch 0/2] smp/hotplug: Fix last minute wreckage Thomas Gleixner
@ 2016-12-26 21:58 ` Thomas Gleixner
  2016-12-26 21:58 ` [patch 2/2] x86/mce/AMD: Make the init code more robust Thomas Gleixner
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Gleixner @ 2016-12-26 21:58 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: LKML, Ingo Molnar, Borislav Petkov, Peter Zijlstra,
	Markus Trippelsdorf, Boris Ostrovsky

[-- Attachment #1: smp-hotplug--Undo-tglxs-brainfart.patch --]
[-- Type: text/plain, Size: 1306 bytes --]

The attempt to prevent overwriting an active state resulted in a disaster
which effectively disables all dynamically allocated hotplug states.

Cleanup the mess.

Fixes: dc280d936239 ("cpu/hotplug: Prevent overwriting of callbacks")
Reported-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Reported-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/cpu.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1471,6 +1471,7 @@ int __cpuhp_setup_state(enum cpuhp_state
 			bool multi_instance)
 {
 	int cpu, ret = 0;
+	bool dynstate;
 
 	if (cpuhp_cb_check(state) || !name)
 		return -EINVAL;
@@ -1480,6 +1481,12 @@ int __cpuhp_setup_state(enum cpuhp_state
 	ret = cpuhp_store_callbacks(state, name, startup, teardown,
 				    multi_instance);
 
+	dynstate = state == CPUHP_AP_ONLINE_DYN;
+	if (ret > 0 && dynstate) {
+		state = ret;
+		ret = 0;
+	}
+
 	if (ret || !invoke || !startup)
 		goto out;
 
@@ -1508,7 +1515,7 @@ int __cpuhp_setup_state(enum cpuhp_state
 	 * If the requested state is CPUHP_AP_ONLINE_DYN, return the
 	 * dynamically allocated state in case of success.
 	 */
-	if (!ret && state == CPUHP_AP_ONLINE_DYN)
+	if (!ret && dynstate)
 		return state;
 	return ret;
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [patch 2/2] x86/mce/AMD: Make the init code more robust
  2016-12-26 21:58 [patch 0/2] smp/hotplug: Fix last minute wreckage Thomas Gleixner
  2016-12-26 21:58 ` [patch 1/2] smp/hotplug: Undo tglxs brainfart Thomas Gleixner
@ 2016-12-26 21:58 ` Thomas Gleixner
  2016-12-27  7:06   ` Borislav Petkov
  1 sibling, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2016-12-26 21:58 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: LKML, Ingo Molnar, Borislav Petkov, Peter Zijlstra,
	Markus Trippelsdorf, Boris Ostrovsky

[-- Attachment #1: x86-mce-AMD--Make-the-init-code-more-robust.patch --]
[-- Type: text/plain, Size: 704 bytes --]

If mce_device_init() fails then the mce device pointer is NULL and the AMD
mce code happily dereferences it.

Add a sanity check.

Reported-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Reported-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/kernel/cpu/mcheck/mce_amd.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
@@ -1182,6 +1182,9 @@ static int threshold_create_bank(unsigne
 	const char *name = get_name(bank, NULL);
 	int err = 0;
 
+	if (!dev)
+		return -ENODEV;
+
 	if (is_shared_bank(bank)) {
 		nb = node_to_amd_nb(amd_get_nb_id(cpu));
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch 2/2] x86/mce/AMD: Make the init code more robust
  2016-12-26 21:58 ` [patch 2/2] x86/mce/AMD: Make the init code more robust Thomas Gleixner
@ 2016-12-27  7:06   ` Borislav Petkov
  0 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2016-12-27  7:06 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Linus Torvalds, LKML, Ingo Molnar, Peter Zijlstra,
	Markus Trippelsdorf, Boris Ostrovsky

On Mon, Dec 26, 2016 at 10:58:20PM +0100, Thomas Gleixner wrote:
> If mce_device_init() fails then the mce device pointer is NULL and the AMD
> mce code happily dereferences it.
> 
> Add a sanity check.
> 
> Reported-by: Markus Trippelsdorf <markus@trippelsdorf.de>
> Reported-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
>  arch/x86/kernel/cpu/mcheck/mce_amd.c |    3 +++
>  1 file changed, 3 insertions(+)
> 
> --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
> +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
> @@ -1182,6 +1182,9 @@ static int threshold_create_bank(unsigne
>  	const char *name = get_name(bank, NULL);
>  	int err = 0;
>  
> +	if (!dev)
> +		return -ENODEV;
> +
>  	if (is_shared_bank(bank)) {
>  		nb = node_to_amd_nb(amd_get_nb_id(cpu));

Acked-by: Borislav Petkov <bp@suse.de>

>From looking at that code, though, it could use some more involved
straightening later.

/me puts it on TODO list.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-12-27  7:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-26 21:58 [patch 0/2] smp/hotplug: Fix last minute wreckage Thomas Gleixner
2016-12-26 21:58 ` [patch 1/2] smp/hotplug: Undo tglxs brainfart Thomas Gleixner
2016-12-26 21:58 ` [patch 2/2] x86/mce/AMD: Make the init code more robust Thomas Gleixner
2016-12-27  7:06   ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).