diff options
author | Soumya Koduri <skoduri@redhat.com> | 2017-11-03 15:41:34 +0530 |
---|---|---|
committer | Niels de Vos <ndevos@redhat.com> | 2017-11-21 08:56:24 +0000 |
commit | 7100c0ec023dd1a4f779b8e6bee0cfbf2bef53b2 (patch) | |
tree | 377dac0ccc3e1f8a076f2ea5af111083dec3fa3d /extras/systemd/Makefile.am | |
parent | b6da32e527f0ba28773a9adf39b1dd55953f9dc4 (diff) |
timer: Fix possible race during cleanup
As mentioned in bug1509189, there is a possible race
between gf_timer_cancel(), gf_timer_proc() and
gf_timer_registry_destroy() leading to use_after_free.
Problem:
1) gf_timer_proc() is called, locks reg, and gets an event.
It unlocks reg, and calls the callback.
2) Meanwhile gf_timer_registry_destroy() is called, and removes
reg from ctx, and joins on gf_timer_proc().
3) gf_timer_call_cancel() is called on the event being
processed. It cannot find reg (since it's been removed from reg),
so it frees event.
4) the callback returns into gf_timer_proc(), and it tries to free
event, but it's already free, so double free.
Solution:
The fix is to bail out in gf_timer_cancel() when registry
is not found. The logic behind this is that, gf_timer_cancel()
is called only on any existing event. That means there was a valid
registry earlier while creating that event. And the only reason
we cannot find that registry now is that it must have got set to
NULL when context cleanup is started.
Since gf_timer_proc() takes care of releasing all the remaining
events active on that registry, it seems safe to bail out
in gf_timer_cancel().
Change-Id: Ia9b088533141c3bb335eff2fe06b52d1575bb34f
BUG: 1509189
Reported-by: Daniel Gryniewicz <dang@redhat.com>
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
Diffstat (limited to 'extras/systemd/Makefile.am')
0 files changed, 0 insertions, 0 deletions