On 9/21/07, Sachin Gaikwad <sachin.kernel@xxxxxxxxx> wrote: > Hi all, > > For kernel 2.6.22.6 : I can see that tyoe of 2nd arg for read function > in strucy file_operations is changed is little bit changed from 2.4 > kernel. > > ssize_t (*read) (struct file *, char __user *, size_t, loff_t *); > > For 2.4 it used to be: > > ssize_t (*read) (struct file *, char *, size_t, loff_t *); > > So what does extra __user specify here. It specifies that this is user data that should be validated by the kernel. You don't know if the user did pass you an invalid memory, so you cannot trust this pointer here. For instance, you can do something like this: err = !access_ok(VERIFY_WRITE, memory, size); err = !access_ok(VERIFY_READ, memory, size); I guess you can find some examples grepping for uaccess.h and /or reading http://lwn.net/Kernel/LDD3/ . > If I have to use this function of reading file inside the kernel, then > shall I pass kernel buffer to it or user space buffer ? Well, I'm not qualified to answer this question, yet. > I know that it is VERY BAD idea to read from kernel. But how are we > suppposed to do it if at all. dd if=file of=/dev/mydev ? cat file > /dev/mydev ? Regards, N.- -- http://arhuaco.org -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ