It's not quite the same question as yours, but in my answer to it I go into some detail on memory descriptors in DriverKit extensions.
Basically, in DriverKit you can only access user space memory that was explicitly provided as a buffer; you can't interpret arbitrary data as pointers in the user process's address space and create memory descriptors for them.
The only way to create memory descriptors for user space buffers that I'm aware of is via "struct" arguments to IOUserClient
external methods, i.e. when the user process passes them to the IOConnectCallMethod*
family of functions as either an input or output "struct". If the buffer is larger than 4096 bytes, it'll show up in the dext as an IOMemoryDescriptor
, and you can perform the usual DMA operations with it.
Typically, you'll want to do this in combination with async external methods, which lets you implement sensible buffer lifetime semantics, but your dext can technically hold on to user space supplied memory descriptors past the return of a synchronous external method, or past the async completion of an asynchronous one.