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

sym_get_fn_address fix #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions include/L1/stack_switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@

// These must be used as a pair
#define SYM_ON_KERN_STACK() \
sym_elevate(); \
uint64_t user_stack; \
SYM_PRESERVE_USER_STACK(user_stack); \
SYM_SWITCH_TO_KERN_STACK();

#define SYM_ON_USER_STACK() \
SYM_RESTORE_USER_STACK(user_stack); \
sym_lower();
SYM_RESTORE_USER_STACK(user_stack);

// Combine the two above so we don't have to remember to call both
// but put all of user code inbetween
Expand Down
12 changes: 9 additions & 3 deletions src/LIDK/idk.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,22 @@ void* sym_get_fn_address(char *symbol) {
parse_system_map();
}

long already_elevated = sym_check_elevate();

// Elevate to be able to call kallsyms_lookup_name
sym_elevate();
if (!already_elevated)
sym_elevate();

// TODO: clean this up
uint64_t user_stack;
SYM_PRESERVE_USER_STACK(user_stack);
SYM_SWITCH_TO_KERN_STACK();
void* result = (void*)kallsyms_lookup_name(symbol);
SYM_RESTORE_USER_STACK(user_stack);
// Don't forget to lower
sym_lower();

// Don't forget to lower
if (!already_elevated)
sym_lower();

return (void*)result;
}
Expand Down