8000 Potential stack corruption when using AVX512 · Issue #69 · miniosv/miniosv · GitHub
[go: up one dir, main page]

Skip to content

Potential stack corruption when using AVX512 #69

Open

Description

@Meandres

I encountered a potential bug when trying to merge upstream changes into our fork.

PR#58 (#58) introduced AVX512, which increases the size of the FPU state that the kernel has to manage.
miniosv handles this via the fpu_lock constructs which save/restore FPU state on entry/exit from interrupts.
This PR also correctly raised the interrupt stack size to 0x2000 to make space for this larger FPU state.

However, page faults happen in another stack (arch_thread::exception_stack). If the page fault handler is deep, this can lead to stack overflow.
This was not caught because we don't really have a test for page-fault-heavy scenarios in the mainline (yet 👀 #47).

I created a PR (#68) with a temporary fix (in my tests, moving from 16KiB to 32KiB solves the problem) but this might break again if we have very deep handler stack (network on the fault path 👀) so we will probably need a more permanent fix at some point.
One approach could be, for example, to assert that the handler does not use certain FPU registers and just omit saving them altogether on exceptions.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0