Re: access to process descriptor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



oh sorry,this is because of power failure in my office
i will take care of that.
Prasanna
--- Davidlohr Bueso A <dbueso@linuxchile.cl> wrote:
> Please make sure you only send the email to the list
> only once (that's
> enough :) ).
> 
> Dave
> 
> On Sat, 2004-06-26 at 01:53, prasanna wakhare wrote:
> > hi,
> > intel processors runs in 4 privilage mode,kernel
> runs
> > in highest privilage mode
> > ,You are in user mode so the segmenation hardware
> > loaded the data and code segment descriptor  
> > with user data and user code segment,and you are
> > trying to access the
> > kernel data structure from user space which is 
> > something you never reach,
> > So for accessing the kernel data struture yr data
> > segment must be set with
> > kernel data segment,but then yr code segment is
> set to
> > user code segment,
> > so processor will again generate exceptions as
> your
> > user space code trying to access kernel space
> code,
> > so better way is to do it in kernel modules which
> is
> > something like dynamically loaded
> > extensions to kernel code,
> > where you can directly access the member of
> > task_struct structure,
> > but genrally the work should get done by using the
> > exported funtions
> > by kernel u get them in /proc/ksyms,
> > more information about kernel programming you will
> get
> > on web,
> > and ofcourse the bible for every kernel programmer
> > "linux device drivers"
> > by rubini is always there.
> > Prasanna
> > 
> > 
> > --- Alexander Nyberg <alexn@telia.com> wrote:
> > > > Hi all,
> > > > I'm trying to develop a C program that access
> to
> > > > process descriptor information but I have had
> some
> > > > problem with libraries.
> > > > In particular, I've developed a program like
> this:
> > > > 
> > > > #include <linux/sched.h>
> > > > 
> > > > int main(void){
> > > >    pid_t pid;
> > > >    ....
> > > >    task_struct process =
> find_task_by_pid(pid);
> > > >    ...
> > > > }
> > > > 
> > > > but the compiler can't find get_task_by_pid
> > > function,
> > > > while this is a function declared in
> > > > include/linux/sched.h.
> > > > What's wrong?
> > > 
> > > The problem is that the function
> get_task_by_pid()
> > > lives in the kernel,
> > > and you cannot call arbitrary functions in the
> > > kernel (think of what
> > > that would mean to security and isolation). The
> > > functions you can access
> > > from user space are system calls.
> > > 
> > > > Are there other methods to access process
> > > descriptor
> > > > pointer?
> > > 
> > > If you need more than what is already available
> from
> > > the task_struct you
> > > would preferably add another system call to your
> > > linux (there are other
> > > ways too).
> > > 
> > > Maybe something like:
> > > sys_get_task_struct(pid_t pid, struct
> task_struct
> > > __user *to)
> > > {
> > > 	task_struct *task = find_task_by_pid(pid);
> > > 	copy_to_user(to, task, sizeof(struct
> task_struct));
> > > }
> > > 
> > > Alex
> > > 
> > > 
> > > --
> > > Kernelnewbies: Help each other learn about the
> Linux
> > > kernel.
> > > Archive:      
> > > http://mail.nl.linux.org/kernelnewbies/
> > > FAQ:           http://kernelnewbies.org/faq/
> > > 
> > > 
> > 
> > 
> > 
> > 		
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Mail - Helps protect you from nasty
> viruses.
> > http://promotions.yahoo.com/new_mail
> > 
> > --
> > Kernelnewbies: Help each other learn about the
> Linux kernel.
> > Archive:      
> http://mail.nl.linux.org/kernelnewbies/
> > FAQ:           http://kernelnewbies.org/faq/
> > 
> > 
> 

> ATTACHMENT part 2 application/pgp-signature
name=signature.asc




	
		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux