x86/mce: Use atomic_inc_return barrier when starting monad sync
Subsystems (2)
PATCH 1/1 x86/mce: Use atomic_inc_return barrier when starting monad sync
mce_start() has an explicit smp_wmb to serialize writes to global_nwo and mce_callin. However, atomic_inc_return() implies barriers on both sides of the call, as such simply rely on this full smp barrier.
--- arch/x86/kernel/cpu/mcheck/mce.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mcheck/mce.c +2 -2
@@ -830,9 +830,9 @@ static int mce_start(int *no_way_out)atomic_add (*no_way_out, &global_nwo);/* -* global_nwo should be updated before mce_callin +* Rely on the implied barrier below, such that global_nwo +* is updated before mce_callin. */ -smp_wmb (); order =atomic_inc_return (&mce_callin);/*
Signature · 1 line
2.1.4
Quoted 9 lines · Davidlohr Bueso
mce_start()has an explicitsmp_wmbto serialize writes toglobal_nwoandmce_callin. However,atomic_inc_return()implies barriers on both sides of the call, as such simply rely on this full smp barrier.Signed-off-by Davidlohr Bueso <[email protected]>--- arch/x86/kernel/cpu/mcheck/mce.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Applied, thanks.
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.PATCH 1/1 x86/mce: Avoid using object after free in genpool.
When we loop over all queued machine check error records to pass them to the registered notifiers we use llist_for_each_entry(). But the loop calls gen_pool_free() for the entry in the body of the loop - and then the iterator looks at node->next after the free.
Use llist_for_each_entry_safe() instead.
--- arch/x86/kernel/cpu/mcheck/mce-genpool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mcheck/mce-genpool.c +2 -2
@@ -29,7 +29,7 @@ static char gen_pool_buf[MCE_POOLSZ];void mce_gen_pool_process (void ) {struct llist_node *head; -struct mce_evt_llist *node; +struct mce_evt_llist *node, *tmp;struct mce *mce; head =llist_del_all (&mce_event_llist);
@@ -37,7 +37,7 @@ void mce_gen_pool_process(void)return ; head =llist_reverse_order (head); -llist_for_each_entry (node, head, llnode) { +llist_for_each_entry_safe (node, tmp, head, llnode) { mce = &node->mce;atomic_notifier_call_chain (&x86_mce_decoder_chain,0 , mce);gen_pool_free (mce_evt_pool, (unsigned long )node,sizeof (*node));
Signature · 1 line
2.5.0
Re: [PATCH] x86/mce: Avoid using object after free in genpool.
Quoted 29 lines · Tony Luck
When we loop over all queued machine check error records to pass them to the registered notifiers we use
llist_for_each_entry(). But the loop callsgen_pool_free()for the entry in the body of the loop - and then the iterator looks atnode->nextafter the free.Use
llist_for_each_entry_safe()instead.Signed-off-by Tony Luck <[email protected]>--- arch/x86/kernel/cpu/mcheck/mce-genpool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/x86/kernel/cpu/mcheck/mce-genpool.c +1
-1@@ -29,7 +29,7 @@ static char gen_pool_buf[MCE_POOLSZ];void mce_gen_pool_process (void ) {struct llist_node *head; -struct mce_evt_llist *node; +struct mce_evt_llist *node, *tmp;struct mce *mce; head =llist_del_all (&mce_event_llist);
arch/x86/kernel/cpu/mcheck/mce-genpool.c void mce_gen_pool_process(void) · line 43
Quoted 8 lines
arch/x86/kernel/cpu/mcheck/mce-genpool.c +1
-1@@ -37,7 +37,7 @@ void mce_gen_pool_process(void)return ; head =llist_reverse_order (head); -llist_for_each_entry (node, head, llnode) { +llist_for_each_entry_safe (node, tmp, head, llnode) { mce = &node->mce;atomic_notifier_call_chain (&x86_mce_decoder_chain,0 , mce);gen_pool_free (mce_evt_pool, (unsigned long )node,sizeof (*node));
I have a couple more RAS patches for tip, want me to pick that one up too? I'm going to send my pile to tip guys after -rc1 is out.
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.RE: [PATCH] x86/mce: Avoid using object after free in genpool.
Quoted 1 line
Acked-by Borislav Petkov <[email protected]>
Thanks
Quoted 2 lines
I have a couple more RAS patches for tip, want me to pick that one up too? I'm going to send my pile to tip guys after -rc1 is out.
Yes please ... throw this one on the pile.
-Tony
Borislav Petkov
maintainercover x86/RAS: Some small things for tip
From: Borislav Petkov <[email protected]>
Hi,
just a couple of smallish fixes. Tony's is CC:stable so please queue this into tip:x86/urgent.
Thanks.
Borislav Petkov (1):
x86/RAS: Rename AMD MCE injectior config item
Davidlohr Bueso (1):
x86/mce: Remove explicit smp_rmb() when starting CPUs sync
Tony Luck (1):
x86/mce: Avoid using object after free in genpool
arch/x86/kernel/cpu/mcheck/mce-genpool.c | 4 ++-- arch/x86/kernel/cpu/mcheck/mce.c | 4 ++-- arch/x86/ras/Kconfig | 2 +- arch/x86/ras/Makefile | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
2.7.3
Borislav Petkov
maintainerPATCH 1/3 x86/RAS: Rename AMD MCE injectior config item
From: Borislav Petkov <[email protected]>
... to be the same like the file name of injection module itself to avoid confusion when grepping.
No functionality change.
--- arch/x86/ras/Kconfig | 2 +- arch/x86/ras/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/ras/Kconfig +1 -1
@@ -1,4 +1,4 @@ -config AMD_MCE_INJ +config MCE_AMD_INJ tristate "Simple MCE injection interface for AMD processors" depends on RAS && EDAC_DECODE_MCE && DEBUG_FS && AMD_NB default n
arch/x86/ras/Makefile +1 -1
@@ -1,2 +1,2 @@ -obj-$(CONFIG_AMD_MCE_INJ) += mce_amd_inj.o +obj-$(CONFIG_MCE_AMD_INJ) += mce_amd_inj.o
Signature · 1 line
2.7.3
tip-bot for Borislav Petkov
merge bot[tip:ras/core] x86/RAS: Rename AMD MCE injector config item
x86/RAS: Rename AMD MCE injector config item
Commit-ID: 69385f8879344f4a1f078f761bd3523fcf697131 Gitweb: http://git.kernel.org/tip/69385f8879344f4a1f078f761bd3523fcf697131 Author: Borislav Petkov <[email protected]> AuthorDate: Wed, 6 Apr 2016 10:05:14 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 13 Apr 2016 10:54:23 +0200
x86/RAS: Rename AMD MCE injector config item
... to be the same like the file name of injection module itself to avoid confusion when grepping.
No functionality change.
--- arch/x86/ras/Kconfig | 2 +- arch/x86/ras/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/ras/Kconfig +1 -1
@@ -1,4 +1,4 @@ -config AMD_MCE_INJ +config MCE_AMD_INJ tristate "Simple MCE injection interface for AMD processors" depends on RAS && EDAC_DECODE_MCE && DEBUG_FS && AMD_NB default n
arch/x86/ras/Makefile +1 -1
@@ -1,2 +1,2 @@ -obj-$(CONFIG_AMD_MCE_INJ) += mce_amd_inj.o +obj-$(CONFIG_MCE_AMD_INJ) += mce_amd_inj.o
Borislav Petkov
maintainerPATCH 2/3 x86/mce: Remove explicit smp_rmb() when starting CPUs sync
In reply to Borislav PetkovFrom: Davidlohr Bueso <[email protected]>
mce_start() has an explicit smp_wmb() to serialize writes to global_nwo and mce_callin. However, atomic_inc_return() implies barriers on both sides of the call, as such simply rely on this full SMP barrier.
--- arch/x86/kernel/cpu/mcheck/mce.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mcheck/mce.c +2 -2
@@ -830,9 +830,9 @@ static int mce_start(int *no_way_out)atomic_add (*no_way_out, &global_nwo);/* -* global_nwo should be updated before mce_callin +* Rely on the implied barrier below, such that global_nwo +* is updated before mce_callin. */ -smp_wmb (); order =atomic_inc_return (&mce_callin);/*
Signature · 1 line
2.7.3
tip-bot for Davidlohr Bueso
merge bot[tip:ras/core] x86/mce: Remove explicit smp_rmb() when starting CPUs sync
x86/mce: Remove explicit smp_rmb() when starting CPUs sync
Commit-ID: bf92b1feb658f6a262daf3a87d790997a1dca0ff Gitweb: http://git.kernel.org/tip/bf92b1feb658f6a262daf3a87d790997a1dca0ff Author: Davidlohr Bueso <[email protected]> AuthorDate: Wed, 6 Apr 2016 10:05:15 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 13 Apr 2016 10:54:23 +0200
x86/mce: Remove explicit smp_rmb() when starting CPUs sync
mce_start() has an explicit smp_wmb() to serialize writes to global_nwo and mce_callin. However, atomic_inc_return() implies barriers on both sides of the call, as such simply rely on this full SMP barrier.
--- arch/x86/kernel/cpu/mcheck/mce.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mcheck/mce.c +2 -2
@@ -830,9 +830,9 @@ static int mce_start(int *no_way_out)atomic_add (*no_way_out, &global_nwo);/* -* global_nwo should be updated before mce_callin +* Rely on the implied barrier below, such that global_nwo +* is updated before mce_callin. */ -smp_wmb (); order =atomic_inc_return (&mce_callin);/*
Borislav Petkov
maintainerPATCH 3/3 x86/mce: Avoid using object after free in genpool
In reply to Borislav PetkovFrom: Tony Luck <[email protected]>
When we loop over all queued machine check error records to pass them to the registered notifiers we use llist_for_each_entry(). But the loop calls gen_pool_free() for the entry in the body of the loop - and then the iterator looks at node->next after the free.
Use llist_for_each_entry_safe() instead.
--- arch/x86/kernel/cpu/mcheck/mce-genpool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mcheck/mce-genpool.c +2 -2
@@ -29,7 +29,7 @@ static char gen_pool_buf[MCE_POOLSZ];void mce_gen_pool_process (void ) {struct llist_node *head; -struct mce_evt_llist *node; +struct mce_evt_llist *node, *tmp;struct mce *mce; head =llist_del_all (&mce_event_llist);
@@ -37,7 +37,7 @@ void mce_gen_pool_process(void)return ; head =llist_reverse_order (head); -llist_for_each_entry (node, head, llnode) { +llist_for_each_entry_safe (node, tmp, head, llnode) { mce = &node->mce;atomic_notifier_call_chain (&x86_mce_decoder_chain,0 , mce);gen_pool_free (mce_evt_pool, (unsigned long )node,sizeof (*node));
Signature · 1 line
2.7.3
tip-bot for Tony Luck
merge bot[tip:ras/core] x86/mce: Avoid using object after free in genpool
x86/mce: Avoid using object after free in genpool
Commit-ID: a3125494cff084b098c80bb36fbe2061ffed9d52 Gitweb: http://git.kernel.org/tip/a3125494cff084b098c80bb36fbe2061ffed9d52 Author: Tony Luck <[email protected]> AuthorDate: Wed, 6 Apr 2016 10:05:16 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 13 Apr 2016 10:54:00 +0200
x86/mce: Avoid using object after free in genpool
When we loop over all queued machine check error records to pass them to the registered notifiers we use llist_for_each_entry(). But the loop calls gen_pool_free() for the entry in the body of the loop - and then the iterator looks at node->next after the free.
Use llist_for_each_entry_safe() instead.
--- arch/x86/kernel/cpu/mcheck/mce-genpool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mcheck/mce-genpool.c +2 -2
@@ -29,7 +29,7 @@ static char gen_pool_buf[MCE_POOLSZ];void mce_gen_pool_process (void ) {struct llist_node *head; -struct mce_evt_llist *node; +struct mce_evt_llist *node, *tmp;struct mce *mce; head =llist_del_all (&mce_event_llist);
@@ -37,7 +37,7 @@ void mce_gen_pool_process(void)return ; head =llist_reverse_order (head); -llist_for_each_entry (node, head, llnode) { +llist_for_each_entry_safe (node, tmp, head, llnode) { mce = &node->mce;atomic_notifier_call_chain (&x86_mce_decoder_chain,0 , mce);gen_pool_free (mce_evt_pool, (unsigned long )node,sizeof (*node));