Re(2): Pass socket to kernel?
Re(2): Pass socket to kernel?
- Subject: Re(2): Pass socket to kernel?
- From: "Peter Lovell" <email@hidden>
- Date: Sat, 30 Dec 2006 12:12:02 -0500
I think you might wish to slightly rethink things. As Josh says, there
isn't a good way to do this.
If you can manage the socket (open/close) in user space, then doing a
socket filter is a viable option. But the socket has to remain open as
long as you need it -- you can't close it in user space and retain it in
the kernel, "pass"ing it as you had originally wanted. It has to stay
open somewhere in user space.
Another possibility is to perform the validation from user space (good)
and then transmit somehow those credentials to your kernel module, which
itself opens its own socket to the server. In this case, the long-term
socket is never opened in user space, and does not need to have a home
there. One example of this is the NFS code available as part of the
darwin source. This isn't KPI-compliant (at least, it wasn't the last
time I looked) but that's probably low on your list of concerns once
you're dealing in this area..
Cheers.....Peter
>
>There isn't a right way to do this.
>
>One way to do this is register a socket filter. You can use a socket
>option, I think it's SO_NKE to attach your filter to the socket from
>user space. You absolutely must not call sock_close on this socket
>from the kernel though. You need user space to be responsible for
>opening and closing the socket. There are some tricky issues in the
>handoff from user space to kernel and the pieces you would need to
>accomplish this are not part of the KPI.
>
>-josh
>
>On Dec 30, 2006, at 3:16 AM, email@hidden wrote:
>
>> I'm writing a remote file system KEXT that uses the socket KPI, but
>> some of the work has to be done from user space via an app (e.g. the
>> authentication process, which requires user interaction).
>>
>> What's the correct way to pass a socket from my app to the kernel for
>> use with the socket KPI? My app will connect to a server, do some
>> exchanges to authenticate, then I want to hand off that socket to the
>> kernel to do the rest (it has to hook into the mass storage stack).
>> Once the socket is handed off, I want the app to be able to quit
>> without the kernel-side of the socket being closed (i.e. sock_retain).
>>
>> I see references to doing this type of thing in kpi_socket.h file, but
>> I wasn't sure how to get the underlying socket_t from the socket file
>> descriptor to use from the kernel side. Do I have to write a socket
>> filter to get the socket_t?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden