Skip to content

Fix Memory Leaks in IPP Crypto ML-DSA Implementation#112

Closed
iMartyan wants to merge 1 commit into
smuellerDD:masterfrom
iMartyan:master
Closed

Fix Memory Leaks in IPP Crypto ML-DSA Implementation#112
iMartyan wants to merge 1 commit into
smuellerDD:masterfrom
iMartyan:master

Conversation

@iMartyan
Copy link
Copy Markdown
Contributor

@iMartyan iMartyan commented May 5, 2026

I've fixed some memory leaks in the ML-DSA part of the IPP Crypto backend. Thanks @smuellerDD for pointing that out!

The issue was that several alloc_buf calls didn't have matching free_buf calls in the error paths. I’ve updated keygen, siggen, and the internal keygen helper to ensure all temporary and output buffers are properly cleaned up if something fails.

@smuellerDD
Copy link
Copy Markdown
Owner

Are you sure about that? Why are you freeing memory only in error code path? The memory is only needed local to the function, no?

@iMartyan
Copy link
Copy Markdown
Contributor Author

The buffers (data->pk, data->sk, data->sig) are output parameters, not local scratch space. They are passed back to the caller, which assumes ownership of the memory and frees it after serialization (e.g., in vector_free_entry for JSON or proto_ml_dsa_keygen_tester for protobuf). Freeing them unconditionally here would cause a use-after-free for the caller. They are only freed in the error path to prevent leaking partially allocated output buffers if a failure occurs before the function completes.

Are you sure about that? Why are you freeing memory only in error code path? The memory is only needed local to the function, no?

@smuellerDD
Copy link
Copy Markdown
Owner

Applied, thanks.

@smuellerDD smuellerDD closed this May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants