public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: [patch] x86, microcode, AMD: use after free in free_cache()
Date: Wed, 05 Sep 2012 12:30:42 +0000	[thread overview]
Message-ID: <20120905123042.GB6128@elgon.mountain> (raw)

list_for_each_entry_reverse() dereferences the iterator, but we already
freed it.  I don't see a reason that this has to be done in reverse
order so I've changed it to use list_for_each_entry_safe().

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This is only needed on linux-next.  Sorry, it turns out that I don't
have any AMD systems right now, so I have not tested this.

diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
index 5511216..7720ff5 100644
--- a/arch/x86/kernel/microcode_amd.c
+++ b/arch/x86/kernel/microcode_amd.c
@@ -150,9 +150,9 @@ static void update_cache(struct ucode_patch *new_patch)
 
 static void free_cache(void)
 {
-	struct ucode_patch *p;
+	struct ucode_patch *p, *tmp;
 
-	list_for_each_entry_reverse(p, &pcache, plist) {
+	list_for_each_entry_safe(p, tmp, &pcache, plist) {
 		__list_del(p->plist.prev, p->plist.next);
 		kfree(p->data);
 		kfree(p);

             reply	other threads:[~2012-09-05 12:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-05 12:30 Dan Carpenter [this message]
2012-09-05 13:20 ` [patch] x86, microcode, AMD: use after free in free_cache() Borislav Petkov
2012-09-05 23:42 ` Dan Carpenter
2012-09-06 12:01 ` Borislav Petkov
2012-09-06 12:30 ` Dan Carpenter
2012-09-06 13:06 ` Borislav Petkov
2012-09-06 14:04 ` Dan Carpenter
2012-09-06 16:16 ` Borislav Petkov
2012-09-12 11:00 ` 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=20120905123042.GB6128@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@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