Skip to contentSkip to conversation

How get instruction pointer of user space ???

Question liyu@WAN 2 participants 2 messages Aug 31, 2005

lore
Share & tools
lore

liyu@WAN

author
#0 lore raw

Hi everyone:

I am implemnting one ioctl() in one character device.

That need know instruction pointer of user space. I am on i386
platform.
I can sure I am in process context. and enter kernel by system call way.

As I known, in default case, each task have one kernel stack, its length
is THREAD_SIZE(2 pages), and current_thread_info() is at its top. the struct pt_regs is at bottom of this stack.

so I write the code like here:

   pt_regs = ((struct pt_regs *)(THREAD_SIZE + current_thread_info()))+1;
   return pt_regs->eip;

but it do not work! even, I get segment fault and kernel Oops at
sometime.

Also, I am sure current_thread_info() return right value of current
user task.

Any idea on here?

thanks

sailor.

#1 lore raw
Quoted 8 lines · On 8/31/05, liyu@WAN <[email protected]> wrote:

Hi everyone:

I am implemnting one ioctl() in one character device.

That need know instruction pointer of user space. I am on i386
platform.
I can sure I am in process context. and enter kernel by system call way.

Quoted 7 lines

As I known, in default case, each task have one kernel stack, its length
is THREAD_SIZE(2 pages), and current_thread_info() is at its top. the struct pt_regs is at bottom of this stack.

so I write the code like here:

pt_regs = ((struct pt_regs *)(THREAD_SIZE + current_thread_info()))+1;

try doing the following, I amnot sure of it, just try it.

pt_regs = (struct pt_regs *) (((int *)(THREAD_SIZE + current)) - (sizeof(pt_regs) + 1));

Quoted 31 lines

return pt_regs->eip;

but it do not work! even, I get segment fault and kernel Oops at
sometime.

Also, I am sure current_thread_info() return right value of current
user task.

Any idea on here?

thanks

sailor.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/