Re: file access in kernel

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

 



On 1/26/06, Hsieh Steve <stevecfhsieh@xxxxxxxxx> wrote:
>
> 2006/1/25, Thomas Petazzoni <thomas.petazzoni@xxxxxxxx>:
> >
> >
> > Do not try to access a file from kernel space.
>
>
>
> Could u explan "Dont try to access files in kernel space?"
> it this any drawback??
>
>

AFAIK accessing files from the kernel is not the good approach as it
can open security issues/holes with-in the kernel, hence the better
approach (if really wants to perform file-io) is to use some interface
like sysfs/netlink sockets for sending data to user space and then
performing file io from user space !

> > If these informations are available through a /proc, it means that they
> > are available in the kernel without having to open a /proc/something.
> > Have you looked at how /proc/net/tcp is implemented in the kernel ?
> > After a very quick look, it seems to be implemented at
> > http://lxr.linux.no/source/net/ipv4/tcp_ipv4.c#L2394.
>
>
> You are right, the infomation I need is available in kernel through invoking
> tcp_get_info()
> (kernel version 2.4.25)
> However, this func is written in tcp module and not exposed as a kernel
> symbol, so that
> I can not call this func in my module.
>

Actually the function mentioned by Thomas is for your reference and
hint because that is also not exported (rather defined as static) and
you can see from it that how it is accessing the information exported
to /proc and use/get the things as that function is doing ! (CMIIW)

--
Fawad Lateef

--
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