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

ARM: userspace/test_bad_syscall fails on ARMv8-M #17177

Closed
ioannisg opened this issue Jun 30, 2019 · 0 comments · Fixed by #17146
Closed

ARM: userspace/test_bad_syscall fails on ARMv8-M #17177

ioannisg opened this issue Jun 30, 2019 · 0 comments · Fixed by #17146
Assignees
Labels
area: ARM ARM (32-bit) Architecture area: Userspace Userspace bug The issue is a bug, or the PR is fixing a bug priority: high High impact/importance bug
Milestone

Comments

@ioannisg
Copy link
Member

ioannisg commented Jun 30, 2019

After increasing the test coverage in tests/kernel/mem_protect/userspace (FYI @andrewboie), the test is failing for ARMv8-M platforms.

To Reproduce
Steps to reproduce the behavior:

  1. Checkout master or pull-request branch [Backport v1.14-branch] 1.14 userspace backports coverage #17079 (for the LTS)
  2. Build and run tests/kernel/mem_protect/userspace for nrf9160_pca10090
  3. test_bad_syscall fails.

The logs are provided below:

===================================================================
starting test - test_bad_syscall
Bad system call id 2147483647 invoked
***** Hardware exception *****
Current thread ID = 0x200011d0 (unknown)
Faulting instruction address = 0x33c9
Caught system error -- reason 0
***** USAGE FAULT *****
  Stack overflow (context area not valid)
***** Stack Check Fail! *****
Current thread ID = 0x200011d0 (unknown)
Faulting instruction address = 0xffffffff
Caught system error -- reason 2

    Assertion failed at ../src/main.c:107: z_SysFatalErrorHandler: (Reached unreachable code)
Unexpected fault during test
FAIL - test_bad_syscall

The failure is not yet observed in v1.14-branch, since the PR with the test coverage increase has not yet been merged.

The root cause of the failing test is an implementation bug in system call handling for ARM platforms: the system call initialization code is using the default (un-privileged) stack before switching to the privilege stack.

The fail is only detected in ARMv8-M, because ARMv8-M has more strict rules for pushing to the stack, when stack-overflow mechanisms are activated (i.e. does not allow any push to stack memory below the stack limit; not only a push into a programmed read-only guard, as the traditional MPU-based guard mechanism).

Impact
Affects ARM builds with CONFIG_USERSPACE=y.
The userspace test is failing
Any swap during system-call initialization in ARMv8-M builds will trigger a stack-overflow.

Fix
The fix is provided in #17146

@ioannisg ioannisg added bug The issue is a bug, or the PR is fixing a bug priority: high High impact/importance bug area: ARM ARM (32-bit) Architecture area: Userspace Userspace labels Jun 30, 2019
@ioannisg ioannisg added this to the v1.14.1 milestone Jun 30, 2019
@ioannisg ioannisg self-assigned this Jul 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ARM ARM (32-bit) Architecture area: Userspace Userspace bug The issue is a bug, or the PR is fixing a bug priority: high High impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant