Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate: can we probe-and-lock AssociatedIrp.SystemBuffer instead of copying it to a new NonPaged buffer? #555

Closed
dmiller-nmap opened this issue Oct 22, 2021 · 1 comment

Comments

@dmiller-nmap
Copy link
Contributor

In a few places (funcBIOC_OID, NPF_BufferedWrite, perhaps others), data from the user is used as input to a function that requires that the memory not be paged out until it is done being processed. To avoid page faults (as in #374), we currently allocate a new buffer from NonPagedPool and copy the user data into it. In cases where the IRP is not pended (i.e. we wait for an event to signal that it is done being processed before returning the buffer to the user), we should be able to use the user data buffer directly instead of copying it. We would need to have a MDL describing the buffer pages and to ensure that they are probed and locked so they cannot be paged out.

I believe that in the case of IRP_MJ_DEVICE_CONTROL, all our IoControl codes (in ioctls.h) specify METHOD_BUFFERED, which means that the user data has already been copied into a nonpaged buffer by the I/O manager. We may still need to create a MDL to describe the buffer, especially for NPF_BufferedWrite because we use several sections of the buffer independently.

@dmiller-nmap
Copy link
Contributor Author

Fixed in 7d8c0a9. The I/O manager probes and locks the relevant pages for direct I/O (which we use for Read and Write. We just have to be sure not to complete the IRP before we're done with those pages (i.e. when the SendComplete handler is called).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant