From: Narcisa Vasile <navasile@microsoft.com>
MmMapLockedPagesSpecifyCache can raise an exception when
it cannot map the specified pages.
Signed-off-by: Narcisa Vasile <navasile@microsoft.com>
Reported-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
kernel/windows/netuio/netuio_queue.c | 36 ++++++++++++++++++----------
1 file changed, 23 insertions(+), 13 deletions(-)
@@ -53,13 +53,18 @@ netuio_map_address_into_user_process(_In_ PNETUIO_CONTEXT_DATA netuio_contextdat
// Map the scratch memory regions to the user's process context
MmBuildMdlForNonPagedPool(netuio_contextdata->dpdk_seg.mdl);
- netuio_contextdata->dpdk_seg.mem.user_mapped_virt_addr =
- MmMapLockedPagesSpecifyCache(
- netuio_contextdata->dpdk_seg.mdl, UserMode, MmCached,
- NULL, FALSE, (NormalPagePriority | MdlMappingNoExecute));
+ __try {
+ netuio_contextdata->dpdk_seg.mem.user_mapped_virt_addr =
+ MmMapLockedPagesSpecifyCache(netuio_contextdata->dpdk_seg.mdl, UserMode,
+ MmCached, NULL, FALSE, NormalPagePriority);
- if (netuio_contextdata->dpdk_seg.mem.user_mapped_virt_addr == NULL) {
- status = STATUS_INSUFFICIENT_RESOURCES;
+ if (netuio_contextdata->dpdk_seg.mem.user_mapped_virt_addr == NULL) {
+ status = STATUS_INSUFFICIENT_RESOURCES;
+ goto end;
+ }
+ }
+ __except (EXCEPTION_EXECUTE_HANDLER) {
+ status = GetExceptionCode();
goto end;
}
@@ -70,13 +75,18 @@ netuio_map_address_into_user_process(_In_ PNETUIO_CONTEXT_DATA netuio_contextdat
}
MmBuildMdlForNonPagedPool(netuio_contextdata->dpdk_hw[idx].mdl);
- netuio_contextdata->dpdk_hw[idx].mem.user_mapped_virt_addr =
- MmMapLockedPagesSpecifyCache(
- netuio_contextdata->dpdk_hw[idx].mdl, UserMode, MmCached,
- NULL, FALSE, (NormalPagePriority | MdlMappingNoExecute));
-
- if (netuio_contextdata->dpdk_hw[idx].mem.user_mapped_virt_addr == NULL) {
- status = STATUS_INSUFFICIENT_RESOURCES;
+ __try {
+ netuio_contextdata->dpdk_hw[idx].mem.user_mapped_virt_addr =
+ MmMapLockedPagesSpecifyCache(netuio_contextdata->dpdk_hw[idx].mdl, UserMode,
+ MmCached, NULL, FALSE, NormalPagePriority);
+
+ if (netuio_contextdata->dpdk_hw[idx].mem.user_mapped_virt_addr == NULL) {
+ status = STATUS_INSUFFICIENT_RESOURCES;
+ goto end;
+ }
+ }
+ __except (EXCEPTION_EXECUTE_HANDLER) {
+ status = GetExceptionCode();
goto end;
}
}