[sr-dev] [kamailio/kamailio] ndb_redis: fix SIGSEGV in redisc_check_auth (#2834)

Dennis notifications at github.com
Tue Aug 24 16:40:22 CEST 2021


Hi !

This issue appears when ndb_redis module connect to redis via proxy, in my case haproxy.
Haproxy keeps front socket always open, when all backend redis servers become unavailable, haproxy just send RST to front,
redisCommand function in tis case return NULL poiner, redisc_check_auth try to dereference it without NULL checking.

kamailio log:
`kernel: [7250430.508827] kamailio[21749]: segfault at 0 ip 00007f00d7bb106f sp 00007fffc523c620 error 4 in ndb_redis.so[7f00d7b94000+36000]`

gdb:
```
# gdb /usr/sbin/kamailio core
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/sbin/kamailio...(no debugging symbols found)...done.
[New LWP 21752]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/usr/sbin/kamailio -P /run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.cfg'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f00d7bb106f in redisc_check_auth () from /usr/lib64/kamailio/modules/ndb_redis.so
(gdb) bt
#0  0x00007f00d7bb106f in redisc_check_auth () from /usr/lib64/kamailio/modules/ndb_redis.so
#1  0x00007f00d7b9937a in redisc_init () from /usr/lib64/kamailio/modules/ndb_redis.so
#2  0x00007f00d7bb4300 in print_redis_reply () from /usr/lib64/kamailio/modules/ndb_redis.so
#3  0x0000561825796935 in ?? ()
#4  0x0000561825796550 in ?? ()
#5  0x0000561825796550 in ?? ()
#6  0x0000561825796550 in ?? ()
#7  0x0000561825796550 in ?? ()
#8  0x0000561825796550 in ?? ()
#9  0x0000561825796550 in ?? ()
#10 0x0000561825796550 in ?? ()
#11 0x0000561825796550 in ?? ()
#12 0x0000561825796550 in ?? ()
#13 0x0000561825796550 in ?? ()
#14 0x0000561825796550 in ?? ()
#15 0x0000561825796550 in ?? ()
#16 0x0000561825796550 in ?? ()
#17 0x000056182579722c in init_child ()
#18 0x00005618256f4520 in fork_process ()
#19 0x00005618255cfbf3 in main_loop ()
#20 0x00005618255dd095 in main ()
```


<!-- 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
- [ ] Commits are split per component (core, individual modules, libs, utils, ...)
- [ ] Each component has a single commit (if not, squash them into one commit)
- [ ] 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
- [ ] 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 -->
- [ ] 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 -->

You can view, comment on, or merge this pull request online at:

  https://github.com/kamailio/kamailio/pull/2834

-- Commit Summary --

  * ndb_redis: fix SIGSEGV in redisc_check_auth

-- File Changes --

    M src/modules/ndb_redis/redis_client.c (4)

-- Patch Links --

https://github.com/kamailio/kamailio/pull/2834.patch
https://github.com/kamailio/kamailio/pull/2834.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/2834
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20210824/d3ce5501/attachment-0001.htm>


More information about the sr-dev mailing list