Skip to content

Commit 367c476

Browse files
committed
Fix spurious appsec munmaps in ZTS mode
Once any ZTS thread shuts down, _shared_state is munmap'ped(). It will be unmapped and any other later mapping may happen at that same place through bad luck. If another thread shuts down, it will munmap this again and accesses to the later mapping are now crashing. Signed-off-by: Bob Weinand <[email protected]>
1 parent 7d6fda9 commit 367c476

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Changelog for older versions can be found in our [release page](https://github.c
5252

5353
### Fixed
5454
- Use abstract namespace on linux #3525
55+
- Fix spurious munmaps in ZTS mode #3590
5556

5657
### Internal
5758
- Improvements for appsec libxml2 usage #3564

appsec/src/extension/helper_process.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,17 @@ void dd_helper_startup(void)
8888
#endif
8989
}
9090

91-
void dd_helper_shutdown(void) {}
91+
void dd_helper_shutdown(void)
92+
{
93+
if (_shared_state) {
94+
munmap(_shared_state, sizeof(dd_helper_shared_state));
95+
}
96+
}
9297

9398
void dd_helper_gshutdown(void)
9499
{
95100
pefree(_mgr.socket_path, 1);
96101
pefree(_mgr.lock_path, 1);
97-
if (_shared_state) {
98-
munmap(_shared_state, sizeof(dd_helper_shared_state));
99-
}
100102
}
101103

102104
void dd_helper_rshutdown(void)

0 commit comments

Comments
 (0)