Bug 56639 - Race condition in Event MPM
Summary: Race condition in Event MPM
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mpm_event (show other bugs)
Version: 2.5-HEAD
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: FixedInTrunk, PatchAvailable
Depends on:
Blocks:
 
Reported: 2014-06-18 18:23 UTC by Edward Lu
Modified: 2014-08-18 06:59 UTC (History)
0 users



Attachments
Fix event MPM race condition on connection scoreboard handle (2.29 KB, patch)
2014-06-18 18:23 UTC, Edward Lu
Details | Diff
Fix event MPM race condition on connection scoreboard handle (1.80 KB, patch)
2014-06-18 18:25 UTC, Edward Lu
Details | Diff
Move sbh nullification to correct place (766 bytes, patch)
2014-06-24 12:26 UTC, Edward Lu
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Edward Lu 2014-06-18 18:23:57 UTC
Created attachment 31725 [details]
Fix event MPM race condition on connection scoreboard handle

In event.c, process_socket(), if a worker thread is put into the lingering close state, it is put into the linger_q (or short_linger_q). Shortly afterward, the scoreboard handle of the connection handled by that thread is set to NULL. Meanwhile, in the listener thread, process_lingering_close() is called on any connections in the linger_q that are closed. This also clears the transaction pool, making it available for other workers to use. Most of the time, this is fine, but in the worst case, this can result in a race condition; the listener thread may assign the pool to another thread between the time the pool is cleared and the time c->sbh is set to NULL. This can be a problem for third-party modules which access the scoreboard using the connection scoreboard handle at arbitrary times.

This problem appears to be very close to revision 1538490, but that fix covers every case except for the lingering close fixed here.
Comment 1 Edward Lu 2014-06-18 18:25:58 UTC
Created attachment 31726 [details]
Fix event MPM race condition on connection scoreboard handle

Wrong patch before - still had some things I was experimenting with
Comment 2 Eric Covener 2014-06-21 13:22:16 UTC
Thanks, committed and proposed for backport.
Comment 3 Edward Lu 2014-06-24 12:26:22 UTC
Created attachment 31747 [details]
Move sbh nullification to correct place

I just realized that I nulled the sbh out in the wrong place in the last patch - it's supposed to be before the connection is added to the queue, not the pollset. This patch is on top of what was just committed.
Comment 4 Christophe JAILLET 2014-08-18 06:59:11 UTC
Fixed and released in 2.4.10