From mboxrd@z Thu Jan 1 00:00:00 1970 From: matthias.bgg@gmail.com (Matthias Brugger) Date: Fri, 14 Dec 2012 10:28:35 +0100 Subject: can I input a gate service to kernel to get kernel data to user ? In-Reply-To: <1b46c269.bc6.13b96e666c5.Coremail.horse_rivers@126.com> References: <16a2ade.3489.13b92440bba.Coremail.horse_rivers@126.com> <50C9B385.8060107@gmail.com> <1b46c269.bc6.13b96e666c5.Coremail.horse_rivers@126.com> Message-ID: <50CAF143.6060604@gmail.com> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org Hi, On 12/14/2012 01:53 AM, horse_rivers wrote: > At 2012-12-13 18:52:53,"Matthias Brugger" wrote: >> On 12/13/2012 04:17 AM, horse_rivers wrote: >>> is there method for doing this work? take kernel data to user? >> >> I think copy_to_user is what you are looking for: >> http://lxr.free-electrons.com/source/include/asm-generic/uaccess.h#L253 >> > > thanks ! > > can this function run at user level ? > > when programme is at user level , can I use this function to get kernel text segment data ,and then analysis it ? no you can't. Userspace programs can only access the kernel trough a systemcall, otherwise userspace could read memory from other programs which would be dangerous (think of passwords etc). If you want to read certain parts of kernel memory from userspace, you need a kernel module which uses copy_to_user, for example a character driver using the read or ioctl function to call copy_to_user. The userspace then would use that character device to invoke systemcalls. Please refer to http://lwn.net/Kernel/LDD3/ about device driver programing. Although the book is outdated it is a perfect point to start understanding the concepts. Best regards, Matthias > > BestRegards! > >> Cheers, >> Matthias >> >>> >>> >>> thanks! >>> >>> _______________________________________________ >>> Kernelnewbies mailing list >>> Kernelnewbies at kernelnewbies.org >>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies >>> >> >> >> _______________________________________________ >> Kernelnewbies mailing list >> Kernelnewbies at kernelnewbies.org >> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies at kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies >