-
Notifications
You must be signed in to change notification settings - Fork 103
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
TLS: Memory corruption #1217
Comments
Blame |
It turns out that thanks to the in-place implementation of TLS, we encrypt data pages without allocating additional memory and copying, but because sendfile links the socket with the file cache, we overwrite the file cache. If several clients request the same file, we will overwrite it in different places at once and each client will receive a unique file. Then the problem can be reproduced not only with the help of sendfile. If the file is given from the cache, then the result will be the same. When sending from our cache, we reuse the pages of memory from the cache. |
@avb good catch - this the fundamental problem of out TLS encryption! The fix should be straightforward enough - we need to copy skb data before encryption if an skb is formed from splice() (sendfile() for file cache or splice() for user-space buffer, but the core is the same) or our web cache. We do something similar in |
Also note, that only payload part of the response served from cache reuses pages. The headers are created from scratch for every new response. Same can happen to Probably the copying of skb data should be configurable option:
|
We have #634 to reuse HTTP response headers kept in cache. For current kernel there is only one zero-copy transmission mechanism - |
Please also don’t forget to backport the fix to 0.6. |
Tempesta config:
Log sh:
The text was updated successfully, but these errors were encountered: