You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "cmcfarlen (via GitHub)" <gi...@apache.org> on 2025/06/19 00:35:53 UTC

[PR] Fix potential mutex destroy while locked in origin_server_auth plugin [trafficserver]

cmcfarlen opened a new pull request, #12307:
URL: https://github.com/apache/trafficserver/pull/12307

   It's possible depending on refcounts of underlying mutex objects that when tearing down an instance of the origin_server_auth plugin that we might call `pthread_mutex_destroy` while holding a lock on the same mutex.  This causes ATS to abort.
   
   The fix involves deferring the continuation destroy until after the mutex is unlocked.  At that time, it doesn't matter what the refcount is and it is safe to destroy the mutex.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix potential mutex destroy while locked in origin_server_auth plugin [trafficserver]

Posted by "bryancall (via GitHub)" <gi...@apache.org>.
bryancall commented on code in PR #12307:
URL: https://github.com/apache/trafficserver/pull/12307#discussion_r2175641303


##########
plugins/origin_server_auth/origin_server_auth.cc:
##########
@@ -1269,11 +1276,18 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf ATS_UNUSE
 void
 TSRemapDeleteInstance(void *ih)
 {
-  S3Config *s3           = static_cast<S3Config *>(ih);
-  TSMutex   s3_mutex_ptr = s3->config_reloader_mutex();
-  TSMutexLock(s3_mutex_ptr);
-  delete s3;
-  TSMutexUnlock(s3_mutex_ptr);
+  S3Config *s3 = static_cast<S3Config *>(ih);

Review Comment:
   Couldn't this all be done in the destructor for s3?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix potential mutex destroy while locked in origin_server_auth plugin [trafficserver]

Posted by "cmcfarlen (via GitHub)" <gi...@apache.org>.
cmcfarlen merged PR #12307:
URL: https://github.com/apache/trafficserver/pull/12307


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix potential mutex destroy while locked in origin_server_auth plugin [trafficserver]

Posted by "cmcfarlen (via GitHub)" <gi...@apache.org>.
cmcfarlen commented on PR #12307:
URL: https://github.com/apache/trafficserver/pull/12307#issuecomment-3028806559

   [approve ci autest 1]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix potential mutex destroy while locked in origin_server_auth plugin [trafficserver]

Posted by "cmcfarlen (via GitHub)" <gi...@apache.org>.
cmcfarlen commented on PR #12307:
URL: https://github.com/apache/trafficserver/pull/12307#issuecomment-3028958885

   Cherry-picked to 10.1.x branch


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix potential mutex destroy while locked in origin_server_auth plugin [trafficserver]

Posted by "cmcfarlen (via GitHub)" <gi...@apache.org>.
cmcfarlen commented on code in PR #12307:
URL: https://github.com/apache/trafficserver/pull/12307#discussion_r2176082765


##########
plugins/origin_server_auth/origin_server_auth.cc:
##########
@@ -1269,11 +1276,18 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf ATS_UNUSE
 void
 TSRemapDeleteInstance(void *ih)
 {
-  S3Config *s3           = static_cast<S3Config *>(ih);
-  TSMutex   s3_mutex_ptr = s3->config_reloader_mutex();
-  TSMutexLock(s3_mutex_ptr);
-  delete s3;
-  TSMutexUnlock(s3_mutex_ptr);
+  S3Config *s3 = static_cast<S3Config *>(ih);

Review Comment:
   Maybe, but the code to avoid the race condition has to modify s3 and then fix the order of the destruction.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org