LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 05-22-2014, 05:05 PM   #1
WoodBunny
LQ Newbie
 
Registered: May 2014
Posts: 2

Rep: Reputation: Disabled
“Attach” a user space process from Linux kernel/kernel module


I want to modify the virtual-to-physical address mapping (i.e. page table) of a particular process for every 60 seconds. I do know how to modify the page table, how to flush the cache and TLB accordingly, and how to leverage workqueue to invoke my function every 60 seconds. However, I am not sure how to "attach" to the target process from kernel or kernel module, assuming that the target process does not initiate any system call. By "attach", I mean the target process will behave similar as when it encountered an interrupt (e.g. a page fault) and the execution goes to the kernel immediately with the context being saved. So is it possible to do this?

Pointers to any similar usage in the kernel code or other hints are also appreciated.
 
Old 05-23-2014, 12:23 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,162

Rep: Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268
If you can modify the process then the easiest way is to add a signal handler.
Send the process a signal. The handler triggers and calls into your kernel module.

If you can't modify the process then you could look at how gdb attaches to and
interrupts an arbitrary running process.
 
1 members found this post helpful.
Old 05-23-2014, 06:14 PM   #3
WoodBunny
LQ Newbie
 
Registered: May 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by smallpond View Post
If you can modify the process then the easiest way is to add a signal handler.
Send the process a signal. The handler triggers and calls into your kernel module.

If you can't modify the process then you could look at how gdb attaches to and
interrupts an arbitrary running process.
Thanks a lot, @smallpond! But I still feel what you suggested is not very straightforward to solve my problem. Do you think it is possible to achieve this purely inside the kernel?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
memory management of a process in kernel space and user space. embeddedlinux Linux - Newbie 1 05-08-2012 08:08 AM
how to send events from kernel module to user space process yugandhar Linux - Kernel 2 02-21-2011 10:39 AM
kernel module - write to user space mrshanim Linux - Kernel 5 12-31-2010 11:25 AM
[SOLVED] Does a kernel module run in kernel or user space? paliga Linux - General 4 10-31-2010 07:22 AM
How to attach a kernel module with kernel source code Gourab Das Linux - Kernel 2 02-04-2010 07:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 02:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration