[Home]

Summary:ASTERISK-12119: Manager deadlock when loading a module
Reporter:James McCoy (jamessan)Labels:
Date Opened:2008-05-30 15:55:29Date Closed:2008-06-02 09:38:31
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Core/ManagerInterface
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:manager.c:process_message calls "ast_rwlock_rdlock(&actionlock);" when determining what action needs to be run.  When it finds the command, the lock is still held while that action is run.  If this is a "module load" action, it is quite likely that the loaded resource will then call ast_manager_register/ast_manager_register2 to add their own commands to the manager interface.  Those functions in turn call "ast_rwlock_wrlock(&actionlock);" which results in a deadlock.

At first glance, unlocking the rdlock once the matching action has been found would seem the right thing to do.  After some thought though, it seems like that would only be safe if the action is one that's native to the manager interface.  Otherwise, the manager may get interrupted immediately after releasing the lock, but before calling the action, by something that then removes the action from the actionlist.
Comments:By: Joshua C. Colp (jcolp) 2008-06-02 07:42:08

This issue does not exist as the Manager interface has a command blacklist to deny these commands from being executed.

By: James McCoy (jamessan) 2008-06-02 08:01:56

Then that blacklist isn't working correctly.  This was bug was discovered by it very reproducibly happening on my system.

By: Joshua C. Colp (jcolp) 2008-06-02 08:06:46

I just confirmed it is indeed there and working... what exactly does your manager command look like?

Here is what I did:

Action: Command
Command: module load res_potato.so

Response: Error
Message: Command blacklisted

By: James McCoy (jamessan) 2008-06-02 08:31:31

Action: Command
Command: module load chan_sip.so

and then no response.

By: Joshua C. Colp (jcolp) 2008-06-02 08:33:25

Can you please grab a backtrace according to doc/backtrace.txt so we can confirm that is indeed where the deadlock is happening?

By: Digium Subversion (svnbot) 2008-06-02 09:33:22

Repository: asterisk
Revision: 119742

U   branches/1.4/main/manager.c

------------------------------------------------------------------------
r119742 | russell | 2008-06-02 09:33:16 -0500 (Mon, 02 Jun 2008) | 5 lines

Improve CLI command blacklist checking for the command manager action.  Previously,
it did not handle case or whitespace properly.  This made it possible for blacklisted
commands to get executed anyway.
(closes issue ASTERISK-12119)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=119742

By: Digium Subversion (svnbot) 2008-06-02 09:35:40

Repository: asterisk
Revision: 119744

_U  trunk/
U   trunk/main/manager.c

------------------------------------------------------------------------
r119744 | russell | 2008-06-02 09:35:36 -0500 (Mon, 02 Jun 2008) | 13 lines

Merged revisions 119742 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r119742 | russell | 2008-06-02 09:39:45 -0500 (Mon, 02 Jun 2008) | 5 lines

Improve CLI command blacklist checking for the command manager action.  Previously,
it did not handle case or whitespace properly.  This made it possible for blacklisted
commands to get executed anyway.
(closes issue ASTERISK-12119)

........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=119744

By: Digium Subversion (svnbot) 2008-06-02 09:38:31

Repository: asterisk
Revision: 119745

_U  branches/1.6.0/
U   branches/1.6.0/main/manager.c

------------------------------------------------------------------------
r119745 | russell | 2008-06-02 09:38:30 -0500 (Mon, 02 Jun 2008) | 21 lines

Merged revisions 119744 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
r119744 | russell | 2008-06-02 09:41:55 -0500 (Mon, 02 Jun 2008) | 13 lines

Merged revisions 119742 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r119742 | russell | 2008-06-02 09:39:45 -0500 (Mon, 02 Jun 2008) | 5 lines

Improve CLI command blacklist checking for the command manager action.  Previously,
it did not handle case or whitespace properly.  This made it possible for blacklisted
commands to get executed anyway.
(closes issue ASTERISK-12119)

........

................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=119745