bneradt commented on PR #13809:
URL: https://github.com/apache/trafficserver/pull/13809#issuecomment-6636173494

   @maskit, @bryancall: thanks, both are addressed in two new commits at the 
end of the branch, rebased on master. Head is 1e4ba0aa78.
   
   **No allocation in the common handshake** (3d20e0efb9, "Keep raw ClientHello 
extension types off the heap")
   
   - `parse_client_hello_extension_types()` now validates the whole message, 
writes the first `types.size()` extension types into a caller-provided 
`std::span`, and returns the total count. It returns `std::nullopt` if the 
message is malformed.
   - `on_client_hello_message()` parses into a fixed `std::array` of 32, the 
same `MAX_EXTENSIONS_FOR_FAST_PATH` that `ja4/tls_client_hello_summary.h` uses. 
Only when the count is more than 32 does it allocate an exact-size 
`std::unique_ptr<int[]>` and parse a second time into it. So the common path 
makes one pass and no allocation, and the list still has no cap.
   - `_clear()`, `bind()`, and the start of each `on_client_hello_message()` 
all release the heap fallback through `_reset_raw_extension_types()`.
   - The element type is `int`, not `uint16_t` as in the jax summary. On 
OpenSSL, `ExtensionIdIterator` walks an `int *` because that is what 
`SSL_client_hello_get1_extensions_present()` returns. Supporting a second 
element type would need a second pointer in the iterator, and 
`TSClientHello::TSExtensionTypeList::Iterator` reserves only 24 bytes for it. 
The `static_assert` in `InkAPI.cc` caught that, so the iterator and the public 
API are unchanged.
   - There is also a new unit test that passes a buffer shorter than the 
extension count and checks that the count is still right.
   
   **Recycle test** (1e4ba0aa78, "Test that _clear() releases the raw extension 
list")
   
   This is Bryan's `RecycledTLSSNISupport` test as written: 40 extensions, so 
it goes through the heap fallback. I checked it under ASan with 
`ENABLE_ASAN=ON`, Fedora 44, OpenSSL 3:
   
   | `_clear()` | `test_net '[TLSSNISupport]'` |
   |---|---|
   | calls `_reset_raw_extension_types()` (this PR) | all 7 cases pass, no 
leaks |
   | clears only the pointer and count, leaving the heap buffer | 
`LeakSanitizer: 640 byte(s) leaked in 4 allocation(s)` from 
`on_client_hello_message()` |
   
   **Local runs at 1e4ba0aa78** (ASan build): all 97 `test_net` ctest cases 
pass. 75 urtests matching `jax_fingerprint or ja4 or ja3 or client_hello or 
tls_hooks or sni` pass, including `test_jax_fingerprint_raw_extensions`.
   
   The docs only describe what `get_extension_types()` returns, which hasn't 
changed, so they needed no edits.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to