Skip to content

[NativeAOT] Randomizing guard stack cookie not supported on some Unix platforms #73695

Closed

Description

@TheSpydog

The Unix NativeAOT startup code includes a step where it randomizes the guard stack cookie that's baked into the binary's .rodata section. On multiple Unix-based game console platforms, this results in a runtime error because the .rodata section can never have its memory access permissions set to anything other than ReadOnly (presumably for security reasons).

It would be ideal if the InitGSCookie call were guarded by a feature define of some sort (FEATURE_RANDOMIZED_GS_COOKIES?) so that console ports don't have to have their own startup.cpp implementation just to work around this one feature.

Activity

  1. ghost added
    untriaged
    on Aug 10, 2022
  2. MichalStrehovsky commented on Aug 11, 2022

    @MichalStrehovsky
    Member

    It would be ideal if the InitGSCookie call were guarded by a feature define of some sort (FEATURE_RANDOMIZED_GS_COOKIES?) so that console ports don't have to have their own startup.cpp implementation just to work around this one feature.

    Sounds like a good plan. Would you be able to submit a PR?

  3. added this to the Future milestone on Aug 11, 2022
  4. added
    help wanted
    and removed
    untriaged
    on Aug 11, 2022
  5. TheSpydog commented on Aug 11, 2022

    @TheSpydog
    ContributorAuthor

    Sure thing. One question -- if this feature is not defined, should the cookie still be set to 0 by default, or should we give it a different value?

  6. MichalStrehovsky commented on Aug 11, 2022

    @MichalStrehovsky
    Member

    If the cookies are not random, an attacker can craft a stack corruption with a matching cookie, bypassing the stack guard. I don't think it matters if the value is 0 or 42. It can be kept at 0 to keep things simple.

  7. ghost added
    in-pr
    on Aug 11, 2022
  8. ghost removed
    in-pr
    on Aug 12, 2022
  9. ghost locked as resolved and limited conversation to collaborators on Sep 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-NativeAOT-coreclrhelp wanted

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions