Skip to content

Conversation

@hanno-becker
Copy link
Contributor

@hanno-becker hanno-becker commented Dec 24, 2025

The default implementation of MLD_ALLOC and MLD_FREE uses stack
allocation, which the compiler can assume not to fail. This means
that CBMC does not exercise the cleanup paths which handle fallible
dynamic allocation -- a significant proof gap.

This commit changes the configuration uses for the CBMC proofs
to use the (instrumented) calls to malloc/free for MLD_ALLOC/MLD_FREE.

Importantly, we set --malloc-may-fail to model allocation as fallible,
and --malloc-fail-null to return NULL in case of allocation failure.

@hanno-becker hanno-becker requested a review from a team as a code owner December 24, 2025 04:40
@hanno-becker hanno-becker force-pushed the alloc_cbmc branch 4 times, most recently from 20a9d4e to f03a619 Compare December 24, 2025 07:21
@mkannwischer mkannwischer self-assigned this Dec 28, 2025
Copy link
Contributor

@mkannwischer mkannwischer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hanno-becker. The changes itself look good to me, but CBMC fails due to timeouts. Marking as draft until we can resolve that.

@mkannwischer mkannwischer marked this pull request as draft December 29, 2025 02:40
This commit replaces multiple successive allocations from
MLD_ALLOC by a single allocation of a suitable 'workspace'
structure.

This reduces the number of allocations as well as the number
of exit paths, thereby reducing the complexity of CBMC proofs.
It also unifies the zeroization at the end of each function.

Signed-off-by: Hanno Becker <[email protected]>
The default implementation of MLD_ALLOC and MLD_FREE uses stack
allocation, which the compiler can assume not to fail. This means
that CBMC does not exercise the cleanup paths which handle fallible
dynamic allocation -- a significant proof gap.

This commit changes the configuration uses for the CBMC proofs
to use the (instrumented) calls to malloc/free for MLD_ALLOC/MLD_FREE.

Importantly, we set --malloc-may-fail to model allocation as fallible,
and --malloc-fail-null to return NULL in case of allocation failure.

Signed-off-by: Hanno Becker <[email protected]>
Signed-off-by: Hanno Becker <[email protected]>
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.

3 participants