[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-a3125494cff084b098c80bb36fbe2061ffed9d52@git.kernel.org>
Date: Wed, 13 Apr 2016 04:35:03 -0700
From: tip-bot for Tony Luck <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: linux-edac@...r.kernel.org, stable@...r.kernel.org,
tony.luck@...el.com, gong.chen@...ux.intel.com, tglx@...utronix.de,
linux-kernel@...r.kernel.org, mingo@...nel.org, hpa@...or.com,
torvalds@...ux-foundation.org, bp@...e.de, peterz@...radead.org
Subject: [tip:ras/core] x86/mce: Avoid using object after free in genpool
Commit-ID: a3125494cff084b098c80bb36fbe2061ffed9d52
Gitweb: http://git.kernel.org/tip/a3125494cff084b098c80bb36fbe2061ffed9d52
Author: Tony Luck <tony.luck@...el.com>
AuthorDate: Wed, 6 Apr 2016 10:05:16 +0200
Committer: Ingo Molnar <mingo@...nel.org>
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.
Signed-off-by: Tony Luck <tony.luck@...el.com>
Signed-off-by: Borislav Petkov <bp@...e.de>
Cc: <stable@...r.kernel.org>
Cc: Gong Chen <gong.chen@...ux.intel.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: linux-edac <linux-edac@...r.kernel.org>
Link: http://lkml.kernel.org/r/0205920@agluck-desk.sc.intel.com
Link: http://lkml.kernel.org/r/1459929916-12852-4-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
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 0a85010..2658e2a 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));
Powered by blists - more mailing lists