RE: Accessing a File System/ Files from kernel space

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

 




Hello Robert and All,
 
   Well the real purpose of the driver / set of drivers is to read packet data from a file and process this data in kernel space. For example, I have a device - XYZ which reads the data from the file on HDD and then processes this data to see if its valid . Once this is done we feed this data to another driver ABC which further works on it and filters it.
 
  I have a couple of doubts in this context:
 
1) How to read the file from kernel space - yes, the fact as to whether the file name etc can be changed are yet to be resolved and hence I am still considering opening the file from userspace and then feeding the driver data wtih copy_to_user.
 
2) Feeding(rather the method of feeding) other drivers in the kernel with the processed data - I am still contemplating doing this in user space or kernel space .I could rather do an Interconnect at User Land and hence do a copy_from_user in which case . But then in this case I would rather do a stack at user land than implement them as drivers. Please do suggest me any other method I could use to transfer data between drivers.
 
BTW the project once complete will allow me to read a MPEG File and drive the video/audio drivers in the kernel  - which would effectively make it work like a DVD Player. The project is not targetted at doing something new but to gain some expertise in Linux Kernel programming.
 
Thanks,
G.
 
 
 
 

"Bennett, Robert P" <Robert.Bennett@xxxxxx> wrote:

> -----Original Message-----
> From: kernelnewbies-bounce@xxxxxxxxxxxx
> [mailto:kernelnewbies-bounce@xxxxxxxxxxxx] On Behalf Of Fawad Lateef
> Sent: Tuesday, March 21, 2006 1:28 PM
> To: Gaurav Dhiman
> Cc: George Joseph; Avishay Traeger; kernelnewbies@xxxxxxxxxxxx
> Subject: Re: Accessing a File System/ Files from kernel space
>
>
> On 3/21/06, Gaurav Dhiman wrote:
> > On 3/21/06, Fawad Lateef wrote:
> > >
> > > What you can do is:
> > >
> > > 1) From user application read the file and provide the data to
> > > driver through sysfs, this is secure (I think its fast too)
> > > 2) Directly call the file system functions to access the file (I
> > > think its difficult)
> > > 3) Directly call the user space file accessing functions through
> > > doing system-calls from kernel (its the worst thing to do)
> >
> > Can you explain, why the 3rd point is not recommended.
> whats the harm
> > in doing that, why we say it to be a worst thing to do. I
> only reason
> > I can find for that is, just because we are using the user
> > applications unused fd for opening our file without letting
> the user
> > application know about it. Whenever we opena file in kernel, using
> > sys_open() systemcall, we would be using the unused fd of an
> > application in context of which the driver is executing, and the
> > application wont come to know about it. Is there any harm
> in doing so,
> > if yes, please explain.
> >
>
> Hello Gaurav,
>
> I don't think that sys_open can be called from kernel rather
> accessing a file in kernel can be done through
> filp_open/close, struct file *file->f_op->read/write etc and
> for doing this have to use get_ds/set_fs thing (making
> get_fs() == KERNEL_DS) which actually bypasses arguments
> validity (see
> http://sosdg.org/~coywolf/lxr/source/include/asm-i386/uaccess.h#L18).
> And I think this is creating a security risk as file is
> accessing without checking and wrong content in file can do
> things bad. This is my understanding which might be
> completely wrong :) So, CMIIW

I think we need to understand what George is trying to do before
we try to solve his problem. I am still not clear on what his goal is.
He has something in the kernel which is reading packet data written to a
file, but what exactly is he doing with this data once it is read? What
is he really trying to accomplish? Is this something that can not be
accomplished running entirely in user space? If not, why?

Bob

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

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



Yahoo! Mail
Bring photos to life! New PhotoMail makes sharing a breeze.

[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