-
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
Incorrect restoring of responces from chunked cache entries #803
Comments
Note the #804 issue describing unit tests for this issue. |
It's better to fix this after #515 which will affect caching a lot. |
22 tasks
krizhanovsky
changed the title
[Cache] Incorrect restoring of responces from chunked cache entries
Incorrect restoring of responces from chunked cache entries
Mar 16, 2020
krizhanovsky
modified the milestones:
0.9 QUIC & Advanced DDoS mitigation - Beta,
0.8 TLS 1.3 & TDBv0.2
Apr 27, 2020
krizhanovsky
modified the milestones:
0.8 TLS 1.3 & TDBv0.2 - Beta,
0.7 HTTP/2 & TLS performance,
0.7 - HTTP/2, fast in-kernel TLS,
0.10 - TDBv0.2
Jan 3, 2022
krizhanovsky
modified the milestones:
0.8 - Beta: TDBv0.2 & web cache eviction,
0.7 - HTTP/2, fast in-kernel TLS
Jan 10, 2023
Fixed by #1831 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Applicable to saving and restoring responses from chunked cache entry. There is a situation when
TfwCStr
header can't be fit into the rest of current data chunk (TdbVRec
). In this caseTfwCStr
will be saved into the next record. This condition is handled intfw_cache_copy_hdr()
:tempesta/tempesta_fw/cache.c
Line 686 in 65d9723
The
tfw_cache_copy_hdr()
has also an optimization in order not to split shortTfwCStr
:tempesta/tempesta_fw/cache.c
Lines 675 to 678 in 65d9723
But there is a couple of issues, when restoring responses from a cache entry. First of all optimization above is ignored. So if a response is written to cache with at least one such optimisation we can expect crash or serving corrupted response.
Secondly, crash will happen in
tfw_cache_build_resp_hdr()
ifTfwCstr
of the next header couldn't fit the rest of the current chunk and was placed into the next one:tempesta/tempesta_fw/cache.c
Lines 1019 to 1020 in 65d9723
To fix both issues we need to add a function to adjust current pointer in the current data chunk before reading
TfwCStr
similarly totdb_entry_get_room()
which is used before writing. And use the function any time we are reading aTfwCStr
. To make function aware of optimization above, we need to write a paddingTfwCStr
header with flagSKIP_REC_TAIL
set every time when the optimization is used. The flag will help us understand that the rest of data chunk doesn't contain any data and must be skipped.tdb_entry_get_room()
must write this paddingTfwCStr
header.The text was updated successfully, but these errors were encountered: