Previous commit 4de57a9ff causes driver verifier assertion with
latest Windows builds. Note that this assertion is not in latest
WDF sources on GitHub. The verifier does not allow to forward
the MJ_CREATE requestto local IO target using "send-and-forget".
It requires the request to set completion callback.
There is an option to remove the file create callback at all, but
we prefer to have printout on file open for better diagnostics.
So we add completion callback for forwarded request and complete
the request in it.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Add callback when filter device receives file open request.
Propagate open operation down the stack and log it.
ETW log will contain process id of open request.
It is possible that more than one process opens the device.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Extended rules processing uses bitmask OR between device type
determination bitmap and class/type bitmap provided in 'Class'
parameter of the extended rule.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Device type bitmask is calculated for device class and classes
of all its interfaces by narrowing set of device classes to set
of device types.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Win7 with USB 3.0 stack might not report superspeed
the same way as Win8 does. Use bcdUSB field of device
descriptor for that (USB 3.0 device connected to USB 2.x
port usually falls to USB 2 compatible configuration).
Getting the speed from HUB driver via IOCTL is more
complicated.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
This commit aims to address
https://bugzilla.redhat.com/show_bug.cgi?id=1575043
The driver definitely may try accessing USB device where
it is not USB and sending 'Submit URB' IOCTL down the stack
may cause unpredictable result. Current commit change
the order of checks when the device is enumerated by its
parent device: first ensure this is USB device, then try
to get USB-specific information.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
It is more correct to use lower device in stack for queries
during filter initialization. Lower device is in initialized
state and can process all kinds of requests, when current one is
not ready yet.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
This is requirement of DeviceGuard and HyperVisor Code
Integrity Readiness Test on Win10/Server2016.
We use Nx allocations for all the systems where Nx pool
is implemented, i.e. for Windows 8 and later.
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
The driver may report non-USB device in list of devices
available for redirection (for example, this happens with
FTDI dual-port serial adapter PID 6010)
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This is useful for devices that change ID on reset.
Previous scheme of raising event on device
"reconnection" after port cycle does not work
for such devices because after reset
they look like another device for UsbDK.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Sometimes UsbDk cannot query device descriptors for USB hubs,
in such cases it does not attach to theirs stack during parent bus
relations processing.
However, since UsbDk is registered as USB hub class filter,
WDF will call its AddDevice callback anyway.
In this case UsbDk should assume that it is dealing with a hub
and assign its usual hub strategy.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
m_Relations can be null therefore we should access it carefully.
Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This patch adds support for IRP post processing
on failure and in all cases.
New logic will be used by following commits to
implement device text patching.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This commit retires old device hider logic based
on wiping PDOs from BusRelations array.
Previous commits introduce new logic based on IDs
patching.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Wiping PDOs from BusRelations list has side effect
of absence of hotplug events from the OS.
This is not good for applications that want devices
appear hidden and start redirection process on plug
at the same time.
Following patches will retire old hiding logic.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This patch makes filter object reference counting objects and
ensures reference is help to filter objects while they are in use.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This patch fixes access to bus device relations array
allocated from paged memory pool under child device list
spinlock.
Fixed by creation of temporary non-paged copy of the paged data.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
1. Never hide PDOs indicated to PNP manager
since we're not owning those after the indication
2. Dereferenced PDOs for hidden devices on device removal
because we're the owner of those PDOs
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
If driver fails filter device creation process
before WDF device created context memory allocated
must be freed explicitely.
Bug found by HCK fault injection test.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
It is basically forbidden to send arbitrary requests to device
directly via PDO while device driver is present in device stack.
This may lead to unexpected behaviour because device may be
in many different states e.g. low power, processing other
requests etc.
In order to avoid sending descriptor requests to devices with
active functional driver we're caching all descriptors we need
on QDR post-processing while we're on top of device stack for
sure.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
During stop redirection process driver signals
redirection stopped event before adding corresponding
device back to childen list.
In case of unfortunate timing client code that
enumerates devices right after stoppng redirection
may not get device for which redirection was stopped
in devices list.
This patch fixes the issue by changing order of
corresponding operations.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Move redirection stopped event signalling from DeviceAdd
callback to QDR post-processing callback.
DeviceAdd callback is not (usually) called for non-redirected devices.
Without this patch stop redirection process fails to
complete because corresponing event never set.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Symlinks not needed anymore since we create redirector handles
in kernel.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This commit makes redirection creation atomic operation
from user mode client point of view.
This ensures redirection will be stopped automatically
in case of unexpected user mode client termination.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This makes include policy more strict and ensures
all system includes properly wrapped with extern "C"
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
For some USB devices system calls our AddDevice callback for FDO.
In addition we call the same callback for PDO of the devices we
want to redirect. In this case we will try to install our filter
two times into the same stack which is problematic.
This patch eliminates such a possibility.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>