Reputation: 69
I have the following situation: a Linux OS (ARM) runs on a virtual platform, and a simple program is started within the OS with a breakpoint on a certain symbol. When this breakpoint is hit, we are in the user space.
My question is: having a full overview of the entire virtual memory of the (currently running) process (i.e., kernel + user space), can I somehow find out the address of the task_struct
or thread_info
structures located on the (bottom) of the kernel stack? I'm aware that in the kernel mode it's possible to use a mask on the SP to get the bottom of the kernel stack but this won't work if the SP points to something in the user space. Essentially I'm trying to do something similar to the current / current_thread_info() macros in the kernel.
The reason I think this is hard / impossible is because the kernel stack address is randomized and thus changes with each new process.
Things I need to avoid:
Upvotes: 0
Views: 552
Reputation: 239041
To determine the supervisor mode SP while the target is in userspace, you need to examine the R13_svc
register.
If you take this value and set the 13 least significant bits to zero, you should have the virtual address for the struct thread_info
of the current thread.
Upvotes: 3