<!-- Kamailio Pull Request Template -->
<!--
IMPORTANT:
- for detailed contributing guidelines, read:
https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md
- pull requests must be done to master branch, unless they are backports
of fixes from master branch to a stable branch
- backports to stable branches must be done with 'git cherry-pick -x ...'
- code is contributed under BSD for core and main components (tm, sl, auth, tls)
- code is contributed GPLv2 or a compatible license for the other components
- GPL code is contributed with OpenSSL licensing exception
-->
#### Pre-Submission Checklist
<!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply -->
<!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above-->
<!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list -->
- [x] Commit message has the format required by CONTRIBUTING guide
- [x] Commits are split per component (core, individual modules, libs, utils, ...)
- [x] Each component has a single commit (if not, squash them into one commit)
- [x] No commits to README files for modules (changes must be done to docbook files
in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change
- [x] Small bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist:
<!-- Go over all points below, and after creating the PR, tick the checkboxes that apply -->
- [x] PR should be backported to stable branches
- [ ] Tested changes locally
- [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description
<!-- Describe your changes in detail -->
Preloaded library to make libssl 1.1 use pthread locks with process shared option.
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/1927
-- Commit Summary --
* tls: add preloaded library to force process-shared locks
* tls: added a readme for openssl_mutex_shared
* tls: docs - short note about libssl 1.1.x and openssl_mutex_shared
-- File Changes --
M src/modules/tls/Makefile (2)
M src/modules/tls/doc/tls.xml (5)
A src/modules/tls/utils/openssl_mutex_shared/Makefile (26)
A src/modules/tls/utils/openssl_mutex_shared/README.md (53)
A src/modules/tls/utils/openssl_mutex_shared/openssl_mutex_shared.c (46)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/1927.patchhttps://github.com/kamailio/kamailio/pull/1927.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/1927
Hi,
(X-posted to sr-dev as this is getting into the nitty gritty)
As a short-term workaround for this, I've been playing with the
preloaded library approach to hijack the pthread mutex calls and force
them to provide process-shared mutexes. AFAICT this seems to be working
and only has the minuscule performance impact of using slower
process-shared mutexes in all instances, even when they aren't required.
The code for the preloaded library itself is very short and simple:
https://gist.github.com/rfuchs/1bb7348b6acbe37e557d94c2f69a1498
As a more complete patch that integrates it into the build system
(probably badly):
https://gist.github.com/rfuchs/b240ffe87938a45e6f2a4cf53fe29f17
Finally it requires adding it to the startup script, for example in a
systemd service file as:
Environment='LD_PRELOAD=/usr/lib/x86_64-linux-gnu/kamailio/openssl_mutex_shared/openssl_mutex_shared.so'
(that's with a hard coded path which isn't optimal of course).
I don't consider this a proper fix, but only a hacky workaround, but it
might be a solution for the very near future. Throwing it out there in
case other people have been working on similar approaches, and/or maybe
have some comments about this.
Cheers
On 01/04/2019 04.52, Daniel-Constantin Mierla wrote:
> Hello,
>
> an update on this issue -- I spent a bit of time looking at
> libssl/libcrypto library and the problem can be the type of mutexes they
> use now internally starting with v1.1, respectively the pthread mutex.
> They are not process shared and kamailio is a multi-process application,
> working with the same tls connection from multiple processes.
>
> Today I wrote to openssl mailing list, waiting now to see if I get any
> hints from there.
>
> Cheers,
> Daniel
>
> On 01.04.19 10:33, Kristijan Vrban wrote:
>> Hi Andrew,
>>
>> yes, with openssl 1.0.2 Kamailio is now up and running since five
>> days. Looks good so far.
>>
>> Kristijan
>>
>> Am Do., 28. März 2019 um 11:09 Uhr schrieb Andrew Pogrebennyk
>> <apogrebennyk(a)sipwise.com>:
>>> On 3/26/19 3:52 PM, Kristijan Vrban wrote:
>>>>> Just curious, did you get to compile with OpenSSL 1.0 and test?
>>>> Just compiled with OpenSSL 1.0 . Gone test now.
>>> Kristijan,
>>> any new occurrences since you have recompiled kamailio with openssl 1.0?
>>>
>>> Regards,
>>> Andrew
>> _______________________________________________
>> Kamailio (SER) - Users Mailing List
>> sr-users(a)lists.kamailio.org
>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Module: kamailio
Branch: master
Commit: 387533b04f7bf6d8b1e4e90d38f462639ba03ee2
URL: https://github.com/kamailio/kamailio/commit/387533b04f7bf6d8b1e4e90d38f4626…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-04-15T08:52:24+02:00
tls: openssl_mutex_shared - note about ability to be used independent of Kamailio
---
Modified: src/modules/tls/utils/openssl_mutex_shared/README.md
---
Diff: https://github.com/kamailio/kamailio/commit/387533b04f7bf6d8b1e4e90d38f4626…
Patch: https://github.com/kamailio/kamailio/commit/387533b04f7bf6d8b1e4e90d38f4626…
---
diff --git a/src/modules/tls/utils/openssl_mutex_shared/README.md b/src/modules/tls/utils/openssl_mutex_shared/README.md
index 9f2e9c57e3..e446d66f72 100644
--- a/src/modules/tls/utils/openssl_mutex_shared/README.md
+++ b/src/modules/tls/utils/openssl_mutex_shared/README.md
@@ -34,6 +34,11 @@ For Debian packing, the location is like:
/usr/lib/x86_64-linux-gnu/kamailio/openssl_mutex_shared/openssl_mutex_shared.so
```
+Note: there is no dependency on Kamailio source code, this shared object can
+be compiled and used ouside of Kamailio source tree. It uses only Kamailio's
+Makefile system to install in the same directory like the other shared objects
+installed by Kamailio.
+
## Usage ##
Use LD_PRELOAD to tell the linker to preload this shared object before starting
Module: kamailio
Branch: master
Commit: 84002ae99524bdb2aba4c724a86074f88bea1ffe
URL: https://github.com/kamailio/kamailio/commit/84002ae99524bdb2aba4c724a86074f…
Author: Kamailio Dev <kamailio.dev(a)kamailio.org>
Committer: Kamailio Dev <kamailio.dev(a)kamailio.org>
Date: 2019-04-15T08:46:56+02:00
modules: readme files regenerated - tls ... [skip ci]
---
Modified: src/modules/tls/README
---
Diff: https://github.com/kamailio/kamailio/commit/84002ae99524bdb2aba4c724a86074f…
Patch: https://github.com/kamailio/kamailio/commit/84002ae99524bdb2aba4c724a86074f…
---
diff --git a/src/modules/tls/README b/src/modules/tls/README
index a94c179dac..4b724210cb 100644
--- a/src/modules/tls/README
+++ b/src/modules/tls/README
@@ -273,6 +273,10 @@ request_route {
options, run kamailio -V and look for USE_TLS and TLS_HOOKS among the
flags.
+ For OpenSSL (libssl) v1.1.x, it is required to preload
+ 'openssl_mutex_shared' library shipped by Kamailio. For more details
+ see 'src/modules/tls/openssl_mutex_shared/README.md'.
+
This module includes several workarounds for various Openssl bugs (like
compression and Kerberos using the wrong memory allocations functions,
low memory problems a.s.o). On startup it will try to enable the needed