Skip to content

control stack memory allocation #521

@vladak

Description

@vladak

The C functions produced by Karamel do not constrain memory allocation as far as I know. For example, the Hacl_P521.c file produced by HACL and used by Mozilla NSS contains various large stack allocations. In my environment, the resulting x64 object file contains multi-kilobyte sized stack allocations (e.g. the p521_qinv() function requests ~7.6 kibibytes) and the default maximum stack size in this environment is 20 KiB and cannot be changed on the fly. Running the HACL ECC code (e.g. ECDSA verify operation) in such environment leads to stack exhaustion.

Ideally, it would be nice to be able to switch to heap based allocation above given threshold, where possible. This would require the corresponding freeing of the resources, however looking at the biggest stack space consumers in the above referenced file this is doable, at least in some of the places. Not sure about the side channels.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions