Re: Verify Kernel Pointer

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

 



On Fri, Apr 21, 2006 at 06:11:47PM +0000, Talib Alim wrote:
> >On Thu, Apr 20, 2006 at 10:42:16PM +0000, Talib Alim wrote:
> >> >	If I'm reading Talib's question correctly, it looks like he is
> >> >treating the pointer as opaque in user space, i.e. not directly
> >> >referencing the memory in user space, but he is passing the pointer back
> >> >to his kernel module at some point in the future, and he wants to make
> >> >sure that on this subsequent call the pointer is still valid.  Without
> >> >seeing his code and knowing exactly what he is trying to accomplish, I
> >> >can't say for sure.  Whatever the case, for saving opaque kernel
> >> >pointers I would use the private_data field in the file structure,
> >> >assuming this is a driver or virtual file system he is working with.
> >> >
> >> >Bob
> >>
> >> Bob, you are correct.
> >>
> >> When using application wants service from my device, it open character special file and get a descriptor. Now through ioctl it can make hundreds of request to my
> >> device.
> >>
> >> Driver (i.e. my code) allocate memory for each request (through slab cache). There could be many transections for each request. (think if you open a for file you
> >> can do read, write operations).
> >>
> >> And all I want to make sure that application (by mistake or by choice) is not passing a junk value to my code. Once, I verify that memory is OK, than I can look 
> >for
> >> signatures to make sure that it is pointing to correct data structure.
> >>
> >> Talib
> >
> > I really don't understand what you are trying to do :)
> > You want to pass the kernel pointer to the userspace application and
> > then pass back the kernel pointer from the user application to the
> > kernel ??
> >
> > You can't do any operation from the user space on the kernel pointer,
> > so why do you want to pass it to the user space application ?
> 
> So that next time user calls my driver for service, it can identify context of request (like fd in read)

Ok, I see.
What you have to do is to maintain a cursor inside the driver.
You init the cursor to 0 (when device is opened).
You next adds the number of bytes read (at each read operation).
You move the cursor with the seek function.

But don't do what you said.
-- 
tyler
tyler@xxxxxxxx


	

	
		
___________________________________________________________________________ 
Faites de Yahoo! votre page d'accueil sur le web pour retrouver directement vos services préférés : vérifiez vos nouveaux mails, lancez vos recherches et suivez l'actualité en temps réel. 
Rendez-vous sur http://fr.yahoo.com/set


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