From: Marcel Holtmann <marcel@holtmann.org>
To: Szymon Janc <szymon@janc.net.pl>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] shared: Fix use after free in read_watch_destroy
Date: Sun, 03 Feb 2013 12:47:49 +0100 [thread overview]
Message-ID: <1359892069.6873.2.camel@aeonflux> (raw)
In-Reply-To: <1359830398-23165-1-git-send-email-szymon@janc.net.pl>
Hi Szymon,
> read_watch_destroy is called when received_data returns FALSE.
> free mgmt in read_watch_destroy instead of received_data to avoid
> use after free.
>
> Invalid write of size 4
> at 0x8051604: read_watch_destroy (mgmt.c:271)
> by 0x48C7468E: g_source_callback_unref (gmain.c:1457)
> by 0x48C77287: g_main_context_dispatch (gmain.c:2723)
> by 0x48C774FF: g_main_context_iterate.isra.22 (gmain.c:3290)
> by 0x48C77962: g_main_loop_run (gmain.c:3484)
> by 0x805393E: tester_run (tester.c:784)
> by 0x804D1C7: main (mgmt-tester.c:2558)
> Address 0x4039b80 is 16 bytes inside a block of size 76 free'd
> at 0x4007F0F: free (vg_replace_malloc.c:446)
> by 0x48C7D44B: standard_free (gmem.c:98)
> by 0x48C7D607: g_free (gmem.c:252)
> by 0x8051BB6: received_data (mgmt.c:337)
> by 0x48CBA72E: g_io_unix_dispatch (giounix.c:167)
> by 0x48C7715A: g_main_context_dispatch (gmain.c:2715)
> by 0x48C774FF: g_main_context_iterate.isra.22 (gmain.c:3290)
> by 0x48C77962: g_main_loop_run (gmain.c:3484)
> by 0x805393E: tester_run (tester.c:784)
> by 0x804D1C7: main (mgmt-tester.c:2558)
> ---
> src/shared/mgmt.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
excellent catch here. I totally overlooked this code path when fixing
unregister from event callback. Patch has been applied.
Regards
Marcel
prev parent reply other threads:[~2013-02-03 11:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-02 18:39 [PATCH] shared: Fix use after free in read_watch_destroy Szymon Janc
2013-02-03 11:47 ` Marcel Holtmann [this message]
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=1359892069.6873.2.camel@aeonflux \
--to=marcel@holtmann.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=szymon@janc.net.pl \
/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