Invalid VA in MDL: Win2K - SP4

Hi All,

I have a TDI filter and I am modifying the incoming and outgoing traffic.

When my receive event handler is called, I pass the data to AFD by calling
its receive event handler.

If AFD returns STATUS_MORE_PROCESSING_REQUIRED and passes me an IRP, I try
to get the virtual address from the MDL associated to IRP (Irp->MdlAddress).

My problem is some times I am getting an invalid address. This happens
rarely though.
I can’t figure out why AFD is passing me an invalid address. Probably it is
not mapping the user space buffer to system space.
I am extracting the StartVa field using MmGetMdlVirtualAddress.

And this problem occurs on Windows 2000 SP4 only.
Any clue…??

The workaround I have found is to check the virtual address using
MmIsAddressValid and if it is invalid, map it using
MmGetSystemAddressForMdlSafe. Do I need to unmap the pages also if mapping
is done by MmGetSystemAddressForMdlSafe?

Regards
Vijender

-----Original Message-----
From: Vijender Yadav [mailto:xxxxx@nodeinfotech.com]
Sent: Wednesday, October 27, 2004 4:07 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Invalid VA in MDL: Win2K - SP4

Hi All,

I have a TDI filter and I am modifying the incoming and outgoing traffic.

When my receive event handler is called, I pass the data to AFD by calling
its receive event handler.

If AFD returns STATUS_MORE_PROCESSING_REQUIRED and passes me an IRP, I try
to get the virtual address from the MDL associated to IRP (Irp->MdlAddress).

My problem is some times I am getting an invalid address. This happens
rarely though.
I can’t figure out why AFD is passing me an invalid address. Probably it is
not mapping the user space buffer to system space.
I am extracting the StartVa field using MmGetMdlVirtualAddress.

And this problem occurs on Windows 2000 SP4 only.
Any clue…??

The workaround I have found is to check the virtual address using
MmIsAddressValid and if it is invalid, map it using
MmGetSystemAddressForMdlSafe. Do I need to unmap the pages also if mapping
is done by MmGetSystemAddressForMdlSafe?
[DevSingh] You need not to unmap this but this memory will become invalid
with the completion of corresponding IRP. So ensure you not use it after IRP
completion. Better make this pointer invalid at the time of IRP completion.

Regards
Vijender


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: dsingh@in.safenet-inc.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Your driver should always use MmGetSystemAddressForMdlSafe rather than
trying to reuse the user-mode VA mapping.

If you map the MDL associated with the IRP you don’t need to unmap it -
the request originator should take care of that for you.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Vijender Yadav
Sent: Wednesday, October 27, 2004 3:37 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Invalid VA in MDL: Win2K - SP4

Hi All,

I have a TDI filter and I am modifying the incoming and
outgoing traffic.

When my receive event handler is called, I pass the data to
AFD by calling its receive event handler.

If AFD returns STATUS_MORE_PROCESSING_REQUIRED and passes me
an IRP, I try to get the virtual address from the MDL
associated to IRP (Irp->MdlAddress).

My problem is some times I am getting an invalid address.
This happens rarely though.
I can’t figure out why AFD is passing me an invalid address.
Probably it is not mapping the user space buffer to system space.
I am extracting the StartVa field using MmGetMdlVirtualAddress.

And this problem occurs on Windows 2000 SP4 only.
Any clue…??

The workaround I have found is to check the virtual address
using MmIsAddressValid and if it is invalid, map it using
MmGetSystemAddressForMdlSafe. Do I need to unmap the pages
also if mapping is done by MmGetSystemAddressForMdlSafe?

Regards
Vijender


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as:
xxxxx@windows.microsoft.com To unsubscribe send a blank
email to xxxxx@lists.osr.com

>

My problem is some times I am getting an invalid address. This happens
rarely though.
I can’t figure out why AFD is passing me an invalid address. Probably it is
not mapping the user space buffer to system space.
I am extracting the StartVa field using MmGetMdlVirtualAddress.

Weeeellll… I’m no AFD expert, OK? So, perhaps there’s some special
AFD convention that you’re referring to that would allow you to do this.

But IN GENERAL (for any KM driver), when you get an MDL in a driver,
there’s no reason that you should think MmGetMdlVirtualAddress will give
you an address you can USE in kernel mode, in the current process context.

If you want a Kernel Virtual Address, given an MDL, you call
MmGetSystemAddressForMdlSafe(…). Full stop. You do not need to do
anything to unmap this (in fact, you shouldn’t, given that part of the
point of this function is that successive drivers can call it without
creating a separate mapping – See the code for this macro in wdm.h).

Peter
OSR