* [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
* Re: [PATCH] compile-i386: fix use-after-free in func_cleanup()
[not found] ` <CANeU7Qm9Lo320TmkMzh6BKVC4Uwz6Pz6btuNxmW3fJH7zMMYcg@mail.gmail.com>
@ 2012-06-04 9:42 ` Jeff Garzik
2012-06-04 11:01 ` Pekka Enberg
0 siblings, 1 reply; 3+ messages in thread
From: Jeff Garzik @ 2012-06-04 9:42 UTC (permalink / raw)
To: Christopher Li; +Cc: Xi Wang, linux-sparse
On Fri, Jun 1, 2012 at 9:55 PM, Christopher Li <sparse@chrisli.org> wrote:
> On Fri, Jun 1, 2012 at 9:22 AM, Xi Wang <xi.wang@gmail.com> wrote:
>> 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.
>
> 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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] compile-i386: fix use-after-free in func_cleanup()
2012-06-04 9:42 ` Jeff Garzik
@ 2012-06-04 11:01 ` Pekka Enberg
0 siblings, 0 replies; 3+ messages in thread
From: Pekka Enberg @ 2012-06-04 11:01 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Christopher Li, Xi Wang, linux-sparse
On Mon, Jun 4, 2012 at 12:42 PM, Jeff Garzik <jgarzik@pobox.com> wrote:
> On Fri, Jun 1, 2012 at 9:55 PM, Christopher Li <sparse@chrisli.org> wrote:
>> On Fri, Jun 1, 2012 at 9:22 AM, Xi Wang <xi.wang@gmail.com> wrote:
>>> 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.
>>
>> 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.
Reviewed-by: Pekka Enberg <penberg@kernel.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [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).