Repository navigation
Conversation
|
Member
Author
|
Jenkins retest this please |
julek-wolfssl
requested changes
Oct 21, 2026
Frauschi
force-pushed
the
tls_mem_2
branch
4 times, most recently
from
October 21, 2026 19:40
a67e3bb to
8aafcde
Compare
Member
Author
|
Jenkins retest this please |
julek-wolfssl
requested changes
Oct 22, 2026
julek-wolfssl
previously approved these changes
Oct 22, 2026
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11756
Scan targets checked: wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): tests/api/test_tls_ext.h
Coverage: 2 of 5 in-scope changed file(s) opened by the reviewer; not opened: tests/api.c, tests/api/test_tls_ext.c, wolfssl/internal.h
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Lite
Contributor
|
tests good, just rebase please to be safe |
The supported groups extension stored its named groups as a linked list with one node per two byte group identifier. A client advertising 16 groups made 16 allocations for 32 bytes of wire data, and a server made a second set of nodes for the intersection with the client's list. Every insert also walked the list to check for a duplicate. Replace the list with a single block holding a count, a capacity and a flat array of names. The block starts with room for WOLFSSL_MAX_GROUP_COUNT names, the most wolfSSL_set_groups() accepts, so a handshake makes one allocation per list; it doubles only for a peer that sends more. Inserts and lookups index the array instead of chasing pointers, and freeing the extension is a single XFREE.
A server with its own supported groups list built a second list holding the groups it has in common with the client, swapped that into the extension and freed the original. Now that the groups are a flat array, the common ones are moved to the front of the server's own list instead, so the intersection needs no allocation. The kept groups stay in the client's order, as before. A name that has already been moved sits outside the range still searched, so a group repeated in the client list is added once. Adds a test for the resulting list and for the TLS 1.2 handshake failure when no group is common.
Before sending EncryptedExtensions a TLS 1.3 server checked whether the client offered the group the server prefers most. It answered that by populating a whole temporary extension list with every group this build offers, reading the first name out of it, and freeing the list again. The TLS 1.2 FFDHE selection did the same to find the highest priority group both sides have. Both cost a TLSX node, a groups block and a walk of the full preference chain on every handshake. Turn the preference chain into TLSX_WalkSupportedGroups(), which calls a callback for each group in the same order. Populating an extension list is now one caller of the walk, finding the preferred group is another that stops at the first group, and the FFDHE selection is a third that stops at the first group the client also has. The server builds a list only in the case that sends it back to the client.
Walk the groups with TLSX_NextSupportedGroup(), an index into the existing preferredGroup[] table filtered at run time, instead of a callback per group. Populating the extension, CheckPriority() and the FFDHE selection now loop over it directly. The FFDHE selection is back to master's shape: find the group in the loop and set it once afterwards. The table now decides the ML-KEM groups per side for the walk as it already did for the key share ranking, which only differs in encapsulate-only server builds. Build the server's intersection in a separate list instead of moving names around inside its own one, and swap it in only on success, so an error leaves the list as it was. The list is allocated once with room for the shorter of the two lists plus one, where master made one allocation per common group. It is not capped: after an HRR the second ClientHello is intersected with the client's whole list from the first, which can be longer than WOLFSSL_MAX_GROUP_COUNT. Only the first unsupported FFDHE codepoint is kept, since TLSX_SupportedFFDHE_Set() only needs to see one. Grow a live list with XREALLOC, keeping malloc and copy for builds without it, such as FreeRTOS without OPENSSL_EXTRA. A new list still comes from XMALLOC: the uITRON4 and uT-Kernel reallocs return NULL for a NULL pointer, and with no realloc callback installed wolfSSL_Realloc() falls back to the native one. The first allocation now holds the larger of WOLFSSL_MAX_GROUP_COUNT and the build's default group table, plus the three old hybrid codepoints when WOLFSSL_ML_KEM_USE_OLD_IDS adds them, so a default list no longer grows in builds with many groups but no ML-KEM, where WOLFSSL_MAX_GROUP_COUNT is only 10. TLSX_SupportedCurve_Copy() makes one allocation and copy instead of re-adding every group. Append through a typed local rather than casting &extension->data, which GCC flags with -Wstrict-aliasing=2. Drop two casts and some comments. Adds tests for an intersection longer than WOLFSSL_MAX_GROUP_COUNT, for the list surviving a failed allocation or a failed grow, for creating a list when realloc always fails, and for which brainpool and ML-KEM groups the default list holds for TLS 1.2, TLS 1.3 and version-flexible clients.
The comment in the server's intersection loop pointed back at the one in the parse loop. State the RFC 7919 Section 4 requirement directly instead.
Contributor
|
Retest this please. (generic config PRB timeout or something) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The supported groups extension used one heap node per group, on both client and server, and a TLS 1.3 server built and freed a full throwaway list on every handshake. Part of the TLS extension memory series (after #11353, #11345, #11342 and #11343; #11730 is still open).
WOLFSSL_MAX_GROUP_COUNT(thewolfSSL_set_groups()limit) and the build's default group table, so a default orset_groups()list takes one allocation; a longer one, such as a peer's, grows withXREALLOC.TLSX_NextSupportedGroup()returns this build's groups in preference order from the existingpreferredGroup[]table, soTLSX_SupportedCurve_CheckPriority()andTLSX_SupportedFFDHE_Set()no longer allocate.No public API or wire changes. An encapsulate-only ML-KEM server now ranks the hybrid groups first in its default list, as the key share ranking already did.
TLSX_SupportedCurve_CheckPriority()andTLSX_SupportedFFDHE_Set()becomeWOLFSSL_TEST_VIS.One in-memory TLS 1.3 handshake on macOS (arm64, static library), client and server allocations combined, counted from
wolfSSL_new():--enable-all