Owen Smith [Thu, 12 Aug 2021 12:33:47 +0000 (13:33 +0100)]
Fix SDV/CodeQL log generation
- sarif files need to be stored with SDV logs when generating the DVL file
- Disable PREFast and CodeAnalysis by default
- Run a seperate CodeAnalysis build after SDV, but before generating DVL file
DVL file should contain multiple summary lines for SDV, at least 1 line
for CodeAnalysis and at least 1 line for Semmle (CodeQL)
Owen Smith [Thu, 12 Aug 2021 12:33:46 +0000 (13:33 +0100)]
Fix build with later WDKs
- Adds alias for GetProjectInfoForReference target to version.vcxproj
Later kits seemed to have renamed the build target, and will fail without
this alias target.
- Adds "/fd sha256" to signtool command line
WDK 20344 and later require binaries signed with a SHA256 file digest, or
the build outputs are deleted
Signed-off-by: Owen Smith <owen.smith@citrix.com>
- Squash warnings 4061 (in xencons.vcxproj) and 26052 (in
xencons_monitor.vcxproj) to avoid bogus noise.
Owen Smith [Fri, 5 Mar 2021 10:14:18 +0000 (10:14 +0000)]
Add CodeQL build stage
CodeQL logs will be required for future WHQL submissions. Add a stage
that generates the required SARIF files. CodeQL is a semantic code
analysis engine, which will highlight vunerabilities that will need
fixing.
In order to use CodeQL, the CodeQL binaries must be on the path and the
Windows-Driver-Developer-Supplemental-Tools must be on the path defined
by the CODEQL_QUERY_SUITE environment variable (if defined), or under
the parent folder (if CODEQL_QUERY_SUITE variable is not defined)
Note: Due to the way the codeql command line is built, using quotes in a
MSBuild command line is not possible, so generate a batch file to wrap
the command line.
Inherit versioning info from environment if present
As the drivers stabilize and mature, there is an ever-growing
chance that other opensource virtualization projects will adopt
them. Allow external projects to inject their own versioning
into the drivers instead of hardcoding the latest winpv version.
Signed-off-by: Nicholas Tsirakis <tsirakisn@ainfosec.com> Acked-by: Owen Smith <owen.smith@citrix.com>
Often times we only need to build a driver for a single
targeted architecture. Continue to build both by default,
but allow the user to specify one if desired.
Signed-off-by: Nicholas Tsirakis <tsirakisn@ainfosec.com>
Use [string]::IsNullOrEmpty($Arch)
These bugchecks have been observed in recent updates of Server 2019.
This patch, rather than replacing calls to MmAllocatePagesForMdlEx() with
calls to MmMapLockedPagesSpecifyCache(), just avoids passing
MM_DONT_ZERO_ALLOCATION to work round the bug.
The patch instead passes MM_ALLOCATE_FULLY_REQUIRED, which arguably should
have always been passed for allocations larger than a single page. It also
fixes a formatting issue.
Reported-by: Jan Bakuwel <jan.bakuwel@gmail.com> Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Owen Smith [Thu, 7 Nov 2019 15:53:16 +0000 (15:53 +0000)]
Add option to elevate administrator users
If the user has Administrator access, add a prompt and ability to
elevate the access to the Administrator privilege level instead of
retaining the user privilege level.
Signed-off-by: Owen Smith <owen.smith@citrix.com>
[squashed 'Improve elevation prompts'] Signed-off-by: Paul Durrant <paul@xen.org>
Owen Smith [Fri, 14 Jun 2019 16:01:11 +0000 (17:01 +0100)]
Add PowerShell build scripts, version.vcxproj
Based on the sequence of commits to xenbus, add powershell scripts to
build the solution using the EWDK
version.vcxproj generates versioned files (version.h and xencons.inf) using
scripts/genfiles.ps1
Strips duplicated functionality from build.py toproduce consistant
builds between python and powershell.
Owen Smith [Thu, 8 Nov 2018 10:18:11 +0000 (10:18 +0000)]
Add more logging to xencons_tty
Signed-off-by: Owen Smith <owen.smith@citrix.com>
Don't restrict logging to debug builds and use 4 '=' characters in arrows,
to be consistent with other code.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Owen Smith [Thu, 8 Nov 2018 09:52:37 +0000 (09:52 +0000)]
Disable warning 5032
WDK17763 triggers a warning (mismatched #pragma warning(push)) in
include/um/winioctl.h
Disable this warning until the WDK header has resolved this issue.
Owen Smith [Fri, 24 Aug 2018 16:46:43 +0000 (17:46 +0100)]
Conditionally package DPInst
Since DPInst.exe is not shipped with the Windows Driver Kit 10, an
environment variable must point to local copies. Make the inclusion of
DPInst conditional on DPINST_REDIST being defined and that path
existing. This simplifies building packages which do not require DPInst
for installation, and removes a required step to create a working build.
Owen Smith [Fri, 2 Mar 2018 13:23:37 +0000 (13:23 +0000)]
Fail FrontendPrepare if backend doesn't re-initialize
Current backend will crash (taking out the VM) if any attempt is
made to reconnect to a backend that has transitioned to the
Closed state. Forces the frontend offline, which will fail the
frontend state transitions, and its initiating IRP.
Owen Smith [Fri, 2 Mar 2018 13:09:10 +0000 (13:09 +0000)]
Implement ring protocol
Adds ring.h/.c which implements the console ring protocol and
handles the cancel safe queues for the outstanding read/write IRPs.
Connect the ring with the state protocol in the frontend.
Also fixes frontend state transitions to get allow the ring to
connect and operate correctly.
Owen Smith [Fri, 2 Mar 2018 11:43:00 +0000 (11:43 +0000)]
Add boilerplate frontend
* Frontend is used for non-default consoles
* State changes are disabled for now, as there is insufficient
implementation to handle the state model (no evtchn/gnttab changes)
* Reads "protocol" and "name" xenstore fields
Signed-off-by: Owen Smith <owen.smith@citrix.com>
Re-worked create/destroy code and renamed some items
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Owen Smith [Thu, 1 Mar 2018 17:21:34 +0000 (17:21 +0000)]
Hide console access behind an interface
* Allows a different implementation of the console protocol for
non-default consoles.
Signed-off-by: Owen Smith <owen.smith@citrix.com>
* Re-worked create/destroy and renamed some items.
* Left IsDefault as a flag on the Pdo.
* Fail to create the PDO in the non-default case.
* ASSERT the Pdo is default before attempting to use the ABI, since it
is only valid in this case.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Owen Smith [Thu, 1 Mar 2018 12:43:09 +0000 (12:43 +0000)]
Make monitor service multi-console aware
* Move console specific data to a seperate structure
* Make all threads' use the console data
* Removes the Add and Remove event in favor of inline add/remove
* Convert Win32 calls to explicit narrow/wide character set as appropriate
* Removes tchar.h include to force narrow/wide character usage
* Renames structures and thread functions
* Pipe names are based on console name
* INF file stores "Executable" under console's name subkey
* Change pipe name tty.exe uses
* Add WaitNamedPipe() before connecting to pipes in tty.exe
Owen Smith [Thu, 1 Mar 2018 12:13:58 +0000 (12:13 +0000)]
Add IOCTLs to query instance, name and protocol
Signed-off-by: Owen Smith <owen.smith@citrix.com>
Renamed __ConsolePutQueue() to __ConsoleReadWrite().
PdoDispatchReadWriteClose() should mark pending IRPs.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Owen Smith [Wed, 28 Feb 2018 17:21:36 +0000 (17:21 +0000)]
Move console handlers to console.c
Isolate console handler code from fdo code.
This will make the console code easier to maintain.
Signed-off-by: Owen Smith <owen.smith@citrix.com>
Rename __ConsoleDestroy() to __ConsoleDestroyHandle() and introduce
__ConsoleCreateHandle() which is called by ConsoleOpen() to allocate and
initialize a handle.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 25 Jan 2018 14:16:12 +0000 (14:16 +0000)]
Update util.h
XENCONS does not use much of the functionality in util.h, including the
__AllocatePages() function modified by this change, however
it is good to keep the header in-sync with the other drivers.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Owen Smith [Mon, 11 Sep 2017 20:08:29 +0000 (13:08 -0700)]
Handle DBT_DEVICEREMOVEPENDING and DBT_DEVICEREMOVECOMPLETE
When surprise removed, DBT_DEVICEQUERYREMOVE is not called, and
the handles opened by the service need closing before the driver
gets the IRP_MN_REMOVE_DEVICE Irp.
Owen Smith [Mon, 11 Sep 2017 20:04:22 +0000 (13:04 -0700)]
Destroy all handles on FdoD0ToD3
Since the StreamWorker holds a reference to the XENBUS_CONS interface,
xenbus will BUG_ON if the handles are not cleaned up before power down.
The service should close all handles in response to a
DBT_DEVICEQUERYREMOVE notification, but this may not be issued on
system power down.
Signed-off-by: Owen Smith <owen.smith@citrix.com>
Added missing UNREFERENCED_PARAMETER() to fix build failure.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Owen Smith [Tue, 29 Aug 2017 11:05:02 +0000 (12:05 +0100)]
Cancel all outstanding IRPs in StreamDestroy
After IRP_MJ_CLEANUP completes, all outstanding IRPs (for that FileObject)
are cancelled. This would attempt to use the cancel safe queue and list
which are now zeroed, and lead to a 0xCC Bugcheck.
Owen Smith [Tue, 29 Aug 2017 10:07:48 +0000 (11:07 +0100)]
Ensure handles are closed when pipe disconnects
Fixes leaks where the pipe handles were not closed, preventing new
connections. Fixes the MONITOR_PIPE context leaking when its thread
is stopped.
Signed-off-by: Owen Smith <owen.smith@citrix.com>
Since error gotos are introduced, have them do the cleanup. The scope of
Pipe and Instance needs to be widened but it keeps the code neater overall.
Also removed the unnecessary newlines in the log messages.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Owen Smith [Tue, 25 Jul 2017 12:39:30 +0000 (13:39 +0100)]
Add named pipe server
Create a threaded NamedPipe server for the device.
This will be used to pass data from the console to child processes, and
read data from the child processes to pass to the console device.
Signed-off-by: Owen Smith <owen.smith@citrix.com>
s/memset/ZeroMemory
Add a '__' prefix to forceinlined list manipulation primitives
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Thu, 18 May 2017 11:05:54 +0000 (12:05 +0100)]
Add BUILD.md and fix final package location
Microsoft helpfully removed the PackageDir property from package projects
in VS2015 so, as an interim fix, OutDir was used. This unfortunately means
that package output ends up in xencons/<arch>/package rather than just
xencons/<arch>.
This patch fixes the final package location by using python to do the
final copy (replacing what older VS used to do) and also adds a BUILD.md,
which was missing.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 5 May 2017 15:02:26 +0000 (16:02 +0100)]
Add a TTY utility
This patch adds a new TTY utility which will open the console device and
pipe it to a command shell (cmd.exe) process. It also provides login
functionality for a local user such that the command shell is invoked as
that user.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Paul Durrant [Fri, 5 May 2017 14:24:27 +0000 (15:24 +0100)]
Add console functionality
This patch adds a new interface so that user-space code can open a
character device to the PV console along with all the necessary dispatch
handling for basic functionality.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>