-
Notifications
You must be signed in to change notification settings - Fork 291
Nginx Restart with loaded module cause segfaults (maybe problem for ModSec v3 and not connector itself) #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello @md2k, could you please provide full nginx configuration (in recent versions it can be obtained by running Thanks. |
I can semi-confirm this bug! Have already posted it in the modsec_dev list. And also after updating the source from 12.12.16 - 27.01.17 the shared-collections are in / root@waf-1-a-02:~# ls -la /etc/nginx/modsec/ root@waf-1-a-02:~# ls -la / I'm running latest N+ and build MS3 from source, not the N+ module. |
I could also send you a nginx -T directly if you like cause it's very huge and sensible |
@defanator i can send it, but it also big for me and and obfuscation will take some time (for nginx). |
@md2k we can start from backtraces then. |
@mimugmail if you're using N+, I would suggest to address this via N+ support channel. You can share backtraces here though. |
It will be helpful if you can tell me how i can get backtrace from modsec/nginx |
@defanator Since I'm not using the commercial WAF module I don't think that we can expect much support from N+, also I don't want to keep these guys rotating (was a promise to OwenGarret@Nginx) :) I'll try to make a detailed bug report |
@md2k you need to obtain core file and then use GDB to get output of the https://www.nginx.com/resources/admin-guide/debug/ |
Thank, will check them later, going to prepare virtual box for this to not mess with my production server |
OS: Debian 8 Backtrace full: nginx -T: root@nginx:~# /opt/nginx/sbin/nginx -T configuration file /opt/nginx//conf/nginx.conf:#user nobody; worker_rlimit_core 500M; #error_log logs/error.log; pid logs/nginx.pid; load_module "modules/ngx_http_modsecurity_module.so"; events { http {
} configuration file /opt/nginx//conf/mime.types:types {
} This is just a development machine, non-productive! Installed like in: |
This is what nginx error logs throws after reload: 2017/02/04 22:03:11 [notice] 576#0: signal process started @md2k What distro do you use? |
This is my last one ... also installed it with CentOS7 and also got the segfault. |
@mimugmail, thanks for the backtrace! It seems like the issue you're observing is related to a number of other issues we've been also facing. Latest attempt to provide a fix was made here: owasp-modsecurity/ModSecurity#1306 (though there's a number of questions to that PR). Tagging @zimmerle here - this is related to the libmodsecurity itself, not just the connector. @md2k, were you able to grab a core and obtain a backtrace from it? |
@defanator @zimmerle Hope you will find this one :) @md2k install gdb packet, compile nginx --with-debug and add the stuff in the links @defanator added here. Then start nginx, reload it, then the segfault comes but there's no core, after that type a killall nginx and now there's the coredump int /tmp. Then type "gdb /opt/nginx/sbin/nginx /tmp/core" and "backtrace full" |
@mimugmail thanks. @defanator most probably i will have time to deal with it next week due my main project workload. |
As @zimmerle told me to disable lmdb in another issue I tried it on this one, but --without-lmdb I also get a segfault here. |
Hi @defanator , as you asked, in Gist output of |
Thanks @md2k. |
@defanator i added 2 more backtraces to same gist as |
Hi, The problem was related to shared memory. The first design was meant to be used by forked processes. In the forked process, the address space and file descriptor will be common in every forked-process (worker). The reload (in this case ./nginx -t) creates a new process, leading to different file descriptors and consequently a segfault. The segfault seems to be resolved, although I have faced `zombie' processes while stressing the implementation. Do you guys mind to test? Those are the commits: SharedFile class: To use the SharedFile class within the DebugLogs: The are available on the branch dev/parser: Thank you guys, and sorry for the huge delay. |
Thanks @zimmerle for fixing this! I can confirm that with dev parser branch I can cleanly compile and reload the process. BUT, now when I start nginx it looks like this: root@nginx: Also when reloading there are these asterisks. The performance like in the other issue is also not better than before, will post my results there. Thank you! |
Hello, Same that @mimugmail with the last release (thanks for the update @zimmerle ) on check of status of nginx
|
@zimmerle I've just tested libmodsecurity from the current head of v3/dev/parser, and can confirm that nginx is not segfaulting anymore. Then I realized that I've been running nginx with older connector module, built with libmodsecurity v3/master. I tried to rebuild it with v3/dev/parser code and got the following:
Are there any plans to merge v3/dev/parser to v3/master, or cherry pick a set of changes affecting the logging part, so we could adjust nginx connector code here? |
v3/dev/parser is now part of v3/master ;) Thank you for the reports ;) |
I got this error too
What I am doing wrong or how do I fix it? Thanks. |
Hi @hernandanielg, Please upgrade both: ModSecurity and ModSecurity-nginx connector |
Worked like a charm :) thanks! |
I am having this issue now; details here: owasp-modsecurity/ModSecurity#1318 (comment) any thoughts? |
Hi Devs, i noticed that latest master of connector (maybe issue not in connector exactly) causing nginx segfaults during its restart.
Reload or Stop then Start do not cause such segfaults.
Also by default files for shared collection dropped to root folder '/'
But, during restart Nginx with init/init.d scripts those files created in directory where cli command was used.
The text was updated successfully, but these errors were encountered: