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

Fix user task exit by exception #226

Merged
merged 3 commits into from
Mar 21, 2024
Merged

Conversation

jlaitine
Copy link

@jlaitine jlaitine commented Mar 19, 2024

Summary

Fix the bugs DP-2143, DP-8522

I will still offer this to upstream review first

Impact

Increase resilience to SW bugs, don't crash the whole system if a userspace process excepts

Testing

Injected NULL dereference bugs in couple of PX4 processes, tried out that they exit without causing a panic.

@jlaitine jlaitine requested a review from pussuw March 19, 2024 10:46
@jlaitine jlaitine force-pushed the fix_user_task_exit_by_exception branch from 114b7cb to 699c1f5 Compare March 20, 2024 10:14
@jlaitine jlaitine force-pushed the fix_user_task_exit_by_exception branch from 699c1f5 to 5036d5d Compare March 20, 2024 12:05
@jlaitine jlaitine force-pushed the fix_user_task_exit_by_exception branch from 5036d5d to 8329991 Compare March 20, 2024 12:34
…force-cancelled

There is no point in waiting for children to exit if the parent is force-cancelled

Signed-off-by: Jukka Laitinen <[email protected]>
…using an exception

We shouldn't panic the kernel when a user task excepts, we can just kill the user task and
it's children. Do this by returning to _exit() in kernel context.

Signed-off-by: Jukka Laitinen <[email protected]>
… currently running task in risc-v syscall

If a context switch occurs in syscall, the g_running_task need to be recorded for assert logic.
This copies the logic from arm platforms

Signed-off-by: Jukka Laitinen <[email protected]>
@jlaitine jlaitine force-pushed the fix_user_task_exit_by_exception branch from 8329991 to 13ea8e1 Compare March 21, 2024 07:31
@jlaitine
Copy link
Author

jlaitine commented Mar 21, 2024

I reverted the running_task -> this_task change in favor of following the upstream g_running_tasks[thiscpu()] recording method. The reason why g_running_task method was not working was that it needs to be updated every time a context switch occurs, i.e. also in syscalls.

Made another Pr for this in upstream: apache#11961. sorry for continuous updates to this PR, I decided to just put this into this same one as this was not yet merged.

@jlaitine jlaitine merged commit 6c4e6d6 into master Mar 21, 2024
6 of 7 checks passed
@jlaitine jlaitine deleted the fix_user_task_exit_by_exception branch March 21, 2024 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants