On Thu, Sep 30, 2004 at 20:53:53 +0530, Rakesh Jagota wrote: > Hello Jan, > > Thanks for your prompt reply. Sorry for giving some what wrong info . I have > written functions corresponding to sys_* calls . I did not call them. > Ex. > sys_socket -- my_socket > sys_bind -- my_bind > and eliminated the file system by removing sock_fdlookup() and other > functions which deals with filesystem.This is mainly done to avoid the file > system as a kernel module does not have any files_struct as it is associted > with user processes. Now I am maintaining my own array which contains > addresses of > BSD sockets > > Pls pass on any advice. That does not seem to change anything about the answer. The -EFAULT error is most likely to be caused by copy_to/from_user with a kernel-space pointer. Either avoid that call by using more primitive function, or, if that's not possible, use the set_fs wrapper. > Regards > Rekesh > > > > I developed on kernel module which provides wrapper functions to all sys_* > > funtions related to sockets. With this i developed one application , and i > > could run TCP server which is communicating with TCP client on the other > > m/c. > > > > Now Developed one kernel module (instead of application in the earlier > > case)for TCP server (now Kernel module) . when the server is executing the > > bind function > > it has given Error No -14. > > > > I know that It is accessing bad area. Any suggestions. > > First, errno 14 is Bad Address. In kernel, errno values are negative. > > Now, I have two suggestions: > > 1) Don't use syscalls from kernel. Use the sock_* functions directly. > > 2) If you have to call a syscall, or any other function that does > copy_to/from_user with data in kernel, do: > > mm_segment_t oldfs = get_fs(); > set_fs(KERNEL_DS); > <do-the-call-here> > set_fs(oldfs); > > In fact, even if you avoid calling syscalls, read and write (and send, > recv etc...) file/socket methods will still need this, because they > copy_to/from_user. > > ---------------------------------------------------------------------------- > --- > Jan 'Bulb' Hudec <bulb@xxxxxx> > > ----- Original Message ----- > From: "Jan Hudec" <bulb@xxxxxx> > To: "Rakesh Jagota" <j.rakesh@xxxxxxxxxxxxx> > Cc: <kernelnewbies@xxxxxxxxxxxx> > Sent: Thursday, September 30, 2004 7:57 PM > Subject: Re: Error No -14 in Binding by server in Kernel module > > > ------------------------------------------------------------------------------- Jan 'Bulb' Hudec <bulb@xxxxxx>
Attachment:
signature.asc
Description: Digital signature