zje
zje

Reputation: 3912

Is there a way to ensure that a kernel module runs in a specific process context?

Basically, how can I make sure that in my module, a specific process is current. I've looked at kick_process, but I'm not sure how to have my module execute in the context of that process once kicking it into kernel mode.

I found this related question, but it has no replies. I believe an answer to my question could help that asker as well.

Note: I am aware that if I want the task_struct of a process, I can look it up. I'm interested in running in a specific context since I want to call functions that reference current.

Upvotes: 0

Views: 407

Answers (1)

Raghu
Raghu

Reputation: 501

Best way i have found to do anything in the context of a particular process in the kernel, is to sleep in process context(wait_* family of functions) and wake up that thread and do whatever needs to be done in that context. This would ofcourse mean you would have to have the application call into the kernel via IOCTL or something and sleep on that thread and wake it up whenever you need to do something. This seems to be a very widely used and popular mechanism.

Upvotes: 1

Related Questions