-
Notifications
You must be signed in to change notification settings - Fork 428
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
ejabberd_zlib_drv: avoid overflow when OOM #1134
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @msantos! I have 2 questions:
- Could you describe briefly when does this help and how is it suppose to behave in case of OOM?
- See the question in code.
@@ -42,6 +42,40 @@ typedef struct { | |||
z_stream *i_stream; | |||
} ejabberd_zlib_data; | |||
|
|||
/* Wrappers around driver_alloc() that check */ | |||
/* for OOM. */ | |||
void erl_exit(int n, char* v, ...) { abort(); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if abort
is the best choice here. How about driver_failure
?
I can add this check in another PR if wanted. driver_failure() is reasonable if the system will deal gracefully with having the zlib driver unloaded in a running system. Calling erts_exit() follows what the erlang inet driver does in OOM conditions.
|
Thanks for the explanation, now I understand your work better. Did run into the issue on your system? Is it somehow connected to ZLib bomb attack? https://en.wikipedia.org/wiki/Zip_bomb. |
Just from reading the code, however a zip bomb would be a good way of
triggering it.
…On Jan 2, 2017 7:42 PM, "Michał Piotrowski" ***@***.***> wrote:
Thanks for the explanation, now I understand your work better. Did run
into the issue on your system? Is it somehow connected to ZLib bomb attack?
https://en.wikipedia.org/wiki/Zip_bomb.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1134 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAJpa9IZiCL25tKVRgZ0nhwiofUUEK7wks5rOOK0gaJpZM4LVK3J>
.
|
Regarding the zlib bomb, we are already trying to prevent such an attack. Take a look at the |
Yes, that option is a great way of preventing zip bombs. Unfortunately there are many ways to force a system to run out of memory. Checking for memory allocation failure prevents undefined behaviour in case of error. |
Right, I have only one issue with it - stopping the entire VM. Maybe, it would be ok, to just stop the port driver and linked ejabberd_c2s process, so only one user is affected. This should free some memory also. |
Assuming the inet or fast_tls drivers don't stop the VM first, the behaviour today is:
So it may be possible to unload the driver and have a functioning system but the next call into the network may force the VM to abort anyway (and hopefully be restarted by heart). If we decide to go with driver_failure(), it will be difficult to simulate an OOM condition to test if everything continues to work. One idea might be to add a "fail" command to the driver that simply returns driver_failure() to force the driver to unload during the test run. |
Ok, this sounds reasonable. Thanks for explanations and your contribution. |
One more thing. Could you create another PR regarding the Erlang version check?
|
Set CFLAGS in rebar.config.script based on the emulator version as discussed in: esl#1134
Set CFLAGS in rebar.config.script based on the emulator version as discussed in: esl#1134
No description provided.