-
Notifications
You must be signed in to change notification settings - Fork 47
threads: Kernel handling of unsafe operations on user memory #664
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ | |
| #include "hal/string.h" | ||
| #include "hal/spinlock.h" | ||
| #include "hal/hal.h" | ||
| #include "arch/exceptions.h" | ||
| #include "include/errno.h" | ||
|
|
||
| #include "armv7a.h" | ||
| #include "config.h" | ||
|
|
@@ -96,8 +98,12 @@ int hal_cpuCreateContext(cpu_context_t **nctx, void *start, void *kstack, size_t | |
| } | ||
|
|
||
|
|
||
| extern void threads_setexcjmp(excjmp_context_t *ctx, excjmp_context_t **oldctx); | ||
|
|
||
|
|
||
| int hal_cpuPushSignal(void *kstack, void (*handler)(void), cpu_context_t *signalCtx, int n, unsigned int oldmask, const int src) | ||
| { | ||
| excjmp_context_t excctx, *oldctx; | ||
| cpu_context_t *ctx = (void *)((char *)kstack - sizeof(cpu_context_t)); | ||
| const struct stackArg args[] = { | ||
| { &ctx->psr, sizeof(ctx->psr) }, | ||
|
|
@@ -110,19 +116,26 @@ int hal_cpuPushSignal(void *kstack, void (*handler)(void), cpu_context_t *signal | |
|
|
||
| (void)src; | ||
|
|
||
| hal_memcpy(signalCtx, ctx, sizeof(cpu_context_t)); | ||
| if (!hal_setexcjmp(&excctx, &oldctx)) { | ||
| hal_memcpy(signalCtx, ctx, sizeof(cpu_context_t)); | ||
|
|
||
| signalCtx->pc = (u32)handler & ~1; | ||
| signalCtx->sp -= sizeof(cpu_context_t); | ||
| signalCtx->pc = (u32)handler & ~1; | ||
| signalCtx->sp -= sizeof(cpu_context_t); | ||
|
|
||
| if (((u32)handler & 1) != 0) { | ||
| signalCtx->psr |= THUMB_STATE; | ||
| if (((u32)handler & 1) != 0) { | ||
| signalCtx->psr |= THUMB_STATE; | ||
| } | ||
| else { | ||
| signalCtx->psr &= ~THUMB_STATE; | ||
| } | ||
|
|
||
| hal_stackPutArgs((void **)&signalCtx->sp, sizeof(args) / sizeof(args[0]), args); | ||
| } | ||
| else { | ||
| signalCtx->psr &= ~THUMB_STATE; | ||
| threads_setexcjmp(oldctx, NULL); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we could clear old ctx on
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's problematic, as it would require putting pointer to oldctx in struct |
||
| return -EFAULT; | ||
| } | ||
|
|
||
| hal_stackPutArgs((void **)&signalCtx->sp, sizeof(args) / sizeof(args[0]), args); | ||
| threads_setexcjmp(oldctx, NULL); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.