From: Xi Wang <xi.wang@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Xi Wang <xi.wang@gmail.com>
Subject: [PATCH] compile-i386: fix use-after-free in func_cleanup()
Date: Fri, 1 Jun 2012 12:22:00 -0400 [thread overview]
Message-ID: <1338567720-23595-1-git-send-email-xi.wang@gmail.com> (raw)
compile-i386 sometimes crashes due a use-after-free error. Since
f->pseudo_list is freed first, which invalidates some atom->op* in
f->atom_list. Further checks like `atom->op1->flags & STOR_WANTS_FREE'
will read garbage, which may lead to a double free.
This patch switches the cleanup order and frees f->atom_list first.
Those marked as STOR_WANTS_FREE won't appear in f->pseudo_list.
Signed-off-by: Xi Wang <xi.wang@gmail.com>
---
compile-i386.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/compile-i386.c b/compile-i386.c
index da3ee49..b470952 100644
--- a/compile-i386.c
+++ b/compile-i386.c
@@ -761,10 +761,6 @@ static void func_cleanup(struct function *f)
struct storage *stor;
struct atom *atom;
- FOR_EACH_PTR(f->pseudo_list, stor) {
- free(stor);
- } END_FOR_EACH_PTR(stor);
next reply other threads:[~2012-06-01 16:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-01 16:22 Xi Wang [this message]
[not found] ` <CANeU7Qm9Lo320TmkMzh6BKVC4Uwz6Pz6btuNxmW3fJH7zMMYcg@mail.gmail.com>
2012-06-04 9:42 ` [PATCH] compile-i386: fix use-after-free in func_cleanup() Jeff Garzik
2012-06-04 11:01 ` Pekka Enberg
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=1338567720-23595-1-git-send-email-xi.wang@gmail.com \
--to=xi.wang@gmail.com \
--cc=linux-sparse@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;
as well as URLs for NNTP newsgroup(s).