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

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


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

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:
  Richard Mudgett: Looks good to me, but someone else must approve
  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/+/15637
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Id65016201b5f9c9519a216e250f9101c629e19e9
Gerrit-Change-Number: 15637
Gerrit-PatchSet: 4
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-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210322/ebf85afb/attachment.html>


More information about the asterisk-code-review mailing list