Extables#220
Merged
Merged
Conversation
wipawel
previously approved these changes
Oct 15, 2021
| { | ||
| __start_extables = .; | ||
| *(.extables) | ||
| __stop_extables = .; |
| #include <mm/regions.h> | ||
|
|
||
| void init_extables(void) { | ||
| for (extable_entry_t *cur = __start_extables; cur < __stop_extables; ++cur) { |
Contributor
There was a problem hiding this comment.
Good idea to have them sanity checked. Thanks!
Next step could be to sort them and use bsearch to speed up lookup.
Contributor
Author
There was a problem hiding this comment.
Right now we've only like 8 entries, so a linear search should still be fast enough. ;) But yeah, when we get more users and especially ones in hot code, speeding up the search might make sense.
Comment on lines
-314
to
+312
| use_extables(regs); | ||
| if (extables_fixup(regs)) | ||
| return; |
82marbag
previously approved these changes
Oct 15, 2021
Change the type of the __{start,end}_* markers to unsigned char so
pointer diff does "The Right Thing"™, i.e. give the byte difference,
not the object count difference.
Signed-off-by: Mathias Krause <minipli@grsecurity.net>
The extables handling is broken as in not being able to handle exceptions gracefully. They'll all end up in a panic, which is probably not intended. Make use_extables() return a boolean that tells if the exception was handled or not. If it was, we can simply return from the exception handler and continue execution. Also don't support doing both, a fixup IP and a callback. Only do one and prefer the fixup IP which is currently the only use case. Last, but not least, use the oppurtunity to rename the function to extables_fixup(), as that's what it does: fixing up the exception. Signed-off-by: Mathias Krause <minipli@grsecurity.net>
We round up the extables array to a multiple of 4kB. However, this leads to empty extable entries, i.e. entries for NULL ptr faults without a fixup IP nor a callback. To avoid bogus handling of these, introduce a new symbol __stop_extables[] that points to the end of legitimate extable entries. Leave __end_extables[] as is to lower the amount of code churn. However, change its type to unsigned char to avoid and flag accidental misuse. Signed-off-by: Mathias Krause <minipli@grsecurity.net>
Some headers lack explicit includes for #defines / types they use. Add these to avoid these implicit include dependencies. Signed-off-by: Mathias Krause <minipli@grsecurity.net>
Ensure all entries have a fixup IP or a callback. Panic if an entry lacks both. Signed-off-by: Mathias Krause <minipli@grsecurity.net>
auto-merge was automatically disabled
October 15, 2021 14:25
Head branch was pushed to by a user without write access
82marbag
approved these changes
Oct 15, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes the extable handling as in not triggering a panic or handling NULL pointer dereferences in an endless loop. E.g. when booting on a VM with too little memory we'll now fail gracefully instead of looping in exception handling:
Boilerplate disclamer follows:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.