From: Tony Luck <tony.luck@intel.com>
To: Borislav Petkov <bp@alien8.de>
Cc: linux-kernel@vger.kernel.org, "Chen, Gong" <gong.chen@linux.intel.com>
Subject: [PATCH] x86/mce: Avoid using object after free in genpool.
Date: Wed, 23 Mar 2016 09:14:40 -0700 [thread overview]
Message-ID: <0205920@agluck-desk.sc.intel.com> (raw)
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.
Cc: stable@vger.kernel.org
Signed-off-by: Tony Luck <tony.luck@intel.com>
---
arch/x86/kernel/cpu/mcheck/mce-genpool.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/mcheck/mce-genpool.c b/arch/x86/kernel/cpu/mcheck/mce-genpool.c
index 0a850100c594..2658e2af74ec 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-genpool.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-genpool.c
@@ -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));
--
2.5.0
next reply other threads:[~2016-03-23 16:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-23 16:14 Tony Luck [this message]
2016-03-23 17:33 ` [PATCH] x86/mce: Avoid using object after free in genpool Borislav Petkov
2016-03-23 20:47 ` Luck, Tony
-- strict thread matches above, loose matches on Subject: below --
2016-04-06 8:05 [PATCH 0/3] x86/RAS: Some small things for tip Borislav Petkov
2016-04-06 8:05 ` [PATCH 1/3] x86/RAS: Rename AMD MCE injectior config item Borislav Petkov
2016-04-13 11:35 ` [tip:ras/core] x86/RAS: Rename AMD MCE injector " tip-bot for Borislav Petkov
2016-04-06 8:05 ` [PATCH 2/3] x86/mce: Remove explicit smp_rmb() when starting CPUs sync Borislav Petkov
2016-04-13 11:35 ` [tip:ras/core] " tip-bot for Davidlohr Bueso
2016-04-06 8:05 ` [PATCH 3/3] x86/mce: Avoid using object after free in genpool Borislav Petkov
2016-04-13 11:35 ` [tip:ras/core] " tip-bot for Tony Luck
2016-03-21 23:19 [PATCH -tip] x86/mce: Use atomic_inc_return barrier when starting monad sync Davidlohr Bueso
2016-03-23 8:30 ` Borislav Petkov
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=0205920@agluck-desk.sc.intel.com \
--to=tony.luck@intel.com \
--cc=bp@alien8.de \
--cc=gong.chen@linux.intel.com \
--cc=linux-kernel@vger.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