[SR-Users] Possible locking issue in usrloc module in file udomain.c

Rupesh Kumar rupesh_kumar at sbcglobal.net
Wed Sep 18 22:05:27 CEST 2019


Hi ,
Currently I am running kamailio 4.2 and now upgrading to kamailio 5.2 and was just going thru the changes.

In the file modules/usrloc/udomain.c inside the function free_udomain( ) , it appears that we are not protecting via lock_ulslot and unlock_ulslot doing free. Could it cause some race condition ?
May be its intentional but going thru the github history its there since day 1. I checked all branches in kamailio 4.x and we have the protection.
In 4.x 

void free_udomain(udomain_t* _d)
{
    int i;
    
    if (_d->table) {
        for(i = 0; i < _d->size; i++) {
            lock_ulslot(_d, i);
            deinit_slot(_d->table + i);
            unlock_ulslot(_d, i);
        }
        shm_free(_d->table);
    }    shm_free(_d);
}
In 5.x
void free_udomain(udomain_t* _d)
{
    int i;
    
    if (_d->table) {
        for(i = 0; i < _d->size; i++) {
            deinit_slot(_d->table + i);
        }
        shm_free(_d->table);
    }
    shm_free(_d);
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20190918/21317dab/attachment.html>


More information about the sr-users mailing list