linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] compile-i386: fix use-after-free in func_cleanup()
@ 2012-06-01 16:22 Xi Wang
       [not found] ` <CANeU7Qm9Lo320TmkMzh6BKVC4Uwz6Pz6btuNxmW3fJH7zMMYcg@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Xi Wang @ 2012-06-01 16:22 UTC (permalink / raw)
  To: linux-sparse; +Cc: Xi Wang

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);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-06-04 11:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-01 16:22 [PATCH] compile-i386: fix use-after-free in func_cleanup() Xi Wang
     [not found] ` <CANeU7Qm9Lo320TmkMzh6BKVC4Uwz6Pz6btuNxmW3fJH7zMMYcg@mail.gmail.com>
2012-06-04  9:42   ` Jeff Garzik
2012-06-04 11:01     ` Pekka Enberg

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).