LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 01-26-2013, 02:56 AM   #1
ehabababneh
LQ Newbie
 
Registered: Apr 2009
Posts: 15

Rep: Reputation: 0
accessing/copying/modifying the data segment of a target process from kernel module.


Hello All,

Given a process task struct, I would like to be able to access the data segment of a that process. This is to be done from a kernel module if possible.

What I tried and did not work:

I know that task->mm->start_data should give the address of the data segment. But I am not sure if that address is relative (may be to RIP) or direct.

Also, if I iterate over all the vm_area_struct(s) in task->mm->mmap and check their vm_start(s) against task->mm->start_data. I found start_data is an order of magnitude larger than vm_start. That is obviously under many assumptions including that the beginning of the data segment start is aligned with the beginning of a page.

I am using Linux kernel 3.2.0 for amd64 arch.

Thank you!
 
Old 01-27-2013, 02:07 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,536

Rep: Reputation: 148Reputation: 148
start_data & friends are in the process virtual memory space. So if you access them in the module from this process context, the access is quite easy. From another process you need some more effort.
 
Old 01-27-2013, 07:05 PM   #3
ehabababneh
LQ Newbie
 
Registered: Apr 2009
Posts: 15

Original Poster
Rep: Reputation: 0
Thanks Mara for the reply.

So, does it contain the actual address of the data segment? if yes, can I use that address to and treat the data segment as a buffer? also if both yes, then how can I read/modify it? I tried using copy_to_user() but did not work. Can you please tell me what functions I need to use in order to access it?

btw, I am not going to attempt to modify the target process's data segment from another process ... I want to do that from within the kernel either by an kernel-space function, additional system call or from a kernel module.

Thanks.

Last edited by ehabababneh; 01-27-2013 at 07:06 PM.
 
  


Reply

Tags
kernel, kernel module, memory management


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Modifying the elevator.c module in linux kernel paresh.nakhe Programming 6 02-25-2011 05:44 AM
Where is LKM's text and data segment once it is loaded into kernel? tommy24 Linux - Kernel 4 07-25-2008 09:13 PM
Modifying / replacing a kernel module dplazz Linux - General 1 07-22-2005 03:14 PM
modifying TCP packets using kernel module shinkm Linux - Networking 2 09-02-2004 09:37 AM
accessing and copying data from remote sites? mikescar Linux - Software 1 02-03-2004 05:20 PM


All times are GMT -5. The time now is 03:32 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration