[Asterisk-code-review] core_unreal: Fix deadlock with T.38 control frames. (asterisk[18.3])

Joshua Colp asteriskteam at digium.com
Mon Mar 22 07:50:30 CDT 2021


Joshua Colp has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/15652 )

Change subject: core_unreal: Fix deadlock with T.38 control frames.
......................................................................

core_unreal: Fix deadlock with T.38 control frames.

When using the ast_unreal_lock_all function no channel
locks can be held before calling it.

This change unlocks the channel that indicate was
called on before doing so and then relocks it afterwards.

ASTERISK-29035

Change-Id: Id65016201b5f9c9519a216e250f9101c629e19e9
---
M main/core_unreal.c
1 file changed, 4 insertions(+), 0 deletions(-)

Approvals:
  George Joseph: Looks good to me, approved
  Joshua Colp: Approved for Submit



diff --git a/main/core_unreal.c b/main/core_unreal.c
index 5adc90d..a79fca4 100644
--- a/main/core_unreal.c
+++ b/main/core_unreal.c
@@ -710,6 +710,7 @@
 			 * signaling and we need to be sure that the locking order is the same to prevent possible
 			 * deadlocks.
 			 */
+			ast_channel_unlock(ast);
 			ast_unreal_lock_all(p, &chan, &owner);
 
 			if (owner) {
@@ -726,12 +727,14 @@
 			}
 
 			ao2_unlock(p);
+			ast_channel_lock(ast);
 		} else if (parameters->request_response == AST_T38_TERMINATED) {
 			/*
 			 * Lock both parts of the local channel so we can restore their topologies to the original.
 			 * The topology should be on the unreal_pvt structure, with a ref that we can steal. Same
 			 * conditions as above.
 			 */
+			ast_channel_unlock(ast);
 			ast_unreal_lock_all(p, &chan, &owner);
 
 			if (owner) {
@@ -745,6 +748,7 @@
 			}
 
 			ao2_unlock(p);
+			ast_channel_lock(ast);
 		}
 
 		/*

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15652
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 18.3
Gerrit-Change-Id: Id65016201b5f9c9519a216e250f9101c629e19e9
Gerrit-Change-Number: 15652
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210322/e495d335/attachment-0001.html>


More information about the asterisk-code-review mailing list