[Asterisk-code-review] res pjsip transport websocket: Fix use-after-free bugs. (asterisk[master])

Ivan Poddubny asteriskteam at digium.com
Sat Jun 6 13:24:55 CDT 2015


Ivan Poddubny has uploaded a new patch set (#2).

Change subject: res_pjsip_transport_websocket: Fix use-after-free bugs.
......................................................................

res_pjsip_transport_websocket: Fix use-after-free bugs.

This patch fixes use-after-free bugs caught by AddressSanitizer.

1. PJSIP transport manager may decide to destroy transport on its own.
For example, when the contact registered via websocket has not renewed
its registration in time. The transport was destoyed, but the websocket
listener thread was still active until the socket closes, and then tried
to call transport_shutdown on transport that has been freed.

This is fixed by adding a group lock that ensures that transport is
destroyed only when both websocket listener and pjsip transport manager
are finished with it.

2. The websocket listener deletes the last reference on websocket session
when the tcp connection is closed, and it gets destroyed, but
the transport manager may still use it, for example when disconnect
happens in the middle of a SIP transaction.

A new reference to websocket session has been added that is released
with the transport to prevent this.

3. The transport destructor accessed wstransport->rdata.tp_info.pool
right after freeing memory that contained wstransport itself.

ASTERISK-25096 #close
Reported by: Josh Kitchens

ASTERISK-24963 #close
Reported by: Badalian Vyacheslav

Change-Id: Idc0b63eb6e459c1ddfb2430127d34b3c4d8d373b
---
M res/res_pjsip_transport_websocket.c
1 file changed, 62 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/98/598/2
-- 
To view, visit https://gerrit.asterisk.org/598
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Idc0b63eb6e459c1ddfb2430127d34b3c4d8d373b
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Ivan Poddubny <ivan.poddubny at gmail.com>



More information about the asterisk-code-review mailing list