compile-i386: fix use-after-free in func_cleanup()
PATCH 1/1 compile-i386: fix use-after-free in func_cleanup()
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.
--- compile-i386.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
compile-i386.c +0 -3
@@ -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);
A message that is not in the archive (sent off-list or not yet received): CANeU7Qm9Lo320TmkMzh6BKVC4Uwz6Pz6btuNxmW3fJH7zMMYcg@mail.gmail.com
Quoted 10 lines · Christopher Li
Quoted 7 lines · Xi Wang
compile-i386 sometimes crashes due a use-after-free error. Since
f->pseudo_listis freed first, which invalidates some atom->op* inf->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_listfirst. Those marked asSTOR_WANTS_FREEwon't appear inf->pseudo_list.Seems make sense. I will apply if Jeff don't have any objections.
If the patch makes sense, go for it. I'm on vacation in France until June 8, the original patch is not in my inbox, and I do not have readily available Internet connectivity besides... :)
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Pekka Enberg
Reviewed-byQuoted 7 lines · Jeff Garzik
Quoted 6 lines · Christopher Li
Quoted 5 lines · Xi Wang
compile-i386 sometimes crashes due a use-after-free error. Since
f->pseudo_listis freed first, which invalidates some atom->op* inf->atom_list. Further checks like `atom->op1->flags &STOR_WANTS_FREE' will read garbage, which may lead to a double free.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
This patch switches the cleanup order and frees
f->atom_listfirst. Those marked asSTOR_WANTS_FREEwon't appear inf->pseudo_list.Seems make sense. I will apply if Jeff don't have any objections.
If the patch makes sense, go for it. I'm on vacation in France until June 8, the original patch is not in my inbox, and I do not have readily available Internet connectivity besides... :)
Looks good to me.
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html