Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could non-executable heap be a compile time error? (IDFGH-14014) #14837

Open
projectgus opened this issue Nov 6, 2024 · 1 comment
Open

Could non-executable heap be a compile time error? (IDFGH-14014) #14837

projectgus opened this issue Nov 6, 2024 · 1 comment
Assignees
Labels
Status: Reviewing Issue is being reviewed Type: Feature Request Feature request for IDF

Comments

@projectgus
Copy link
Contributor

projectgus commented Nov 6, 2024

Is your feature request related to a problem?

(This feature request relates to bug reports #14835 and #14836)

Most default ESP-IDF configurations no longer support executable heap:

  • ESP_SYSTEM_MEMPROT_FEATURE is enabled by default on supported ESP32-S2,S3, probably others.
  • ESP_SYSTEM_PMP_IDRAM_SPLIT is enabled by default on ESP32-C6, maybe others.

In both cases heap_caps_malloc(n, MALLOC_CAP_EXEC) is not expected to succeed.

This is fine and good, Writable XOR Executable memory access is a very sensible default for security.

Describe the solution you'd like.

From my perspective as a programmer trying to get executable memory[^], it'd be nice to get this failure at compile time instead of runtime, i.e. If config does not allow executable heap then don't define the MALLOC_CAP_EXEC flag.

[^] For MicroPython native code modules.

Describe alternatives you've considered.

Alternative is the current behaviour: get back a NULL pointer at runtime (unless there's a bug), and then realise you need to change the config yourself.

Additional context.

I guess this is probably a breaking API change, so maybe one for IDF 6?

@projectgus projectgus added the Type: Feature Request Feature request for IDF label Nov 6, 2024
@github-actions github-actions bot changed the title Could non-executable heap be a compile time error? Could non-executable heap be a compile time error? (IDFGH-14014) Nov 6, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Nov 6, 2024
@espressif-bot espressif-bot added Status: Reviewing Issue is being reviewed and removed Status: Opened Issue is new labels Nov 11, 2024
@SoucheSouche
Copy link
Collaborator

Hi @projectgus, I created an MR to make MALLOC_CAP_EXEC definition conditional.
It was reviewed, but since it represents a breaking change, it will be most likely merged for 6.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Reviewing Issue is being reviewed Type: Feature Request Feature request for IDF
Projects
None yet
Development

No branches or pull requests

3 participants